43#include "../../QSC/QSC/rcs.h"
44#include "../../QSC/QSC/sha3.h"
91#define QSMP_CONFIG_DILITHIUM_KYBER
106#include "../../QSC/QSC/socketbase.h"
108#if defined(QSMP_CONFIG_DILITHIUM_KYBER)
109# include "../../QSC/QSC/dilithium.h"
110# include "../../QSC/QSC/kyber.h"
111#elif defined(QSMP_CONFIG_DILITHIUM_MCELIECE)
112# include "../../QSC/QSC/dilithium.h"
113# include "../../QSC/QSC/mceliece.h"
114#elif defined(QSMP_CONFIG_SPHINCS_MCELIECE)
115# include "../../QSC/QSC/sphincsplus.h"
116# include "../../QSC/QSC/mceliece.h"
118# error Invalid parameter set!
131#define QSMP_CONFIG_SIZE 48
137#define QSMP_SIMPLEX_HASH_SIZE 32
143#define QSMP_SIMPLEX_MACKEY_SIZE 32
149#define QSMP_SIMPLEX_MACTAG_SIZE 32
155#define QSMP_SIMPLEX_SYMMETRIC_KEY_SIZE 32
161#define QSMP_SIMPLEX_SCHASH_SIZE 32
167#define QSMP_DUPLEX_HASH_SIZE 64
173#define QSMP_DUPLEX_MACKEY_SIZE 64
179#define QSMP_DUPLEX_MACTAG_SIZE 64
185#define QSMP_DUPLEX_SYMMETRIC_KEY_SIZE 64
191#define QSMP_DUPLEX_SCHASH_SIZE 64
197#define QSMP_ASYMMETRIC_KEYCHAIN_COUNT 10
203#define QSMP_CLIENT_PORT 31118
209#define QSMP_CONNECTIONS_INIT 1000
218#define QSMP_CONNECTIONS_MAX 50000
224#define QSMP_CONNECTION_MTU 1500
230#define QSMP_ERROR_SEQUENCE 0xFF00000000000000ULL
236#define QSMP_ERROR_MESSAGE_SIZE 1
242#define QSMP_FLAG_SIZE 1
248#define QSMP_HEADER_SIZE 21
254#define QSMP_KEEPALIVE_STRING 20
260#define QSMP_KEEPALIVE_TIMEOUT (120 * 1000)
266#define QSMP_KEYID_SIZE 16
272#define QSMP_MSGLEN_SIZE 4
278#define QSMP_NETWORK_MTU_SIZE 1500
284#define QSMP_NONCE_SIZE 32
290#define QSMP_RTOK_SIZE 32
296#define QSMP_SERVER_PORT 31119
305#define QSMP_PACKET_TIME_THRESHOLD 60
311#define QSMP_POLLING_INTERVAL (120 * 1000)
317#define QSMP_PUBKEY_DURATION_DAYS 365
323#define QSMP_PUBKEY_DURATION_SECONDS (QSMP_PUBKEY_DURATION_DAYS * 24 * 60 * 60)
329#define QSMP_PUBKEY_LINE_LENGTH 64
335#define QSMP_SECRET_SIZE 32
341#define QSMP_SEQUENCE_SIZE 8
347#define QSMP_SEQUENCE_TERMINATOR 0xFFFFFFFFUL
353#define QSMP_SRVID_SIZE 8
359#define QSMP_STOKEN_SIZE 64
365#define QSMP_TIMESTAMP_SIZE 8
371#define QSMP_TIMESTAMP_STRING_SIZE 20
377#define QSMP_MESSAGE_MAX 0x3D090000
379#if defined(QSMP_CONFIG_DILITHIUM_KYBER)
385# define qsmp_cipher_generate_keypair qsc_kyber_generate_keypair
390# define qsmp_cipher_decapsulate qsc_kyber_decapsulate
395# define qsmp_cipher_encapsulate qsc_kyber_encapsulate
400# define qsmp_signature_generate_keypair qsc_dilithium_generate_keypair
405# define qsmp_signature_sign qsc_dilithium_sign
410# define qsmp_signature_verify qsc_dilithium_verify
413# if defined(QSC_DILITHIUM_S1P2544) && defined(QSC_KYBER_S1P1632)
414static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s1_kyber-s1_sha3_rcs";
415# elif defined(QSC_DILITHIUM_S3P4016) && defined(QSC_KYBER_S3P2400)
416static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s3_kyber-s3_sha3_rcs";
417# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_KYBER_S5P3168)
418static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s5_kyber-s5_sha3_rcs";
419# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_KYBER_S6P3936)
420static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s5_kyber-s6_sha3_rcs";
422# error Invalid parameter set!
430# define QSMP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_KYBER_CIPHERTEXT_SIZE)
436# define QSMP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_KYBER_PRIVATEKEY_SIZE)
442# define QSMP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_KYBER_PUBLICKEY_SIZE)
448# define QSMP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
454# define QSMP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
460# define QSMP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
462#elif defined(QSMP_CONFIG_DILITHIUM_MCELIECE)
467# define qsmp_cipher_generate_keypair qsc_mceliece_generate_keypair
472# define qsmp_cipher_decapsulate qsc_mceliece_decapsulate
477# define qsmp_cipher_encapsulate qsc_mceliece_encapsulate
482# define qsmp_signature_generate_keypair qsc_dilithium_generate_keypair
487# define qsmp_signature_sign qsc_dilithium_sign
492# define qsmp_signature_verify qsc_dilithium_verify
495# if defined(QSC_DILITHIUM_S1P2544) && defined(QSC_MCELIECE_S1N3488T64)
496static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s1_mceliece-s1_sha3_rcs";
497# elif defined(QSC_DILITHIUM_S3P4016) && defined(QSC_MCELIECE_S3N4608T96)
498static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s3_mceliece-s3_sha3_rcs";
499# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S5N6688T128)
500static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s5_sha3_rcs";
501# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S6N6960T119)
502static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s6_sha3_rcs";
503# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S7N8192T128)
504static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s7_sha3_rcs";
506# error Invalid parameter set!
514# define QSMP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
520# define QSMP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
526# define QSMP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
532# define QSMP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
538# define QSMP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
544# define QSMP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
546#elif defined(QSMP_CONFIG_SPHINCS_MCELIECE)
552# define qsmp_cipher_generate_keypair qsc_mceliece_generate_keypair
557# define qsmp_cipher_decapsulate qsc_mceliece_decapsulate
562# define qsmp_cipher_encapsulate qsc_mceliece_encapsulate
567# define qsmp_signature_generate_keypair qsc_sphincsplus_generate_keypair
572# define qsmp_signature_sign qsc_sphincsplus_sign
577# define qsmp_signature_verify qsc_sphincsplus_verify
580# if defined(QSC_SPHINCSPLUS_S1S128SHAKERF) && defined(QSC_MCELIECE_S1N3488T64)
581static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s1f_mceliece-s1_sha3_rcs";
582# elif defined(QSC_SPHINCSPLUS_S1S128SHAKERS) && defined(QSC_MCELIECE_S1N3488T64)
583static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s1s_mceliece-s1_sha3_rcs";
584# elif defined(QSC_SPHINCSPLUS_S3S192SHAKERF) && defined(QSC_MCELIECE_S3N4608T96)
585static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-3f_mceliece-s3_sha3_rcs";
586# elif defined(QSC_SPHINCSPLUS_S3S192SHAKERS) && defined(QSC_MCELIECE_S3N4608T96)
587static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-3s_mceliece-s3_sha3_rcs";
588# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S5N6688T128)
589static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s5_sha3_rcs";
590# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S5N6688T128)
591static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s5_sha3_rcs";
592# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S6N6960T119)
593static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s6_sha3_rcs";
594# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S6N6960T119)
595static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s6_sha3_rcs";
596# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S7N8192T128)
597static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s7_sha3_rcs";
598# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S7N8192T128)
599static const char QSMP_CONFIG_STRING[
QSMP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s7_sha3_rcs";
601# error Invalid parameter set!
609# define QSMP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
615# define QSMP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
621# define QSMP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
627# define QSMP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_SPHINCSPLUS_PRIVATEKEY_SIZE)
633# define QSMP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_SPHINCSPLUS_PUBLICKEY_SIZE)
639# define QSMP_ASYMMETRIC_SIGNATURE_SIZE (QSC_SPHINCSPLUS_SIGNATURE_SIZE)
642# error invalid parameter set!
651#define QSMP_SIGKEY_ENCODED_SIZE (QSMP_KEYID_SIZE + QSMP_TIMESTAMP_SIZE + QSMP_CONFIG_SIZE + QSMP_ASYMMETRIC_SIGNING_KEY_SIZE + QSMP_ASYMMETRIC_VERIFY_KEY_SIZE)
657#define QSMP_PUBKEY_HEADER_SIZE 40
662#define QSMP_PUBKEY_VERSION_SIZE 19
667#define QSMP_PUBKEY_CONFIG_SIZE 16
672#define QSMP_PUBKEY_KEYID_SIZE 10
677#define QSMP_PUBKEY_EXPIRATION_SIZE 13
682#define QSMP_PUBKEY_FOOTER_SIZE 38
726#define QSMP_ERROR_STRING_DEPTH 29
731#define QSMP_ERROR_STRING_WIDTH 128
736 "No error was detected",
737 "The socket accept function returned an error",
738 "The symmetric cipher had an authentication failure",
739 "The keep alive check failed",
740 "The communications channel has failed",
741 "The device could not make a connection to the remote host",
742 "The transmission failed at the KEX connection phase",
743 "The asymmetric cipher failed to decapsulate the shared secret",
744 "The decryption authentication has failed",
745 "The transmission failed at the KEX establish phase",
746 "The transmission failed at the KEX exchange phase",
747 "The public - key hash is invalid",
748 "The server has run out of socket connections",
749 "The expected input was invalid",
750 "The packet flag was unexpected",
751 "The keep alive has expired with no response",
752 "The decryption authentication has failed",
753 "The QSMP public key has expired ",
754 "The key identity is unrecognized",
755 "The ratchet operation has failed",
756 "The listener function failed to initialize",
757 "The server has run out of memory",
758 "The packet has valid time expired",
759 "The packet was received out of sequence",
760 "The random generator has failed",
761 "The receiver failed at the network layer",
762 "The transmitter failed at the network layer",
763 "The protocol string was not recognized",
764 "The expected data could not be verified",
772#define QSMP_MESSAGE_STRING_DEPTH 22
777#define QSMP_MESSAGE_STRING_WIDTH 128
782 "The operation completed succesfully.",
783 "The socket server accept function failed.",
784 "The listener socket listener could not connect.",
785 "The listener socket could not bind to the address.",
786 "The listener socket could not be created.",
787 "The server is connected to remote host: ",
788 "The socket receive function failed.",
789 "The server had a memory allocation failure.",
790 "The key exchange has experienced a failure.",
791 "The server has disconnected from the remote host: ",
792 "The server has disconnected the client due to an error",
793 "The server has had a socket level error: ",
794 "The server has reached the maximum number of connections",
795 "The server listener socket has failed.",
796 "The server has run out of socket connections",
797 "The message decryption has failed",
798 "The keepalive function has failed",
799 "The keepalive period has been exceeded",
800 "The connection failed or was interrupted",
801 "The function received an invalid request",
923 qsmp_mode_simplex = 0x00,
924 qsmp_mode_duplex = 0x01,
QSMP_EXPORT_API void qsmp_packet_header_deserialize(const uint8_t *header, qsmp_network_packet *packet)
Deserialize a byte array to a packet header.
Definition qsmp.c:513
QSMP_EXPORT_API void qsmp_generate_keypair(qsmp_client_verification_key *pubkey, qsmp_server_signature_key *prikey, const uint8_t keyid[QSMP_KEYID_SIZE])
Generate a QSMP key-pair; generates the public and private asymmetric signature keys.
Definition qsmp.c:277
QSMP_EXPORT_API qsmp_errors qsmp_packet_encrypt(qsmp_connection_state *cns, qsmp_network_packet *packetout, const uint8_t *message, size_t msglen)
Encrypt a message and build an output packet.
Definition qsmp.c:461
QSMP_EXPORT_API qsmp_errors qsmp_packet_decrypt(qsmp_connection_state *cns, uint8_t *message, size_t *msglen, const qsmp_network_packet *packetin)
Decrypt a message and copy it to the message output.
Definition qsmp.c:400
QSMP_EXPORT_API size_t qsmp_packet_to_stream(const qsmp_network_packet *packet, uint8_t *pstream)
Serialize a packet to a byte array.
Definition qsmp.c:798
QSMP_EXPORT_API void qsmp_asymmetric_signature_keypair_dispose(qsmp_asymmetric_signature_keypair *keypair)
Dispose of an asymmetric signature keypair.
Definition qsmp.c:58
QSMP_EXPORT_API void qsmp_stream_to_packet(const uint8_t *pstream, qsmp_network_packet *packet)
Deserialize a byte array to a packet.
Definition qsmp.c:777
#define QSMP_ASYMMETRIC_VERIFY_KEY_SIZE
The byte size of the asymmetric signature verification-key array.
Definition qsmp.h:454
#define QSMP_ERROR_STRING_WIDTH
The width of each QSMP error string.
Definition qsmp.h:731
QSMP_EXPORT_API void qsmp_signature_key_deserialize(qsmp_server_signature_key *kset, const uint8_t serk[QSMP_SIGKEY_ENCODED_SIZE])
Decode a secret signature key structure and copy to an array.
Definition qsmp.c:743
QSMP_EXPORT_API void qsmp_asymmetric_cipher_keypair_dispose(qsmp_asymmetric_cipher_keypair *keypair)
Dispose of an asymmetric cipher keypair.
Definition qsmp.c:11
#define QSMP_MESSAGE_STRING_WIDTH
The width of each QSMP message string.
Definition qsmp.h:777
#define QSMP_PUBKEY_CONFIG_SIZE
The size of the QSMP public key configuration prefix.
Definition qsmp.h:667
QSMP_EXPORT_API void qsmp_packet_header_serialize(const qsmp_network_packet *packet, uint8_t *header)
Serialize a packet header to a byte array.
Definition qsmp.c:532
QSMP_EXPORT_API void qsmp_log_write(qsmp_messages emsg, const char *msg)
Log a message and description.
Definition qsmp.c:364
qsmp_errors
The QSMP error values.
Definition qsmp.h:854
@ qsmp_error_receive_failure
Definition qsmp.h:880
@ qsmp_error_keychain_fail
Definition qsmp.h:874
@ qsmp_error_random_failure
Definition qsmp.h:879
@ qsmp_error_connect_failure
Definition qsmp.h:861
@ qsmp_error_authentication_failure
Definition qsmp.h:857
@ qsmp_error_none
Definition qsmp.h:855
@ qsmp_error_transmit_failure
Definition qsmp.h:881
@ qsmp_error_hash_invalid
Definition qsmp.h:866
@ qsmp_error_key_expired
Definition qsmp.h:872
@ qsmp_error_channel_down
Definition qsmp.h:859
@ qsmp_error_bad_keep_alive
Definition qsmp.h:858
@ qsmp_error_connection_failure
Definition qsmp.h:860
@ qsmp_error_decryption_failure
Definition qsmp.h:863
@ qsmp_error_memory_allocation
Definition qsmp.h:876
@ qsmp_error_keepalive_timeout
Definition qsmp.h:871
@ qsmp_error_keepalive_expired
Definition qsmp.h:870
@ qsmp_error_listener_fail
Definition qsmp.h:875
@ qsmp_error_establish_failure
Definition qsmp.h:864
@ qsmp_error_accept_fail
Definition qsmp.h:856
@ qsmp_error_key_unrecognized
Definition qsmp.h:873
@ qsmp_error_exchange_failure
Definition qsmp.h:865
@ qsmp_error_decapsulation_failure
Definition qsmp.h:862
@ qsmp_error_verify_failure
Definition qsmp.h:883
@ qsmp_error_message_time_invalid
Definition qsmp.h:877
@ qsmp_error_invalid_input
Definition qsmp.h:868
@ qsmp_error_packet_unsequenced
Definition qsmp.h:878
@ qsmp_error_invalid_request
Definition qsmp.h:869
@ qsmp_error_hosts_exceeded
Definition qsmp.h:867
@ qsmp_error_unknown_protocol
Definition qsmp.h:882
QSMP_EXPORT_API qsmp_asymmetric_cipher_keypair * qsmp_asymmetric_cipher_keypair_initialize()
Initialize an asymmetric cipher keypair.
Definition qsmp.c:32
qsmp_mode
The QSMP mode enumeration.
Definition qsmp.h:922
qsmp_configuration
The asymmetric cryptographic primitive configuration.
Definition qsmp.h:810
@ qsmp_configuration_dilithium_kyber
Definition qsmp.h:813
@ qsmp_configuration_dilithium_mceliece
Definition qsmp.h:814
@ qsmp_configuration_dilithium_ntru
Definition qsmp.h:815
@ qsmp_configuration_none
Definition qsmp.h:811
@ qsmp_configuration_falcon_kyber
Definition qsmp.h:816
@ qsmp_configuration_sphincs_mceliece
Definition qsmp.h:812
@ qsmp_configuration_falcon_mceliece
Definition qsmp.h:817
@ qsmp_configuration_falcon_ntru
Definition qsmp.h:818
#define QSMP_PUBKEY_FOOTER_SIZE
The size of the QSMP public key footer.
Definition qsmp.h:682
#define QSMP_DUPLEX_SYMMETRIC_KEY_SIZE
TheDuplex 512-bit symmetric cipher key size.
Definition qsmp.h:185
QSMP_EXPORT_API bool qsmp_certificate_encoding_test()
Test the certificate encoding and decoding functions.
Definition qsmp.c:825
QSMP_EXPORT_API bool qsmp_packet_time_valid(const qsmp_network_packet *packet)
Checks the local UTC seconds time against the packet sent time for validity within the packet time th...
Definition qsmp.c:556
QSMP_EXPORT_API void qsmp_packet_set_utc_time(qsmp_network_packet *packet)
Sets the local UTC seconds time in the packet header.
Definition qsmp.c:551
qsmp_flags
The QSMP packet flags.
Definition qsmp.h:891
@ qsmp_flag_connection_terminate
Definition qsmp.h:895
@ qsmp_flag_asymmetric_ratchet_response
Definition qsmp.h:911
@ qsmp_flag_session_establish_verify
Definition qsmp.h:908
@ qsmp_flag_establish_response
Definition qsmp.h:902
@ qsmp_flag_exstart_response
Definition qsmp.h:898
@ qsmp_flag_encrypted_message
Definition qsmp.h:896
@ qsmp_flag_keep_alive_response
Definition qsmp.h:904
@ qsmp_flag_remote_terminated
Definition qsmp.h:906
@ qsmp_flag_unrecognized_protocol
Definition qsmp.h:909
@ qsmp_flag_transfer_request
Definition qsmp.h:913
@ qsmp_flag_symmetric_ratchet_request
Definition qsmp.h:912
@ qsmp_flag_exchange_request
Definition qsmp.h:899
@ qsmp_flag_exstart_request
Definition qsmp.h:897
@ qsmp_flag_connect_request
Definition qsmp.h:893
@ qsmp_flag_asymmetric_ratchet_request
Definition qsmp.h:910
@ qsmp_flag_remote_connected
Definition qsmp.h:905
@ qsmp_flag_session_established
Definition qsmp.h:907
@ qsmp_flag_none
Definition qsmp.h:892
@ qsmp_flag_keep_alive_request
Definition qsmp.h:903
@ qsmp_flag_error_condition
Definition qsmp.h:914
@ qsmp_flag_connect_response
Definition qsmp.h:894
@ qsmp_flag_exchange_response
Definition qsmp.h:900
@ qsmp_flag_establish_request
Definition qsmp.h:901
QSMP_EXPORT_API const char * qsmp_get_error_description(qsmp_messages emsg)
Get the error string description.
Definition qsmp.c:302
#define QSMP_ASYMMETRIC_SIGNING_KEY_SIZE
The byte size of the asymmetric signature signing-key array.
Definition qsmp.h:448
#define QSMP_PUBKEY_EXPIRATION_SIZE
The size of the QSMP public key expiration prefix.
Definition qsmp.h:677
QSMP_EXPORT_API bool qsmp_public_key_compare(const qsmp_client_verification_key *a, const qsmp_client_verification_key *b)
Compares two public keys for equality.
Definition qsmp.c:565
#define QSMP_PUBKEY_KEYID_SIZE
The size of the QSMP public key identifier prefix.
Definition qsmp.h:672
qsmp_messages
The logging message enumeration.
Definition qsmp.h:826
@ qsmp_messages_decryption_fail
Definition qsmp.h:842
@ qsmp_messages_disconnect
Definition qsmp.h:836
@ qsmp_messages_accept_fail
Definition qsmp.h:828
@ qsmp_messages_none
Definition qsmp.h:827
@ qsmp_messages_connection_fail
Definition qsmp.h:845
@ qsmp_messages_queue_empty
Definition qsmp.h:839
@ qsmp_messages_keepalive_fail
Definition qsmp.h:843
@ qsmp_messages_invalid_request
Definition qsmp.h:846
@ qsmp_messages_bind_fail
Definition qsmp.h:830
@ qsmp_messages_create_fail
Definition qsmp.h:831
@ qsmp_messages_sockalloc_fail
Definition qsmp.h:841
@ qsmp_messages_socket_message
Definition qsmp.h:838
@ qsmp_messages_receive_fail
Definition qsmp.h:833
@ qsmp_messages_connect_success
Definition qsmp.h:832
@ qsmp_messages_listen_fail
Definition qsmp.h:829
@ qsmp_messages_kex_fail
Definition qsmp.h:835
@ qsmp_messages_allocate_fail
Definition qsmp.h:834
@ qsmp_messages_listener_fail
Definition qsmp.h:840
@ qsmp_messages_keepalive_timeout
Definition qsmp.h:844
@ qsmp_messages_disconnect_fail
Definition qsmp.h:837
QSMP_EXPORT_API void qsmp_packet_error_message(qsmp_network_packet *packet, qsmp_errors error)
Populate a packet structure with an error message.
Definition qsmp.c:499
#define QSMP_CONFIG_SIZE
The size of the protocol configuration string.
Definition qsmp.h:131
#define QSMP_PUBKEY_HEADER_SIZE
The size of the QSMP public key header.
Definition qsmp.h:657
QSMP_EXPORT_API qsmp_errors qsmp_header_validate(qsmp_connection_state *cns, const qsmp_network_packet *packetin, qsmp_flags kexflag, qsmp_flags pktflag, uint64_t sequence, uint32_t msglen)
Validate a packet header and timestamp.
Definition qsmp.c:225
QSMP_EXPORT_API const char * qsmp_error_to_string(qsmp_errors error)
Return a pointer to a string description of an error code.
Definition qsmp.c:202
QSMP_EXPORT_API void qsmp_log_message(qsmp_messages emsg)
Log a message.
Definition qsmp.c:354
#define QSMP_MESSAGE_STRING_DEPTH
The depth of the QSMP message string array.
Definition qsmp.h:772
QSMP_EXPORT_API size_t qsmp_public_key_encoding_size()
Get the key encoding string size.
Definition qsmp.c:716
QSMP_EXPORT_API size_t qsmp_public_key_encode(char *enck, size_t enclen, const qsmp_client_verification_key *pubk)
Encode a public key structure and copy to a string.
Definition qsmp.c:639
QSMP_EXPORT_API void qsmp_log_error(qsmp_messages emsg, qsc_socket_exceptions err, const char *msg)
Log the message, socket error, and string description.
Definition qsmp.c:317
QSMP_EXPORT_API void qsmp_connection_state_dispose(qsmp_connection_state *cns)
Reset the connection state.
Definition qsmp.c:183
QSMP_EXPORT_API void qsmp_header_create(qsmp_network_packet *packetout, qsmp_flags flag, uint64_t sequence, uint32_t msglen)
Populate a packet header and set the creation time.
Definition qsmp.c:216
QSMP_EXPORT_API bool qsmp_public_key_decode(qsmp_client_verification_key *pubk, const char *enck, size_t enclen)
Decode a public key string and populate a client key structure.
Definition qsmp.c:585
QSMP_EXPORT_API qsmp_asymmetric_signature_keypair * qsmp_asymmetric_signature_keypair_initialize()
Initialize an asymmetric signature keypair.
Definition qsmp.c:79
#define QSMP_PUBKEY_VERSION_SIZE
The size of the QSMP public key version string.
Definition qsmp.h:662
QSMP_EXPORT_API void qsmp_packet_clear(qsmp_network_packet *packet)
Clear a packet's state.
Definition qsmp.c:387
#define QSMP_SIGKEY_ENCODED_SIZE
The secret signature key size.
Definition qsmp.h:651
#define QSMP_ERROR_STRING_DEPTH
The depth of the QSMP error string array.
Definition qsmp.h:726
QSMP_EXPORT_API void qsmp_connection_close(qsmp_connection_state *cns, qsmp_errors err, bool notify)
Close the network connection between hosts.
Definition qsmp.c:105
QSMP_EXPORT_API void qsmp_signature_key_serialize(uint8_t serk[QSMP_SIGKEY_ENCODED_SIZE], const qsmp_server_signature_key *kset)
Encode a secret key structure and copy to a string.
Definition qsmp.c:760
#define QSMP_KEYID_SIZE
The QSMP key identity size.
Definition qsmp.h:266
The QSMP asymmetric cipher key container.
Definition qsmp.h:932
The QSMP asymmetric signature key container.
Definition qsmp.h:942
The QSMP client key structure.
Definition qsmp.h:965
uint8_t config[QSMP_CONFIG_SIZE]
Definition qsmp.h:967
uint64_t expiration
Definition qsmp.h:966
uint8_t verkey[QSMP_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition qsmp.h:969
uint8_t keyid[QSMP_KEYID_SIZE]
Definition qsmp.h:968
The QSMP socket connection state structure.
Definition qsmp.h:1002
uint64_t txseq
Definition qsmp.h:1008
qsmp_mode mode
Definition qsmp.h:1012
bool receiver
Definition qsmp.h:1011
qsc_rcs_state txcpr
Definition qsmp.h:1006
uint8_t rtcs[QSMP_DUPLEX_SYMMETRIC_KEY_SIZE]
Definition qsmp.h:1003
uint64_t rxseq
Definition qsmp.h:1007
uint32_t cid
Definition qsmp.h:1009
qsmp_flags exflag
Definition qsmp.h:1010
qsc_socket target
Definition qsmp.h:1004
qsc_rcs_state rxcpr
Definition qsmp.h:1005
The QSMP keep alive state structure.
Definition qsmp.h:990
bool recd
Definition qsmp.h:994
uint64_t seqctr
Definition qsmp.h:993
qsc_socket target
Definition qsmp.h:991
uint64_t etime
Definition qsmp.h:992
The QSMP packet structure.
Definition qsmp.h:952
uint8_t * pmessage
Definition qsmp.h:957
uint32_t msglen
Definition qsmp.h:954
uint64_t utctime
Definition qsmp.h:956
uint64_t sequence
Definition qsmp.h:955
uint8_t flag
Definition qsmp.h:953
The QSMP server key structure.
Definition qsmp.h:977
uint8_t config[QSMP_CONFIG_SIZE]
Definition qsmp.h:979
uint64_t expiration
Definition qsmp.h:978
uint8_t sigkey[QSMP_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition qsmp.h:981
uint8_t verkey[QSMP_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition qsmp.h:982
uint8_t keyid[QSMP_KEYID_SIZE]
Definition qsmp.h:980