PQS: Post Quantum Shell 1.0.0.0a (A1)
A quantum safe shell application
|
PQS support header. More...
#include "common.h"
#include "../../QSC/QSC/dilithium.h"
#include "../../QSC/QSC/kyber.h"
#include "../../QSC/QSC/rcs.h"
#include "../../QSC/QSC/sha3.h"
#include "../../QSC/QSC/socketbase.h"
Go to the source code of this file.
Data Structures | |
struct | pqs_asymmetric_cipher_keypair |
Container for an asymmetric cipher key pair. More... | |
struct | pqs_asymmetric_signature_keypair |
Container for an asymmetric signature key pair. More... | |
struct | pqs_network_packet |
Represents a network packet in the PQS protocol. More... | |
struct | pqs_client_verification_key |
Structure holding a PQS client public key. More... | |
struct | pqs_server_signature_key |
Structure holding a PQS server secret signature key. More... | |
struct | pqs_keep_alive_state |
Maintains the state for a keep-alive mechanism. More... | |
struct | pqs_connection_state |
Maintains the state for a PQS socket connection. More... | |
Macros | |
#define | PQS_CONFIG_SIZE 48 |
The size in bytes of the protocol configuration string. | |
#define | PQS_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_KYBER_CIPHERTEXT_SIZE) |
The size in bytes of the asymmetric cipher-text array. | |
#define | PQS_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_KYBER_PRIVATEKEY_SIZE) |
The size in bytes of the asymmetric cipher private-key array. | |
#define | PQS_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_KYBER_PUBLICKEY_SIZE) |
The size in bytes of the asymmetric cipher public-key array. | |
#define | PQS_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE) |
The size in bytes of the asymmetric signature signing-key array. | |
#define | PQS_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE) |
The size in bytes of the asymmetric signature verification-key array. | |
#define | PQS_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE) |
The size in bytes of the asymmetric signature array. | |
#define | PQS_PUBKEY_ENCODING_SIZE 3456 |
The size in bytes of the encoded PQS public-key. | |
#define | PQS_PUBKEY_STRING_SIZE 3745 |
The size in bytes of the serialized PQS client-key structure. | |
#define | PQS_CLIENT_PORT 33118 |
The default port number for PQS client connections. | |
#define | PQS_CONNECTIONS_INIT 1000 |
The initial size of the PQS connection queue. | |
#define | PQS_CONNECTIONS_MAX 50000 |
The maximum number of concurrent PQS connections. | |
#define | PQS_CONNECTION_MTU 1500 |
The maximum transmission unit (MTU) size for a PQS packet. | |
#define | PQS_ERROR_SEQUENCE 0xFF00000000000000ULL |
The sequence number used to indicate an error in a packet. | |
#define | PQS_ERROR_MESSAGE_SIZE 1 |
The size in bytes of the error message contained in a packet. | |
#define | PQS_FLAG_SIZE 1 |
The size in bytes of the packet flag. | |
#define | PQS_HASH_SIZE 32 |
The output size in bytes of the Simplex 256-bit hash function. | |
#define | PQS_HEADER_SIZE 21 |
The size in bytes of a PQS packet header. | |
#define | PQS_KEEPALIVE_TIMEOUT (120 * 1000) |
The timeout period (in milliseconds) for keep-alive messages. | |
#define | PQS_KEYID_SIZE 16 |
The size in bytes of a PQS key identity. | |
#define | PQS_MACTAG_SIZE 32 |
The size in bytes of the MAC tag for the Simplex 256-bit MAC. | |
#define | PQS_MESSAGE_MAX 0x3D090000 |
The maximum allowed message size (in bytes) during the key exchange. | |
#define | PQS_MSGLEN_SIZE 4 |
The size in bytes of the packet message length field. | |
#define | PQS_NONCE_SIZE 32 |
The size in bytes of the nonce used in symmetric encryption. | |
#define | PQS_NETWORK_BUFFER_SIZE 1280 |
The size in bytes of the network buffer. | |
#define | PQS_PACKET_TIME_THRESHOLD 60 |
The maximum time (in seconds) a packet is considered valid. | |
#define | PQS_PUBKEY_DURATION_DAYS 365 |
The validity duration (in days) of a public key. | |
#define | PQS_PUBKEY_DURATION_SECONDS (PQS_PUBKEY_DURATION_DAYS * 24 * 60 * 60) |
The validity duration (in seconds) of a public key. | |
#define | PQS_PUBKEY_LINE_LENGTH 64 |
The maximum number of characters per line in a printed PQS public key. | |
#define | PQS_SCHASH_SIZE 32 |
The size in bytes of the Simplex 256-bit session token hash. | |
#define | PQS_SECRET_SIZE 32 |
The size in bytes of the shared secret for each communication channel. | |
#define | PQS_SEQUENCE_SIZE 8 |
The size in bytes of the packet sequence number. | |
#define | PQS_SEQUENCE_TERMINATOR 0xFFFFFFFFUL |
The sequence number that indicates a packet which closes a connection. | |
#define | PQS_SERVER_LISTEN_BACKLOG 0 |
The backlog size for the server listen socket. | |
#define | PQS_SERVER_PORT 3119 |
The default port number for PQS server connections. | |
#define | PQS_SYMMETRIC_KEY_SIZE 32 |
The size in bytes of the Simplex 256-bit symmetric cipher key. | |
#define | PQS_TIMESTAMP_SIZE 8 |
The size in bytes of the key expiration timestamp. | |
#define | PQS_SIGKEY_ENCODED_SIZE |
The size in bytes of the encoded secret signature key structure. | |
#define | pqs_cipher_generate_keypair qsc_kyber_generate_keypair |
Generate an asymmetric cipher key-pair. | |
#define | pqs_cipher_decapsulate qsc_kyber_decapsulate |
Decapsulate a shared-secret with the asymmetric cipher. | |
#define | pqs_cipher_encapsulate qsc_kyber_encapsulate |
Encapsulate a shared-secret with the asymmetric cipher. | |
#define | pqs_signature_generate_keypair qsc_dilithium_generate_keypair |
Generate an asymmetric signature key-pair. | |
#define | pqs_signature_sign qsc_dilithium_sign |
Sign a message with the asymmetric signature scheme. | |
#define | pqs_signature_verify qsc_dilithium_verify |
Verify a message with the asymmetric signature scheme. | |
Typedefs | |
typedef PQS_EXPORT_API enum pqs_client_commands | pqs_client_commands |
typedef PQS_EXPORT_API enum pqs_errors | pqs_errors |
typedef PQS_EXPORT_API enum pqs_flags | pqs_flags |
typedef PQS_EXPORT_API enum pqs_messages | pqs_messages |
typedef PQS_EXPORT_API struct pqs_asymmetric_cipher_keypair | pqs_asymmetric_cipher_keypair |
typedef PQS_EXPORT_API struct pqs_asymmetric_signature_keypair | pqs_asymmetric_signature_keypair |
typedef PQS_EXPORT_API struct pqs_network_packet | pqs_network_packet |
typedef PQS_EXPORT_API struct pqs_client_verification_key | pqs_client_verification_key |
typedef PQS_EXPORT_API struct pqs_server_signature_key | pqs_server_signature_key |
typedef PQS_EXPORT_API struct pqs_keep_alive_state | pqs_keep_alive_state |
typedef PQS_EXPORT_API struct pqs_connection_state | pqs_connection_state |
Functions | |
PQS_EXPORT_API void | pqs_connection_close (pqs_connection_state *cns, pqs_errors err, bool notify) |
Closes the network connection between hosts. | |
PQS_EXPORT_API void | pqs_connection_state_dispose (pqs_connection_state *cns) |
Resets and disposes of the connection state. | |
PQS_EXPORT_API const char * | pqs_error_description (pqs_messages emsg) |
Retrieves the description string for a given message enumeration. | |
PQS_EXPORT_API const char * | pqs_error_to_string (pqs_errors error) |
Converts an error code to its corresponding string description. | |
PQS_EXPORT_API void | pqs_generate_keypair (pqs_client_verification_key *pubkey, pqs_server_signature_key *prikey, const uint8_t keyid[PQS_KEYID_SIZE]) |
Generates a PQS key pair. | |
PQS_EXPORT_API void | pqs_log_error (pqs_messages emsg, qsc_socket_exceptions err, const char *msg) |
Logs an error message along with socket error details. | |
PQS_EXPORT_API void | pqs_log_message (pqs_messages emsg) |
Logs a message based on the provided message enumeration. | |
PQS_EXPORT_API void | pqs_log_write (pqs_messages emsg, const char *msg) |
Logs a message with an accompanying description. | |
PQS_EXPORT_API void | pqs_packet_clear (pqs_network_packet *packet) |
Clears the state of a network packet. | |
PQS_EXPORT_API pqs_errors | pqs_packet_decrypt (pqs_connection_state *cns, uint8_t *message, size_t *msglen, const pqs_network_packet *packetin) |
Decrypts an incoming packet's payload. | |
PQS_EXPORT_API pqs_errors | pqs_packet_encrypt (pqs_connection_state *cns, pqs_network_packet *packetout, const uint8_t *message, size_t msglen) |
Encrypts a message and constructs an output packet. | |
PQS_EXPORT_API void | pqs_packet_error_message (pqs_network_packet *packet, pqs_errors error) |
Populates a packet structure with an error message. | |
PQS_EXPORT_API void | pqs_packet_header_create (pqs_network_packet *packetout, pqs_flags flag, uint64_t sequence, uint32_t msglen) |
Creates and populates a packet header. | |
PQS_EXPORT_API void | pqs_packet_header_deserialize (const uint8_t *header, pqs_network_packet *packet) |
Deserializes a byte array into a packet header. | |
PQS_EXPORT_API void | pqs_packet_header_serialize (const pqs_network_packet *packet, uint8_t *header) |
Serializes a packet header into a byte array. | |
PQS_EXPORT_API pqs_errors | pqs_header_validate (pqs_connection_state *cns, const pqs_network_packet *packetin, pqs_flags kexflag, pqs_flags pktflag, uint64_t sequence, uint32_t msglen) |
Validates a packet header and its associated timestamp. | |
PQS_EXPORT_API void | pqs_packet_time_set (pqs_network_packet *packet) |
Sets the packet's UTC timestamp to the current time. | |
PQS_EXPORT_API bool | pqs_packet_time_validate (const pqs_network_packet *packet) |
Validates the timestamp of a packet against the local UTC time. | |
PQS_EXPORT_API size_t | pqs_packet_to_stream (const pqs_network_packet *packet, uint8_t *pstream) |
Serializes a full packet (header and payload) into a byte stream. | |
PQS_EXPORT_API bool | pqs_public_key_decode (pqs_client_verification_key *pubk, const char enck[PQS_PUBKEY_STRING_SIZE]) |
Decodes an encoded public key string into a client verification key structure. | |
PQS_EXPORT_API void | pqs_public_key_encode (char enck[PQS_PUBKEY_STRING_SIZE], const pqs_client_verification_key *pubkey) |
Encodes a client public key structure into a printable string. | |
PQS_EXPORT_API void | pqs_public_key_hash (uint8_t *hash, const pqs_client_verification_key *pubk) |
Computes a hash of a public key structure. | |
PQS_EXPORT_API void | pqs_signature_key_deserialize (pqs_server_signature_key *kset, const uint8_t serk[PQS_SIGKEY_ENCODED_SIZE]) |
Deserializes an encoded secret signature key into a server signature key structure. | |
PQS_EXPORT_API void | pqs_signature_key_serialize (uint8_t serk[PQS_SIGKEY_ENCODED_SIZE], const pqs_server_signature_key *kset) |
Serializes a server secret signature key structure into an encoded array. | |
PQS_EXPORT_API void | pqs_stream_to_packet (const uint8_t *pstream, pqs_network_packet *packet) |
Deserializes a byte stream into a network packet structure. | |
PQS support header.
This header defines the common parameters, macros, data structures, enumerations, and function prototypes used by both the PQS client and server implementations. PQS (Post Quantum Shell) implements a one-way trust, client-server key-exchange model designed for efficiency and 256-bit post-quantum security. The underlying cryptographic primitives are provided by the QSC library, using combinations of the Dilithium (for signatures) and Kyber (for key encapsulation) schemes.
The protocol configuration is determined at compile-time by preprocessor definitions (such as QSC_DILITHIUM_S1P2544, QSC_KYBER_S1P1632, etc.) defined in the QSC library's common.h file. Although library defaults are used by default, the parameter sets may be changed to suit different security or performance requirements.
The file also defines the structures for network packets, connection state, and key containers, along with function prototypes for operations such as connection management, encryption/decryption, logging, public key encoding/decoding, and key generation.
#define PQS_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_KYBER_CIPHERTEXT_SIZE) |
The size in bytes of the asymmetric cipher-text array.
This macro is defined as the value of QSC_KYBER_CIPHERTEXT_SIZE, representing the output size for the Kyber key encapsulation mechanism.
#define PQS_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_KYBER_PRIVATEKEY_SIZE) |
The size in bytes of the asymmetric cipher private-key array.
This is defined in terms of QSC_KYBER_PRIVATEKEY_SIZE.
#define PQS_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_KYBER_PUBLICKEY_SIZE) |
The size in bytes of the asymmetric cipher public-key array.
This value is taken from QSC_KYBER_PUBLICKEY_SIZE.
#define PQS_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE) |
The size in bytes of the asymmetric signature array.
This value is defined as QSC_DILITHIUM_SIGNATURE_SIZE.
#define PQS_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE) |
The size in bytes of the asymmetric signature signing-key array.
This value corresponds to QSC_DILITHIUM_PRIVATEKEY_SIZE.
#define PQS_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE) |
The size in bytes of the asymmetric signature verification-key array.
This value corresponds to QSC_DILITHIUM_PUBLICKEY_SIZE.
#define PQS_CONFIG_SIZE 48 |
The size in bytes of the protocol configuration string.
This constant defines the fixed length (48 bytes) of the configuration string that specifies the selected cryptographic primitive parameter set.
#define PQS_CONNECTIONS_INIT 1000 |
The initial size of the PQS connection queue.
This value is used when initializing the connection state.
#define PQS_CONNECTIONS_MAX 50000 |
The maximum number of concurrent PQS connections.
This is calculated based on an approximate memory footprint per connection. For example, with a 256GB DRAM system, the maximum may be set to 50,000 connections.
#define PQS_KEEPALIVE_TIMEOUT (120 * 1000) |
The timeout period (in milliseconds) for keep-alive messages.
The default value is 2 minutes.
#define PQS_MESSAGE_MAX 0x3D090000 |
The maximum allowed message size (in bytes) during the key exchange.
This value is approximately 1 GB.
#define PQS_PACKET_TIME_THRESHOLD 60 |
The maximum time (in seconds) a packet is considered valid.
This threshold can be tuned based on network conditions. For interior networks with synchronized clocks, it might be as low as 1 second; for exterior networks, it may be higher.
#define PQS_PUBKEY_DURATION_SECONDS (PQS_PUBKEY_DURATION_DAYS * 24 * 60 * 60) |
The validity duration (in seconds) of a public key.
Calculated from PQS_PUBKEY_DURATION_DAYS.
#define PQS_PUBKEY_ENCODING_SIZE 3456 |
The size in bytes of the encoded PQS public-key.
The encoding size varies depending on the selected Dilithium parameter set.
#define PQS_PUBKEY_STRING_SIZE 3745 |
The size in bytes of the serialized PQS client-key structure.
This defines the length of the string produced when encoding a public key.
#define PQS_SERVER_LISTEN_BACKLOG 0 |
The backlog size for the server listen socket.
Set to zero since concurrent connections are disallowed at the listen level.
#define PQS_SIGKEY_ENCODED_SIZE |
The size in bytes of the encoded secret signature key structure.
The encoded key consists of the key identity, timestamp, configuration string, public key hash, signature key, and verification key.
enum pqs_client_commands |
Enumeration of client commands in the PQS protocol.
DOXYGEN_IGNORE
/*-------------------------------------------------------------------------—
DOXYGEN_IGNORE DOXYGEN_IGNORE
These commands are used by the client to indicate the desired operation.
enum pqs_errors |
Enumeration of error codes returned by PQS functions.
These error values indicate various failure conditions encountered during connection establishment, encryption/decryption, key exchange, and other operations.
enum pqs_flags |
Enumeration of packet flags used in the PQS protocol.
The flags indicate the type or purpose of a packet (e.g., connection requests, key exchange phases, keep alive messages, error conditions, etc.).
enum pqs_messages |
Enumeration of logging and status messages used by PQS.
These messages correspond to various events and errors occurring within the protocol, and are used for diagnostic logging.
PQS_EXPORT_API void pqs_connection_close | ( | pqs_connection_state * | cns, |
pqs_errors | err, | ||
bool | notify ) |
Closes the network connection between hosts.
If the connection is active, this function optionally sends a disconnect notification. In the case of a normal disconnect (no error), a simple disconnect packet is transmitted. If an error has occurred, an error packet is encrypted and sent before closing the connection.
cns | A pointer to the connection state structure. |
err | The error code to be reported (if any). |
notify | Set to true to notify the remote host of the connection closure. |
PQS_EXPORT_API void pqs_connection_state_dispose | ( | pqs_connection_state * | cns | ) |
Resets and disposes of the connection state.
This function disposes of the internal cipher states and clears the socket and sequence information in the connection state structure.
cns | A pointer to the connection state structure to dispose. |
PQS_EXPORT_API const char * pqs_error_description | ( | pqs_messages | emsg | ) |
Retrieves the description string for a given message enumeration.
emsg | The message enumeration value. |
PQS_EXPORT_API const char * pqs_error_to_string | ( | pqs_errors | error | ) |
Converts an error code to its corresponding string description.
error | The error code. |
PQS_EXPORT_API void pqs_generate_keypair | ( | pqs_client_verification_key * | pubkey, |
pqs_server_signature_key * | prikey, | ||
const uint8_t | keyid[PQS_KEYID_SIZE] ) |
Generates a PQS key pair.
This function creates a new asymmetric signature key pair for the server. The expiration time is set to the current UTC time plus the public key duration. The configuration string and key identity are copied to the server key structure, and the generated verification key is also copied to the client public key structure.
pubkey | A pointer to the client public key structure (output). |
prikey | A pointer to the server secret key structure (output). |
keyid | A pointer to a key identity string (input). |
PQS_EXPORT_API pqs_errors pqs_header_validate | ( | pqs_connection_state * | cns, |
const pqs_network_packet * | packetin, | ||
pqs_flags | kexflag, | ||
pqs_flags | pktflag, | ||
uint64_t | sequence, | ||
uint32_t | msglen ) |
Validates a packet header and its associated timestamp.
Checks that the packet's message length, sequence number, flag, and timestamp are as expected. If the packet carries an error flag, the error code is extracted from the payload.
cns | A pointer to the connection state structure. |
packetin | A pointer to the input packet structure. |
kexflag | The expected key exchange stage flag. |
pktflag | The expected packet flag. |
sequence | The expected packet sequence number. |
msglen | The expected length of the message payload. |
PQS_EXPORT_API void pqs_log_error | ( | pqs_messages | emsg, |
qsc_socket_exceptions | err, | ||
const char * | msg ) |
Logs an error message along with socket error details.
This function writes an error message based on the provided message enumeration and appends additional error information from the socket exception if present.
emsg | The message enumeration indicating the error type. |
err | The socket exception value. |
msg | A constant string providing additional context (input). |
PQS_EXPORT_API void pqs_log_message | ( | pqs_messages | emsg | ) |
Logs a message based on the provided message enumeration.
emsg | The message enumeration to be logged. |
PQS_EXPORT_API void pqs_log_write | ( | pqs_messages | emsg, |
const char * | msg ) |
Logs a message with an accompanying description.
emsg | The message enumeration. |
msg | A constant string containing additional information. |
PQS_EXPORT_API void pqs_packet_clear | ( | pqs_network_packet * | packet | ) |
Clears the state of a network packet.
Resets the packet flag, message length, and sequence number to default values. If the packet contains a message payload, it is cleared.
packet | A pointer to the packet structure to clear. |
PQS_EXPORT_API pqs_errors pqs_packet_decrypt | ( | pqs_connection_state * | cns, |
uint8_t * | message, | ||
size_t * | msglen, | ||
const pqs_network_packet * | packetin ) |
Decrypts an incoming packet's payload.
This function verifies the packet sequence number and timestamp before attempting to decrypt the payload using the associated receive cipher state. The decrypted message is copied to the output buffer.
cns | A pointer to the connection state structure. |
message | An output buffer for the decrypted message. |
msglen | A pointer to a size variable to receive the length of the decrypted message. |
packetin | A constant pointer to the input packet structure. |
PQS_EXPORT_API pqs_errors pqs_packet_encrypt | ( | pqs_connection_state * | cns, |
pqs_network_packet * | packetout, | ||
const uint8_t * | message, | ||
size_t | msglen ) |
Encrypts a message and constructs an output packet.
This function increments the transmit sequence number, creates a packet header, and sets the associated data for the transmit cipher state before encrypting the provided message payload.
cns | A pointer to the connection state structure. |
packetout | A pointer to the output packet structure to be populated. |
message | A constant pointer to the input message to encrypt. |
msglen | The length in bytes of the input message. |
PQS_EXPORT_API void pqs_packet_error_message | ( | pqs_network_packet * | packet, |
pqs_errors | error ) |
Populates a packet structure with an error message.
Sets the packet flag to indicate an error, assigns a predefined sequence number, and writes the error code into the message payload.
packet | A pointer to the packet structure (output). |
error | The error code to embed in the packet. |
PQS_EXPORT_API void pqs_packet_header_create | ( | pqs_network_packet * | packetout, |
pqs_flags | flag, | ||
uint64_t | sequence, | ||
uint32_t | msglen ) |
Creates and populates a packet header.
This function sets the flag, sequence number, and message length in the packet header, and assigns the current UTC time as the creation timestamp.
packetout | A pointer to the output packet structure. |
flag | The packet flag indicating the packet type. |
sequence | The packet sequence number. |
msglen | The length in bytes of the message payload. |
PQS_EXPORT_API void pqs_packet_header_deserialize | ( | const uint8_t * | header, |
pqs_network_packet * | packet ) |
Deserializes a byte array into a packet header.
header | A constant pointer to the byte array representing the packet header. |
packet | A pointer to the packet structure to populate. |
PQS_EXPORT_API void pqs_packet_header_serialize | ( | const pqs_network_packet * | packet, |
uint8_t * | header ) |
Serializes a packet header into a byte array.
packet | A constant pointer to the packet structure to serialize. |
header | A pointer to the byte array that will receive the serialized header. |
PQS_EXPORT_API void pqs_packet_time_set | ( | pqs_network_packet * | packet | ) |
Sets the packet's UTC timestamp to the current time.
packet | A pointer to the network packet whose timestamp is to be set. |
PQS_EXPORT_API bool pqs_packet_time_validate | ( | const pqs_network_packet * | packet | ) |
Validates the timestamp of a packet against the local UTC time.
Ensures that the packet's timestamp is within the acceptable time threshold (PQS_PACKET_TIME_THRESHOLD) relative to the current UTC time.
packet | A constant pointer to the network packet. |
PQS_EXPORT_API size_t pqs_packet_to_stream | ( | const pqs_network_packet * | packet, |
uint8_t * | pstream ) |
Serializes a full packet (header and payload) into a byte stream.
packet | A constant pointer to the packet structure to serialize. |
pstream | A pointer to the output byte array. |
PQS_EXPORT_API bool pqs_public_key_decode | ( | pqs_client_verification_key * | pubk, |
const char | enck[PQS_PUBKEY_STRING_SIZE] ) |
Decodes an encoded public key string into a client verification key structure.
This function parses the encoded string (which includes header, configuration, key identity, expiration timestamp, and base64-encoded verification key) and populates the client key structure.
pubk | A pointer to the output client verification key structure. |
enck | A constant encoded public key string. |
PQS_EXPORT_API void pqs_public_key_encode | ( | char | enck[PQS_PUBKEY_STRING_SIZE], |
const pqs_client_verification_key * | pubkey ) |
Encodes a client public key structure into a printable string.
The encoded string includes the header, version, configuration, key identity, expiration timestamp, and a base64-encoded verification key, formatted with line breaks.
enck | A pointer to the output encoded public key string. |
pubkey | A constant pointer to the client verification key structure. |
PQS_EXPORT_API void pqs_public_key_hash | ( | uint8_t * | hash, |
const pqs_client_verification_key * | pubk ) |
Computes a hash of a public key structure.
Uses the SHA3/Keccak hash function to compute a 256-bit hash over the public key's configuration, expiration, key identity, and verification key.
hash | An output array to receive the hash (must be at least PQS_HASH_SIZE bytes). |
pubk | A constant pointer to the client verification key structure. |
PQS_EXPORT_API void pqs_signature_key_deserialize | ( | pqs_server_signature_key * | kset, |
const uint8_t | serk[PQS_SIGKEY_ENCODED_SIZE] ) |
Deserializes an encoded secret signature key into a server signature key structure.
kset | A pointer to the output server signature key structure. |
serk | A constant array containing the encoded secret key. |
PQS_EXPORT_API void pqs_signature_key_serialize | ( | uint8_t | serk[PQS_SIGKEY_ENCODED_SIZE], |
const pqs_server_signature_key * | kset ) |
Serializes a server secret signature key structure into an encoded array.
serk | A pointer to the output encoded key array. |
kset | A constant pointer to the server signature key structure. |
PQS_EXPORT_API void pqs_stream_to_packet | ( | const uint8_t * | pstream, |
pqs_network_packet * | packet ) |
Deserializes a byte stream into a network packet structure.
pstream | A constant pointer to the input byte stream. |
packet | A pointer to the packet structure to populate. |