HKDS: Heirarchal Key Derivation System 1.0.0.2 (A2)
A fast post-quantum secure replacement for DUKPT
|
HKDS client functions and definitions. More...
#include "hkds_config.h"
Go to the source code of this file.
Data Structures | |
struct | hkds_client_state |
Contains the HKDS client state. More... | |
Functions | |
HKDS_EXPORT_API bool | hkds_client_decrypt_token (hkds_client_state *state, const uint8_t *etok, uint8_t *token) |
Decrypt an encrypted token key received from the server. | |
HKDS_EXPORT_API bool | hkds_client_encrypt_message (hkds_client_state *state, const uint8_t *plaintext, uint8_t *ciphertext) |
Encrypt a message to be sent to the server. | |
HKDS_EXPORT_API bool | hkds_client_encrypt_authenticate_message (hkds_client_state *state, const uint8_t *plaintext, const uint8_t *data, size_t datalen, uint8_t *ciphertext) |
Encrypt a message and append an authentication tag. | |
HKDS_EXPORT_API void | hkds_client_generate_cache (hkds_client_state *state, const uint8_t *token) |
Generate the transaction key cache (TKC) for the client. | |
HKDS_EXPORT_API void | hkds_client_initialize_state (hkds_client_state *state, const uint8_t *edk, const uint8_t *did) |
Initialize the HKDS client state. | |
HKDS client functions and definitions.
This file contains definitions and function prototypes for the HKDS (Hierarchical Key Derivation System) client. The HKDS protocol uses cryptographic primitives defined by NIST standards (such as SHA-3, SHAKE, and KMAC) to securely exchange tokens and encrypt messages between client devices and a transaction server.
The HKDS client module handles the following operations:
These functions ensure that client messages remain confidential and authenticated during transmission.
HKDS_EXPORT_API bool hkds_client_decrypt_token | ( | hkds_client_state * | state, |
const uint8_t * | etok, | ||
uint8_t * | token ) |
Decrypt an encrypted token key received from the server.
This function decrypts the encrypted token key (ETOK) sent by the server during the token exchange process. The decryption procedure includes the following steps:
state | [in] Pointer to the HKDS client state structure. |
etok | [in] Pointer to the array containing the encrypted token key. |
token | [out] Pointer to the output buffer where the decrypted token key will be stored. |
HKDS_EXPORT_API bool hkds_client_encrypt_authenticate_message | ( | hkds_client_state * | state, |
const uint8_t * | plaintext, | ||
const uint8_t * | data, | ||
size_t | datalen, | ||
uint8_t * | ciphertext ) |
Encrypt a message and append an authentication tag.
This function performs authenticated encryption by executing two sequential operations:
The final output is a concatenation of the ciphertext and the generated MAC authentication tag.
state | [in] Pointer to the HKDS client state structure. |
plaintext | [in] Pointer to the plaintext message array. |
data | [in] Pointer to an optional additional data array to be included in the MAC computation. |
datalen | [in] The length (in bytes) of the additional data array. |
ciphertext | [out] Pointer to the buffer where the authenticated encrypted message will be stored. |
HKDS_EXPORT_API bool hkds_client_encrypt_message | ( | hkds_client_state * | state, |
const uint8_t * | plaintext, | ||
uint8_t * | ciphertext ) |
Encrypt a message to be sent to the server.
This function encrypts a plaintext message by performing the following steps:
If the key cache is empty, the function returns false, indicating that encryption cannot proceed.
state | [in] Pointer to the HKDS client state structure. |
plaintext | [in] Pointer to the plaintext message array. |
ciphertext | [out] Pointer to the buffer where the resulting encrypted message (ciphertext) will be stored. |
HKDS_EXPORT_API void hkds_client_generate_cache | ( | hkds_client_state * | state, |
const uint8_t * | token ) |
Generate the transaction key cache (TKC) for the client.
This function generates a new Transaction Key Cache using the provided secret token key and the client's Embedded Device Key (EDK). The steps include:
Upon completion, the client's cache-empty flag is set to false, indicating that valid keys are available for encryption.
state | [in/out] Pointer to the HKDS client state structure. |
token | [in] Pointer to the secret token key array used in generating the key cache. |
HKDS_EXPORT_API void hkds_client_initialize_state | ( | hkds_client_state * | state, |
const uint8_t * | edk, | ||
const uint8_t * | did ) |
Initialize the HKDS client state.
This function initializes the client state by setting up the Embedded Device Key (EDK) and the device identity. The initialization process involves:
state | [in/out] Pointer to the HKDS client state structure. |
edk | [in] Pointer to the Embedded Device Key array. |
did | [in] Pointer to the device's unique identity string array. |