package aead
import "github.com/google/tink/go/internal/aead"
Package aead provides internal implementations of the AEAD primitive.
Index ¶
- Constants
- func ValidateAESKeySize(sizeInBytes uint32) error
- type AESGCMInsecureIV
- func NewAESGCMInsecureIV(key []byte, prependIV bool) (*AESGCMInsecureIV, error)
- func (i *AESGCMInsecureIV) Decrypt(iv, ciphertext, associatedData []byte) ([]byte, error)
- func (i *AESGCMInsecureIV) Encrypt(iv, plaintext, associatedData []byte) ([]byte, error)
- type ChaCha20Poly1305InsecureNonce
- func NewChaCha20Poly1305InsecureNonce(key []byte) (*ChaCha20Poly1305InsecureNonce, error)
- func (ca *ChaCha20Poly1305InsecureNonce) Decrypt(nonce, ciphertext, associatedData []byte) ([]byte, error)
- func (ca *ChaCha20Poly1305InsecureNonce) Encrypt(nonce, plaintext, associatedData []byte) ([]byte, error)
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 )
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.
func (*ChaCha20Poly1305InsecureNonce) Decrypt ¶
func (ca *ChaCha20Poly1305InsecureNonce) Decrypt(nonce, ciphertext, associatedData []byte) ([]byte, error)
Decrypt decrypts ciphertext with nonce and associatedData.
func (*ChaCha20Poly1305InsecureNonce) Encrypt ¶
func (ca *ChaCha20Poly1305InsecureNonce) Encrypt(nonce, plaintext, associatedData []byte) ([]byte, error)
Encrypt encrypts plaintext with nonce and associatedData.
Source Files ¶
aead.go aes_gcm_insecure_iv.go chacha20poly1305_insecure_nonce.go
- Version
- v1.7.0 (latest)
- Published
- Aug 10, 2022
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 3 months ago –
Tools for package owners.