Documentation
¶
Overview ¶
Package aead provides implementations of the AEAD primitive.
AEAD encryption assures the confidentiality and authenticity of the data. This primitive is CPA secure.
Example ¶
package main
import (
"encoding/base64"
"fmt"
"log"
tinkaead "github.com/google/tink/go/aead"
"github.com/google/tink/go/keyset"
"github.com/hyperledger/aries-framework-go/pkg/crypto/tinkcrypto/primitive/aead"
)
func main() {
kh, err := keyset.NewHandle(aead.AES128CBCHMACSHA256KeyTemplate())
if err != nil {
log.Fatal(err)
}
a, err := tinkaead.New(kh)
if err != nil {
log.Fatal(err)
}
msg := []byte("this message needs to be encrypted")
aad := []byte("this data needs to be authenticated, but not encrypted")
ct, err := a.Encrypt(msg, aad)
if err != nil {
log.Fatal(err)
}
pt, err := a.Decrypt(ct, aad)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Ciphertext: %s\n", base64.StdEncoding.EncodeToString(ct))
fmt.Printf("Original plaintext: %s\n", msg)
fmt.Printf("Decrypted Plaintext: %s\n", pt)
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AES128CBCHMACSHA256KeyTemplate ¶
func AES128CBCHMACSHA256KeyTemplate() *tinkpb.KeyTemplate
AES128CBCHMACSHA256KeyTemplate is a KeyTemplate that generates an AES-CBC-HMAC-AEAD key with the following parameters:
- AES key size: 16 bytes
- HMAC key size: 16 bytes
- HMAC tag size: 16 bytes
- HMAC hash function: SHA256
func AES192CBCHMACSHA384KeyTemplate ¶
func AES192CBCHMACSHA384KeyTemplate() *tinkpb.KeyTemplate
AES192CBCHMACSHA384KeyTemplate is a KeyTemplate that generates an AES-CBC-HMAC-AEAD key with the following parameters:
- AES key size: 24 bytes
- HMAC key size: 24 bytes
- HMAC tag size: 24 bytes
- HMAC hash function: SHA384
func AES256CBCHMACSHA384KeyTemplate ¶
func AES256CBCHMACSHA384KeyTemplate() *tinkpb.KeyTemplate
AES256CBCHMACSHA384KeyTemplate is a KeyTemplate that generates an AES-CBC-HMAC-AEAD key with the following parameters:
- AES key size: 32 bytes
- HMAC key size: 24 bytes
- HMAC tag size: 24 bytes
- HMAC hash function: SHA384
func AES256CBCHMACSHA512KeyTemplate ¶
func AES256CBCHMACSHA512KeyTemplate() *tinkpb.KeyTemplate
AES256CBCHMACSHA512KeyTemplate is a KeyTemplate that generates an AES-CBC-HMAC-AEAD key with the following parameters:
- AES key size: 32 bytes
- HMAC key size: 32 bytes
- HMAC tag size: 32 bytes
- HMAC hash function: SHA512
Types ¶
This section is empty.