aesgcm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AESGCM

type AESGCM struct {
	// contains filtered or unexported fields
}

AESGCM implements the crypto.Crypto interface using the AES-GCM algorithm for symmetric-key encryption. This algorithm is widely adopted for it's performance and throughput rates for state-of-the-art high-speed communication on inexpensive hardware (Wikipedia). This implementation generates a 32 byte random encryption key when initialized, if one not specified by default. Users should create a new AESGCM to encrypt and sign different messages with different keys.

func New

func New(encryptionKey, hmacSecret []byte) (_ *AESGCM, err error)

New creates an AESGCM Crypto handler, generating an encryption key if it is nil or zero length. If hmac_secret isn't specified, the encryption key is used. The key and secret should be 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func (*AESGCM) Decrypt

func (c *AESGCM) Decrypt(ciphertext []byte) (plaintext []byte, err error)

Decrypt a message using the struct key, extracting the nonce from the end.

func (*AESGCM) Encrypt

func (c *AESGCM) Encrypt(plaintext []byte) (ciphertext []byte, err error)

Encrypt a message using the struct key, appending a 12 byte random nonce to the end of the ciphertext message.

func (*AESGCM) EncryptionAlgorithm

func (c *AESGCM) EncryptionAlgorithm() string

EncryptionAlgorithm returns the name of the algorithm for adding to the Transaction.

func (*AESGCM) EncryptionKey

func (c *AESGCM) EncryptionKey() []byte

EncryptionKey is a read-only getter.

func (*AESGCM) HMACSecret

func (c *AESGCM) HMACSecret() []byte

HMACSecret is a read-only getter.

func (*AESGCM) Sign

func (c *AESGCM) Sign(data []byte) (signature []byte, err error)

Sign the specified data (ususally the ciphertext) using the struct secret.

func (*AESGCM) SignatureAlgorithm

func (c *AESGCM) SignatureAlgorithm() string

SignatureAlgorithm returns the name of the hmac_algorithm for adding to the Transaction.

func (*AESGCM) Verify

func (c *AESGCM) Verify(data, signature []byte) (err error)

Verify the signature on the specified data using the struct secret.

Jump to

Keyboard shortcuts

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