Documentation
¶
Overview ¶
Package cipher provides a common interface for symmetric ciphers. This includes both block ciphers and (in the future) stream ciphers. Block cipher modes such as CBC and GCM can be implemented in a cipher-independent way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block interface { // BlockSize returns the configured algorithms block size BlockSize() int // Encrypt encrypts the first block of src and returns it Encrypt(dst, src []byte) // Decrypt decrypts the first block of src and returns it Decrypt(dst, src []byte) }
Block represents a block cipher implementation (with preconfigured key).
It should never be used directly. You should always use a block cipher mode, which in turn uses this block cipher under the hood.
type BlockMode ¶
type BlockMode interface { // BlockSize returns the configured algorithms block size BlockSize() int // CryptBlocks encrypts or decrypts a number of blocks. CryptBlocks(dst, src []byte) }
BlockMode represents a block cipher running in a specific configured mode (CBC, ECB, etc.). It either encrypts or decrypts data.
func NewCBCDecrypter ¶
NewCBCDecrypter returns a BlockMode which decrypts in cipher block chaining mode, using the given Block. The length of iv must be the same as the Block's block size and must match the iv used to encrypt the data.
func NewCBCEncrypter ¶
NewCBCDecrypter returns a BlockMode which decrypts in cipher block chaining mode, using the given Block. The length of iv must be the same as the Block's block size and must match the iv used to encrypt the data.
type Stream ¶
type Stream interface { // XORKeyStream XORs each byte in src with a byte from the key stream. // Because Stream maintains state, multiple calls to XORKeyStream should // behave just as if it was called with a single, concatenated array XORKeyStream(dst, src []byte) }
Stream represents a stream cipher.