aead

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package aead provides subtle implementations of the Aead primitive.

Index

Constants

View Source
const (
	// AesGcmIvSize is the only IV size that this implementation supports.
	AesGcmIvSize = 12
	// AesGcmTagSize is the only tag size that this implementation supports.
	AesGcmTagSize = 16
)

Variables

This section is empty.

Functions

func ValidateAesKeySize

func ValidateAesKeySize(sizeInBytes uint32) error

ValidateAesKeySize checks if the given key size is a valid AES key size.

Types

type AesGcm

type AesGcm struct {
	Key []byte
}

AesGcm is an implementation of Aead interface.

func NewAesGcm

func NewAesGcm(key []byte) (*AesGcm, error)

NewAesGcm returns an AesGcm instance. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func (*AesGcm) Decrypt

func (a *AesGcm) Decrypt(ct []byte, aad []byte) ([]byte, error)

Decrypt decrypts {@code ct} with {@code aad} as the additionalauthenticated data.

func (*AesGcm) Encrypt

func (a *AesGcm) Encrypt(pt []byte, aad []byte) ([]byte, error)

Encrypt encrypts {@code pt} with {@code aad} as additional authenticated data. The resulting ciphertext consists of two parts: (1) the IV used for encryption and (2) the actual ciphertext.

Note: AES-GCM implementation of crypto library always returns ciphertext with 128-bit tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL