Documentation
¶
Overview ¶
Package HCTR2 implements the HCTR2 length-preserving encryption algorithm.
HCTR2 is designed for situations where the length of the ciphertext must exactly match the length of the plaintext, like disk encryption.
This implementation uses a hardware-accelerated POLYVAL implementation when possible; the block cipher is left to the caller. The recommended block cipher is AES.
Index ¶
Constants ¶
const BlockSize = 16
BlockSize is the size of block allowed by this package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher is an instance of the HCTR2 cipher.
func New ¶
New creates a HCTR2 cipher.
The provided Block must have a block size of exactly BlockSize. This restriction may be lifted in the future.
The recommended block cipher is AES.
func NewAES ¶
NewAES creates a HCTR2 cipher using AES.
If supported, the returned Cipher will use a hardware XCTR implementation. Otherwise, it defers to crypto/aes.
The provided AES key should be either 16, 24, or 32 bytes to choose AES-128, AES-192, or AES-256, respectively.
func (*Cipher) Decrypt ¶
Decrypt decrypts ciphertext with tweak and writes the result to plaintext.
The length of plaintext must be greater than or equal to the length of plaintext.
plaintext and ciphertext must overlap entirely or not at all.