func (c *skeinConfiguration) generateConfiguration() {

	tweak := newUbiTweak()

	// Initialize the tweak value
	tweak.startNewBlockType(uint64(Config))
	tweak.setFinalBlock(true)
	tweak.setBitsProcessed(32)

	cipher, _ := threefish.NewSize(c.numStateWords * 64)
	cipher.SetTweak(tweak.getTweak())
	cipher.Encrypt64(c.configValue, c.configString)

	c.configValue[0] ^= c.configString[0]
	c.configValue[1] ^= c.configString[1]
	c.configValue[2] ^= c.configString[2]
}
示例#2
0
文件: skein.go 项目: supr/Skein3Fish
// Initialize the internal variables
//
func (s *Skein) setup(stateSize, outputSize int) {
	s.cipherStateWords = stateSize / 64

	s.hashSize = outputSize
	s.outputBytes = (outputSize + 7) / 8

	// Figure out which cipher we need based on
	// the state size
	s.cipher, _ = threefish.NewSize(stateSize)

	// Allocate buffers
	s.inputBuffer = make([]byte, s.cipherStateWords*8)
	s.cipherInput = make([]uint64, s.cipherStateWords)
	s.state = make([]uint64, s.cipherStateWords)

	// Allocate tweak
	s.ubiParameters = newUbiTweak()
}