AES-GCM API.
More...
Go to the source code of this file.
|
| int | zpc_aes_gcm_alloc (struct zpc_aes_gcm **ctx) |
| int | zpc_aes_gcm_set_key (struct zpc_aes_gcm *ctx, struct zpc_aes_key *key) |
| int | zpc_aes_gcm_create_iv (struct zpc_aes_gcm *ctx, unsigned char *iv, size_t ivlen) |
| int | zpc_aes_gcm_set_iv (struct zpc_aes_gcm *ctx, const unsigned char *iv, size_t ivlen) |
| int | zpc_aes_gcm_encrypt (struct zpc_aes_gcm *ctx, unsigned char *ct, unsigned char *mac, size_t maclen, const unsigned char *aad, size_t aadlen, const unsigned char *pt, size_t ptlen) |
| int | zpc_aes_gcm_decrypt (struct zpc_aes_gcm *ctx, unsigned char *pt, const unsigned char *mac, size_t maclen, const unsigned char *aad, size_t aadlen, const unsigned char *ct, size_t ctlen) |
| void | zpc_aes_gcm_free (struct zpc_aes_gcm **ctx) |
AES-GCM API.
Authenticated encryption API for the Advanced Encryption Standard (AES) block cipher [1] in Galois/Counter Mode mode of operation [6] .
Definition in file aes_gcm.h.
◆ zpc_aes_gcm_alloc()
| int zpc_aes_gcm_alloc |
( |
struct zpc_aes_gcm ** | ctx | ) |
|
Allocate a new context for an AES-GCM operation.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_set_key()
| int zpc_aes_gcm_set_key |
( |
struct zpc_aes_gcm * | ctx, |
|
|
struct zpc_aes_key * | key ) |
Set the key to be used in the context of an AES-GCM operation.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
| [in] | key | AES key |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_create_iv()
| int zpc_aes_gcm_create_iv |
( |
struct zpc_aes_gcm * | ctx, |
|
|
unsigned char * | iv, |
|
|
size_t | ivlen ) |
Create the initialization vector to be used in the context of an AES-GCM operation. The minimum and recommended iv length is 12 bytes.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
| [in,out] | iv | application provided buffer of at least ivlen bytes to receive the internally created initialization vector |
| [in] | ivlen | initialization vector length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_set_iv()
| int zpc_aes_gcm_set_iv |
( |
struct zpc_aes_gcm * | ctx, |
|
|
const unsigned char * | iv, |
|
|
size_t | ivlen ) |
Set the initialization vector to be used in the context of an AES-GCM operation.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
| [in] | iv | initialization vector |
| [in] | ivlen | initialization vector length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_encrypt()
| int zpc_aes_gcm_encrypt |
( |
struct zpc_aes_gcm * | ctx, |
|
|
unsigned char * | ct, |
|
|
unsigned char * | mac, |
|
|
size_t | maclen, |
|
|
const unsigned char * | aad, |
|
|
size_t | aadlen, |
|
|
const unsigned char * | pt, |
|
|
size_t | ptlen ) |
Do an AES-GCM authenticated encryption operation.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
| [out] | ct | ciphertext |
| [out] | mac | message authentication code |
| [in] | maclen | message authentication code length [bytes] |
| [in] | aad | additional authenticated data |
| [in] | aadlen | additional authenticated data length [bytes] |
| [in] | pt | plaintext |
| [in] | ptlen | plaintext length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_decrypt()
| int zpc_aes_gcm_decrypt |
( |
struct zpc_aes_gcm * | ctx, |
|
|
unsigned char * | pt, |
|
|
const unsigned char * | mac, |
|
|
size_t | maclen, |
|
|
const unsigned char * | aad, |
|
|
size_t | aadlen, |
|
|
const unsigned char * | ct, |
|
|
size_t | ctlen ) |
Do an AES-GCM authenticated decryption operation.
- Parameters
-
| [in,out] | ctx | AES-GCM context |
| [out] | pt | plaintext |
| [in] | mac | message authentication code |
| [in] | maclen | message authentication code length [bytes] |
| [in] | aad | additional authenticated data |
| [in] | aadlen | additional authenticated data length [bytes] |
| [in] | ct | ciphertext |
| [in] | ctlen | ciphertext length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_aes_gcm_free()
| void zpc_aes_gcm_free |
( |
struct zpc_aes_gcm ** | ctx | ) |
|
Free an AES-CCM context.
- Parameters
-
| [in,out] | ctx | AES-GCM context |