Source File
ige.go
Belonging Package
github.com/gotd/ige
package igeimport ()// ErrInvalidIV is displayed as the panic message if the initialization vector// passed to NewIGEEncrypter or NewIGEDecrypter doesn't fulfill the length// requirements for IGE.//// IGE uses a two step xor process, so the first initialization vector is the// first half, and the second initialization vector is the second half. This// requires the initialization vector to be twice as long as the block size.var ErrInvalidIV = errors.New("iv length must be: (block size * 2)")// IGE satisfies the cipher.BlockMode interface from the crypto/cipher package.type IGE interface {// BlockSize returns the mode's block size.BlockSize() int// CryptBlocks encrypts or decrypts a number of blocks based on the// underlying cipher.Block passed to NewIGEEncrypter or NewIGEDecrypter// (usually from crypto/aes).CryptBlocks(dst, src []byte)}type ige struct {block cipher.Blockiv []byte}func ( cipher.Block, []byte) *ige {:= &ige{, make([]byte, len())}copy(.iv, )return}func ( cipher.Block, []byte) error {// the initialization vector needs to contain b.Blocksize()*2 bytes because// ige uses a two step xor process, and iv[:16] corresponds to the first iv// while iv[16:] corresponds to the second iv//// the original ige paper described the first iv as a random block and the// second iv as its encrypted counterpart, however, we're copying the// openssl implementation and therefore both ivs are supplied by the userif len() != .BlockSize()*2 {return ErrInvalidIV}return nil}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |