github.com/lestrrat-go/jwx/v2@v2.0.21/jwe/internal/cipher/interface.go (about) 1 package cipher 2 3 import ( 4 "crypto/cipher" 5 6 "github.com/lestrrat-go/jwx/v2/jwe/internal/keygen" 7 ) 8 9 const ( 10 TagSize = 16 11 ) 12 13 // ContentCipher knows how to encrypt/decrypt the content given a content 14 // encryption key and other data 15 type ContentCipher interface { 16 KeySize() int 17 Encrypt(cek, aad, plaintext []byte) ([]byte, []byte, []byte, error) 18 Decrypt(cek, iv, aad, ciphertext, tag []byte) ([]byte, error) 19 } 20 21 type Fetcher interface { 22 Fetch([]byte) (cipher.AEAD, error) 23 } 24 25 type gcmFetcher struct{} 26 type cbcFetcher struct{} 27 28 // AesContentCipher represents a cipher based on AES 29 type AesContentCipher struct { 30 NonceGenerator keygen.Generator 31 fetch Fetcher 32 keysize int 33 tagsize int 34 }