random.go
func (ri *randInfo) MixEntropy(seedBytes []byte) {
	ri.mtx.Lock()
	defer ri.mtx.Unlock()
	// Make new ri.seedBytes using passed seedBytes and current ri.seedBytes:
	// ri.seedBytes = sha256( seedBytes || ri.seedBytes )
	h := sha256.New()
	h.Write(seedBytes)
	h.Write(ri.seedBytes[:])
	hashBytes := h.Sum(nil)
	hashBytes32 := [32]byte{}
	copy(hashBytes32[:], hashBytes)
	ri.seedBytes = xorBytes32(ri.seedBytes, hashBytes32)
	// Create new cipher.Block
	var err error
	ri.cipherAES256, err = aes.NewCipher(ri.seedBytes[:])
	if err != nil {
		PanicSanity("Error creating AES256 cipher: " + err.Error())
	}
	// Create new stream
	ri.streamAES256 = cipher.NewCTR(ri.cipherAES256, randBytes(aes.BlockSize))
	// Create new reader
	ri.reader = &cipher.StreamReader{S: ri.streamAES256, R: crand.Reader}
}
func (ri *randInfo) MixEntropy(seedBytes []byte) {
	ri.mtx.Lock()
	defer ri.mtx.Unlock()
	// Make new ri.seedBytes using passed seedBytes and current ri.seedBytes:
	// ri.seedBytes = sha256( seedBytes || ri.seedBytes )
	h := sha256.New()
	h.Write(seedBytes)
	h.Write(ri.seedBytes[:])
	hashBytes := h.Sum(nil)
	hashBytes32 := [32]byte{}
	copy(hashBytes32[:], hashBytes)
	ri.seedBytes = xorBytes32(ri.seedBytes, hashBytes32)
	// Create new cipher.Block
	var err error
	ri.cipherAES256, err = aes.NewCipher(ri.seedBytes[:])
	if err != nil {
		PanicSanity("Error creating AES256 cipher: " + err.Error())
	}
	// Create new stream
	ri.streamAES256 = cipher.NewCTR(ri.cipherAES256, randBytes(aes.BlockSize))
	// Create new reader
	ri.reader = &cipher.StreamReader{S: ri.streamAES256, R: crand.Reader}
}
func ( ri * randInfo ) MixEntropy ( seedBytes [ ] byte ) { ri . mtx . Lock ( ) defer ri . mtx . Unlock ( ) // Make new ri.seedBytes using passed seedBytes and current ri.seedBytes: // ri.seedBytes = sha256( seedBytes || ri.seedBytes ) h := sha256 . New ( ) h . Write ( seedBytes ) h . Write ( ri . seedBytes [ : ] ) hashBytes := h . Sum ( nil ) hashBytes32 := [ 32 ] byte { } copy ( hashBytes32 [ : ] , hashBytes ) ri . seedBytes = xorBytes32 ( ri . seedBytes , hashBytes32 ) // Create new cipher.Block var err error ri . cipherAES256 , err = aes . NewCipher ( ri . seedBytes [ : ] ) if err != nil { PanicSanity ( " " + err . Error ( ) ) } // Create new stream ri . streamAES256 = cipher . NewCTR ( ri . cipherAES256 , randBytes ( aes . BlockSize ) ) // Create new reader ri . reader = & cipher . StreamReader { S : ri . streamAES256 , R : crand . Reader } }
// You can call this as many times as you'd like.
// XXX TODO review
You can call this as many times as you d like . XXX TODO review