HKDS: Heirarchal Key Derivation System 1.0.0.2 (A2)
A fast post-quantum secure replacement for DUKPT
hkds_test.h File Reference

This file contains HKDS test definitions. More...

#include "common.h"

Go to the source code of this file.

Functions

bool hkdstest_cycle_test (void)
 Tests full cycles of the server to client interaction.
 
bool hkdstest_kat_test (void)
 Tests against known answer values for operational correctness.
 
bool hkdstest_katae_test (void)
 Tests the authenticated encryption against known answer values for operational correctness.
 
bool hkdstest_monte_carlo_test (void)
 Runs a looping known answer test.
 
bool hkdstest_stress_test (void)
 Tests the server and client modes in a loop for operational correctness.
 
bool hkdstest_simd_encrypt_equivalence_test (void)
 Tests the SIMD server encryption for operational correctness.
 
bool hkdstest_simd_authencrypt_equivalence_test (void)
 Tests the SIMD server authentication and encryption for operational correctness.
 
void hkdstest_test_run (void)
 Runs all HKDS tests.
 

Detailed Description

This file contains HKDS test definitions.

This header declares a set of test functions designed to verify the operational correctness of the HKDS library. The tests include full protocol cycles, known-answer tests (KAT), authenticated encryption tests, monte carlo tests, stress tests, and SIMD/parallel equivalence tests. Each test returns a boolean value indicating success or failure.

Function Documentation

◆ hkdstest_cycle_test()

bool hkdstest_cycle_test ( void )

Tests full cycles of the server to client interaction.

This test runs complete cycles of the HKDS protocol between the server and the client. It simulates the full exchange: the server encrypts a token, the client decrypts the token, derives a transaction key-set, encrypts a message, and finally the server decrypts the message. The test returns true if the decrypted message matches the original plaintext.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_kat_test()

bool hkdstest_kat_test ( void )

Tests against known answer values for operational correctness.

This test verifies the correctness of the HKDS implementation by comparing computed outputs (such as tokens, ciphertext, and decrypted messages) against predetermined known-answer test vectors.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_katae_test()

bool hkdstest_katae_test ( void )

Tests the authenticated encryption against known answer values for operational correctness.

This test validates the authenticated encryption functionality by comparing the computed ciphertext (including its MAC tag) and the result of decryption against known expected values.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_monte_carlo_test()

bool hkdstest_monte_carlo_test ( void )

Runs a looping known answer test.

This test repeatedly performs the encryption and decryption process (monte carlo testing) over many cycles to verify the robustness and consistency of the implementation.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_simd_authencrypt_equivalence_test()

bool hkdstest_simd_authencrypt_equivalence_test ( void )

Tests the SIMD server authentication and encryption for operational correctness.

This test verifies that the SIMD (parallel) implementation of the server authenticated encryption functions produces results equivalent to the sequential implementation.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_simd_encrypt_equivalence_test()

bool hkdstest_simd_encrypt_equivalence_test ( void )

Tests the SIMD server encryption for operational correctness.

This test verifies that the SIMD (parallel) implementation of the server encryption functions produces results equivalent to the sequential implementation.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_stress_test()

bool hkdstest_stress_test ( void )

Tests the server and client modes in a loop for operational correctness.

This stress test repeatedly executes full protocol cycles between the server and client to assess the overall stability and correctness under continuous load.

Returns
Returns true for test success, false otherwise.

◆ hkdstest_test_run()

void hkdstest_test_run ( void )

Runs all HKDS tests.

This function executes all the HKDS test functions, including cycle tests, known-answer tests, monte carlo tests, stress tests, and SIMD/parallel equivalence tests. Test results are printed, and the overall success or failure is determined based on the individual outcomes.