Documentation
¶
Index ¶
- Constants
- type AESGCM
- func (c *AESGCM) Decrypt(ciphertext []byte) (plaintext []byte, err error)
- func (c *AESGCM) Encrypt(plaintext []byte) (ciphertext []byte, err error)
- func (c *AESGCM) EncryptionAlgorithm() string
- func (c *AESGCM) EncryptionKey() []byte
- func (c *AESGCM) HMACSecret() []byte
- func (c *AESGCM) Sign(data []byte) (signature []byte, err error)
- func (c *AESGCM) SignatureAlgorithm() string
- func (c *AESGCM) Verify(data, signature []byte) (err error)
Constants ¶
const ( Algorithm = "AES-GCM" SignatureAlgorithm = "HMAC-SHA256" Algorithm256 = "AES256-GCM" Algorithm192 = "AES192-GCM" Algorithm128 = "AES128-GCM" )
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 ¶
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) Encrypt ¶
Encrypt a message using the struct key, appending a 12 byte random nonce to the end of the ciphertext message.
func (*AESGCM) EncryptionAlgorithm ¶
EncryptionAlgorithm returns the name of the algorithm for adding to the Transaction.
func (*AESGCM) EncryptionKey ¶
EncryptionKey is a read-only getter.
func (*AESGCM) SignatureAlgorithm ¶
SignatureAlgorithm returns the name of the hmac_algorithm for adding to the Transaction.