QSMP: Quantum Secure Messaging Protocol 1.3.0.0a (A3)
A quantum secure encrypted tunneling protocol
kex.h File Reference

QSMP Key Exchange Functions. More...

#include "common.h"
#include "../QSMP/qsmp.h"

Go to the source code of this file.

Data Structures

struct  qsmp_kex_duplex_client_state
 Internal state for the Duplex key exchange (client-side). More...
 
struct  qsmp_kex_duplex_server_state
 Internal state for the Duplex key exchange (server-side). More...
 
struct  qsmp_kex_simplex_client_state
 Internal state for the Simplex key exchange (client-side). More...
 
struct  qsmp_kex_simplex_server_state
 Internal state for the Simplex key exchange (server-side). More...
 

Typedefs

typedef struct qsmp_kex_duplex_client_state qsmp_kex_duplex_client_state
 
typedef struct qsmp_kex_duplex_server_state qsmp_kex_duplex_server_state
 
typedef struct qsmp_kex_simplex_client_state qsmp_kex_simplex_client_state
 
typedef struct qsmp_kex_simplex_server_state qsmp_kex_simplex_server_state
 

Functions

qsmp_errors qsmp_kex_duplex_server_key_exchange (qsmp_kex_duplex_server_state *kss, qsmp_connection_state *cns)
 Execute the server-side Duplex key exchange.
 
qsmp_errors qsmp_kex_duplex_client_key_exchange (qsmp_kex_duplex_client_state *kcs, qsmp_connection_state *cns)
 Execute the client-side Duplex key exchange.
 
qsmp_errors qsmp_kex_simplex_server_key_exchange (qsmp_kex_simplex_server_state *kss, qsmp_connection_state *cns)
 Execute the server-side Simplex key exchange.
 
qsmp_errors qsmp_kex_simplex_client_key_exchange (qsmp_kex_simplex_client_state *kcs, qsmp_connection_state *cns)
 Execute the client-side Simplex key exchange.
 
bool qsmp_kex_test ()
 Run internal tests for the key exchange functions.
 

Detailed Description

QSMP Key Exchange Functions.

This header file contains the internal key exchange functions for the Quantum Secure Messaging Protocol (QSMP). QSMP supports two key exchange variants:

  • Duplex: A bidirectional key exchange method that enables mutual authentication and secure session key establishment. Both parties exchange cryptographic material to derive a shared secret.
  • Simplex: A unidirectional key exchange method where typically the client verifies the server's identity.

The file defines internal state structures for both the client and server roles in Duplex and Simplex key exchanges. These structures encapsulate various cryptographic parameters such as key identities, session token hashes, asymmetric keys (for encryption, signing, and verification), shared secrets, and session expiration times.

The following internal (non-exportable) functions are declared:

  • qsmp_kex_duplex_server_key_exchange: Executes the server-side Duplex key exchange.
  • qsmp_kex_duplex_client_key_exchange: Executes the client-side Duplex key exchange.
  • qsmp_kex_simplex_server_key_exchange: Executes the server-side Simplex key exchange.
  • qsmp_kex_simplex_client_key_exchange: Executes the client-side Simplex key exchange.
  • qsmp_kex_test: Runs a suite of internal tests to validate the correctness of the key exchange operations.
Note
These functions and state structures are internal and are not part of the public QSMP API.

Function Documentation

◆ qsmp_kex_duplex_client_key_exchange()

qsmp_errors qsmp_kex_duplex_client_key_exchange ( qsmp_kex_duplex_client_state * kcs,
qsmp_connection_state * cns )

Execute the client-side Duplex key exchange.

This function initiates and completes the Duplex key exchange from the client side. It processes the server's response, computes the shared secret, and updates the QSMP connection state with the derived cryptographic parameters.

Parameters
kcsA pointer to the duplex client key exchange state structure.
cnsA pointer to the current QSMP connection state.
Returns
Returns a value of type qsmp_errors representing the result of the key exchange operation.
Note
This is an internal non-exportable API.

◆ qsmp_kex_duplex_server_key_exchange()

qsmp_errors qsmp_kex_duplex_server_key_exchange ( qsmp_kex_duplex_server_state * kss,
qsmp_connection_state * cns )

Execute the server-side Duplex key exchange.

This function processes an incoming Duplex key exchange request on the server side. It uses the server key exchange state (qsmp_kex_duplex_server_state) to verify client credentials, exchange the necessary asymmetric keys, and update the QSMP connection state accordingly.

Parameters
kssA pointer to the duplex server key exchange state structure.
cnsA pointer to the current QSMP connection state.
Returns
Returns a value of type qsmp_errors indicating the outcome of the key exchange process.
Note
This is an internal non-exportable API.

◆ qsmp_kex_simplex_client_key_exchange()

qsmp_errors qsmp_kex_simplex_client_key_exchange ( qsmp_kex_simplex_client_state * kcs,
qsmp_connection_state * cns )

Execute the client-side Simplex key exchange.

This function initiates and completes the Simplex key exchange from the client side. It exchanges the necessary cryptographic keys, verifies the server's identity using the remote verification key, and updates the QSMP connection state with the established session parameters.

Parameters
kcsA pointer to the simplex client key exchange state structure.
cnsA pointer to the current QSMP connection state.
Returns
Returns a value of type qsmp_errors representing the outcome of the key exchange process.
Note
This is an internal non-exportable API.

◆ qsmp_kex_simplex_server_key_exchange()

qsmp_errors qsmp_kex_simplex_server_key_exchange ( qsmp_kex_simplex_server_state * kss,
qsmp_connection_state * cns )

Execute the server-side Simplex key exchange.

This function handles the Simplex key exchange on the server side. It processes the client's connection request, validates the provided cryptographic material, and updates the QSMP connection state with the negotiated session parameters.

Parameters
kssA pointer to the simplex server key exchange state structure.
cnsA pointer to the current QSMP connection state.
Returns
Returns a value of type qsmp_errors indicating the success or failure of the key exchange.
Note
This is an internal non-exportable API.

◆ qsmp_kex_test()

bool qsmp_kex_test ( )

Run internal tests for the key exchange functions.

This function executes a suite of internal tests designed to validate the correct operation of the QSMP key exchange mechanisms. The tests include:

  • Verifying the proper initialization and management of state structures for both Duplex and Simplex modes.
  • Testing the cryptographic operations involved in key generation, shared secret derivation, and session token hashing.
  • Ensuring that the key exchange functions correctly update the QSMP connection state.

The function returns true if all internal tests pass, confirming the reliability and correctness of the key exchange implementation.

Returns
Returns true if the key exchange tests succeed; otherwise, false.
Note
This is an internal non-exportable API.