AES Full-XTS APIs - zpc/aes_xts_full.h
In file zpc/aes_xts_full.h, libzpc provides an encryption API for the advanced encryption standard (AES) block cipher in XEX-based Tweaked-codebook mode with the ciphertext stealing (XTS) mode of operation.
In contrast to the AES XTS API, the AES full-XTS API uses full-XTS protected keys containing two single AES keys in one single protected key. This feature requires MSA 10.
Data structures
struct zpc_aes_xts_full; Context objects must not be shared among multiple
threads. They may be used for multiple operations by setting or resetting the key or initialization
vector.zpc_aes_xts_full_alloc
Purpose: Allocate a new context for an AES-XTS operation to be used with an AES full-XTS key object.
int zpc_aes_xts_full_alloc (
struct zpc_aes_xts_full **ctx);
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_set_key
Purpose: Set the AES full-XTS key to be used in the context of an AES-XTS operation.
int zpc_aes_xts_full_set_key (
struct zpc_aes_xts_full *ctx,
struct zpc_aes_xts_key *key);
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| input | key | Pointer to an AES full-XTS key . |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_set_iv
Purpose: Set the initialization vector to be used in the context of an AES-XTS operation.
int zpc_aes_xts_full_set_iv (
struct zpc_aes_xts_full *ctx,
const unsigned char *iv);
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| input | iv | Pointer to a 16 byte initialization vector buffer. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_export
Purpose: Get the intermediate state information used in the context of an AES-XTS operation.
int zpc_aes_xts_full_export (
struct zpc_aes_xts_full *ctx,
unsigned char state[32]);
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| output | state | Application-provided buffer of 32 bytes to receive the 32 byte intermediate state information. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_import
Purpose: Set the intermediate state information to be used in the context of an AES-XTS operation.
int zpc_aes_xts_full_import (
struct zpc_aes_xts_full *ctx,
const unsigned char state[32])
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| input | state | Buffer of 32 bytes containing the intermediate state information as obtained via zpc_aes_xts_full_export().. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_encrypt
Purpose: Perform an AES-XTS encryption operation.
int zpc_aes_xts_full_encrypt (
struct zpc_aes_xts_full *ctx,
unsigned char *ct,
const unsigned char *pt,
size_t ptlen);
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| output | ct | Pointer to a ciphertext buffer. |
| input | pt | Pointer to a plaintext buffer. |
| input | ptlen | Plaintext length [bytes]. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_decrypt
Purpose: Perform an AES-XTS decryption operation.
int zpc_aes_xts_full_decrypt (
struct zpc_aes_xts_full *ctx,
unsigned char *pt,
const unsigned char *ct,
size_t ctlen)
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |
| output | pt | Pointer to a plaintext buffer. |
| input | ct | Pointer to a ciphertext buffer. |
| input | ctlen | Ciphertext length [bytes]. |
Return codes:
0 on success. Otherwise, a non-zero error code is returned.
zpc_aes_xts_full_free
Purpose: Free an AES full-XTS context.
int zpc_aes_xts_full_free (
struct zpc_aes_xts_full **ctx)
Parameters:
| Direction | Name | Description |
|---|---|---|
| input, output | ctx | Pointer to an AES full-XTS context. |