NewCipher creates a cipher that can be used in Dial(), Listen() etc.
(rawKey []byte)
| 90 | |
| 91 | // NewCipher creates a cipher that can be used in Dial(), Listen() etc. |
| 92 | func NewCipher(rawKey []byte) (c *Cipher) { |
| 93 | mi := &cipherInfo{ |
| 94 | 32, |
| 95 | 16, |
| 96 | newAESCFBDecStream, |
| 97 | newAESCFBEncStream, |
| 98 | } |
| 99 | hSuite := &hash.HashSuite{ |
| 100 | HashLen: hash.HashBSize, |
| 101 | HashFunc: hash.DoubleHashB, |
| 102 | } |
| 103 | key := KeyDerivation(rawKey, mi.keyLen, hSuite) |
| 104 | c = &Cipher{key: key, info: mi} |
| 105 | |
| 106 | return c |
| 107 | } |
| 108 | |
| 109 | // initEncrypt Initializes the block cipher with CFB mode, returns IV. |
| 110 | func (c *Cipher) initEncrypt() (iv []byte, err error) { |