Documentation ¶
Overview ¶
Package aead provides internal implementations of the AEAD primitive.
Index ¶
Constants ¶
const ( // AESGCMIVSize is the acceptable IV size defined by RFC 5116. AESGCMIVSize = 12 // AESGCMTagSize is the acceptable tag size defined by RFC 5116. AESGCMTagSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func ValidateAESKeySize ¶
ValidateAESKeySize checks if the given key size is a valid AES key size.
Types ¶
type AESGCMInsecureIV ¶
type AESGCMInsecureIV struct { Key []byte // contains filtered or unexported fields }
AESGCMInsecureIV is an insecure implementation of the AEAD interface that permits the user to set the IV.
func NewAESGCMInsecureIV ¶
func NewAESGCMInsecureIV(key []byte, prependIV bool) (*AESGCMInsecureIV, error)
NewAESGCMInsecureIV returns an AESGCMInsecureIV instance, where key is the AES key with length 16 bytes (AES-128) or 32 bytes (AES-256).
If prependIV is true, both the ciphertext returned from Encrypt and passed into Decrypt are prefixed with the IV.
func (*AESGCMInsecureIV) Decrypt ¶
func (i *AESGCMInsecureIV) Decrypt(iv, ciphertext, associatedData []byte) ([]byte, error)
Decrypt decrypts ciphertext with iv as the initialization vector and associatedData as associated data.
If prependIV is true, the iv argument and the first AESGCMIVSize bytes of ciphertext must be equal. The ciphertext argument is as follows:
| iv | actual ciphertext | tag |
If false, the ciphertext argument is as follows:
| actual ciphertext | tag |
func (*AESGCMInsecureIV) Encrypt ¶
func (i *AESGCMInsecureIV) Encrypt(iv, plaintext, associatedData []byte) ([]byte, error)
Encrypt encrypts plaintext with iv as the initialization vector and associatedData as associated data.
If prependIV is true, the returned ciphertext contains both the IV used for encryption and the actual ciphertext. If false, the returned ciphertext contains only the actual ciphertext.
Note: The crypto library's AES-GCM implementation always returns the ciphertext with an AESGCMTagSize (16-byte) tag.
type ChaCha20Poly1305InsecureNonce ¶
type ChaCha20Poly1305InsecureNonce struct {
Key []byte
}
ChaCha20Poly1305InsecureNonce is an insecure implementation of the AEAD interface that permits the user to set the nonce.
func NewChaCha20Poly1305InsecureNonce ¶
func NewChaCha20Poly1305InsecureNonce(key []byte) (*ChaCha20Poly1305InsecureNonce, error)
NewChaCha20Poly1305InsecureNonce returns a ChaCha20Poly1305InsecureNonce instance. The key argument should be a 32-bytes key.