44#include "../../QSC/QSC/socketbase.h"
45#include "../../QSC/QSC/rcs.h"
46#include "../../QSC/QSC/sha3.h"
89#define QSTP_CONFIG_DILITHIUM_KYBER
104#if defined(QSTP_CONFIG_DILITHIUM_KYBER)
105# include "../../QSC/QSC/dilithium.h"
106# include "../../QSC/QSC/kyber.h"
107#elif defined(QSTP_CONFIG_DILITHIUM_MCELIECE)
108# include "../../QSC/QSC/dilithium.h"
109# include "../../QSC/QSC/mceliece.h"
110#elif defined(QSTP_CONFIG_SPHINCS_MCELIECE)
111# include "../../QSC/QSC/sphincsplus.h"
112# include "../../QSC/QSC/mceliece.h"
114# error Invalid parameter set!
138#define QSTP_PROTOCOL_SET_SIZE 42
168#if defined(QSTP_CONFIG_DILITHIUM_MCELIECE)
174# define qstp_cipher_generate_keypair qsc_mceliece_generate_keypair
179# define qstp_cipher_decapsulate qsc_mceliece_decapsulate
184# define qstp_cipher_encapsulate qsc_mceliece_encapsulate
189# define qstp_signature_generate_keypair qsc_dilithium_generate_keypair
194# define qstp_signature_sign qsc_dilithium_sign
199# define qstp_signature_verify qsc_dilithium_verify
205# define QSTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
211# define QSTP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
217# define QSTP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
223# define QSTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
229# define QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
235# define QSTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
238# if defined(QSC_DILITHIUM_S1P2544) && defined(QSC_MCELIECE_S1N3488T64)
239 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s1_mceliece-s1_rcs-256_sha3-256";
241# elif defined(QSC_DILITHIUM_S3P4016) && defined(QSC_MCELIECE_S3N4608T96)
242 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s3_mceliece-s3_rcs-256_sha3-256";
244# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S5N6688T128)
245 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s5_mceliece-s5_rcs-256_sha3-256";
247# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S6N6960T119)
248 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s5_mceliece-s6_rcs-256_sha3-256";
250# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_MCELIECE_S7N8192T128)
251 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s5_mceliece-s7_rcs-256_sha3-256";
254# error the library parameter sets are mismatched!
258#elif defined(QSTP_CONFIG_DILITHIUM_KYBER)
264# define qstp_cipher_generate_keypair qsc_kyber_generate_keypair
269# define qstp_cipher_decapsulate qsc_kyber_decapsulate
274# define qstp_cipher_encapsulate qsc_kyber_encapsulate
279# define qstp_signature_generate_keypair qsc_dilithium_generate_keypair
284# define qstp_signature_sign qsc_dilithium_sign
289# define qstp_signature_verify qsc_dilithium_verify
295# define QSTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_KYBER_CIPHERTEXT_SIZE)
301# define QSTP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_KYBER_PRIVATEKEY_SIZE)
307# define QSTP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_KYBER_PUBLICKEY_SIZE)
313# define QSTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
319# define QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
325# define QSTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
328# if defined(QSC_DILITHIUM_S1P2544) && defined(QSC_KYBER_S1P1632)
329 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s1_kyber-s1_rcs-256_sha3-256";
331# elif defined(QSC_DILITHIUM_S3P4016) && defined(QSC_KYBER_S3P2400)
332 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s3_kyber-s3_rcs-256_sha3-256";
334# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_KYBER_S5P3168)
335 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s5_kyber-s5_rcs-256_sha3-256";
337# elif defined(QSC_DILITHIUM_S5P4880) && defined(QSC_KYBER_S6P3936)
338 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"dilithium-s5_kyber-s6_rcs-512_sha3-512";
341# error the library parameter sets are mismatched!
345#elif defined(QSTP_CONFIG_SPHINCS_MCELIECE)
351# define qstp_cipher_generate_keypair qsc_mceliece_generate_keypair
356# define qstp_cipher_decapsulate qsc_mceliece_decapsulate
361# define qstp_cipher_encapsulate qsc_mceliece_encapsulate
366# define qstp_signature_generate_keypair qsc_sphincsplus_generate_keypair
371# define qstp_signature_sign qsc_sphincsplus_sign
376# define qstp_signature_verify qsc_sphincsplus_verify
382# define QSTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
388# define QSTP_ASYMMETRIC_PRIVATE_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
394# define QSTP_ASYMMETRIC_PUBLIC_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
400# define QSTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_SPHINCSPLUS_PRIVATEKEY_SIZE)
406# define QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE (QSC_SPHINCSPLUS_PUBLICKEY_SIZE)
412# define QSTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_SPHINCSPLUS_SIGNATURE_SIZE)
415# if defined(QSC_MCELIECE_S1N3488T64) && defined(QSC_SPHINCSPLUS_S1S128SHAKERF)
416 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s1_sphincs-f1_rcs-256_sha3-256";
418# elif defined(QSC_MCELIECE_S1N3488T64) && defined(QSC_SPHINCSPLUS_S1S128SHAKERS)
419 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s1_sphincs-s1_rcs-256_sha3-256";
421# elif defined(QSC_MCELIECE_S3N4608T96) && defined(QSC_SPHINCSPLUS_S3S192SHAKERF)
422 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s3_sphincs-f3_rcs-256_sha3-256";
424# elif defined(QSC_MCELIECE_S3N4608T96) && defined(QSC_SPHINCSPLUS_S3S192SHAKERS)
425 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s3_sphincs-s3_rcs-256_sha3-256";
427# elif defined(QSC_MCELIECE_S5N6688T128) && defined(QSC_SPHINCSPLUS_S5S256SHAKERF)
428 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s5_sphincs-f5_rcs-256_sha3-256";
430# elif defined(QSC_MCELIECE_S5N6688T128) && defined(QSC_SPHINCSPLUS_S5S256SHAKERS)
431 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s5_sphincs-s5_rcs-256_sha3-256";
433# elif defined(QSC_MCELIECE_S6N6960T119) && defined(QSC_SPHINCSPLUS_S5S256SHAKERF)
434 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s6_sphincs-f5_rcs-256_sha3-256";
436# elif defined(QSC_MCELIECE_S6N6960T119) && defined(QSC_SPHINCSPLUS_S5S256SHAKERS)
437 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s6_sphincs-s5_rcs-256_sha3-256";
439# elif defined(QSC_MCELIECE_S7N8192T128) && defined(QSC_SPHINCSPLUS_S5S256SHAKERF)
440 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s7_sphincs-f5_rcs-256_sha3-256";
442# elif defined(QSC_MCELIECE_S7N8192T128) && defined(QSC_SPHINCSPLUS_S5S256SHAKERS)
443 static const char QSTP_PROTOCOL_SET_STRING[
QSTP_PROTOCOL_SET_SIZE] =
"mceliece-s7_sphincs-s5_rcs-256_sha3-256";
448# error Invalid parameter sets, check the QSC library settings
458#define QSTP_ACTIVE_VERSION 1
464#define QSTP_CERTIFICATE_ALGORITHM_SIZE 1
470#define QSTP_CERTIFICATE_DESIGNATION_SIZE 1
476#define QSTP_CERTIFICATE_EXPIRATION_SIZE 16
482#define QSTP_CERTIFICATE_HASH_SIZE 32
488#define QSTP_CERTIFICATE_ISSUER_SIZE 32
494#define QSTP_CERTIFICATE_LINE_LENGTH 64
500#define QSTP_CERTIFICATE_DEFAULT_PERIOD ((uint64_t)365 * 24 * 60 * 60)
506#define QSTP_CERTIFICATE_DEFAULT_DURATION_DAYS 365
512#define QSTP_CERTIFICATE_DEFAULT_DURATION_SECONDS (QSTP_CERTIFICATE_DEFAULT_DURATION_DAYS * 24 * 60 * 60)
518#define QSTP_CERTIFICATE_LINE_LENGTH 64
524#define QSTP_CERTIFICATE_MAXIMUM_PERIOD (QSTP_CERTIFICATE_DEFAULT_PERIOD * 2)
530#define QSTP_CERTIFICATE_MINIMUM_PERIOD ((uint64_t)1 * 24 * 60 * 60)
536#define QSTP_CERTIFICATE_SERIAL_SIZE 16
542#define QSTP_CERTIFICATE_SERIAL_ENCODED_SIZE 32
548#define QSTP_CERTIFICATE_SIGNED_HASH_SIZE (QSTP_ASYMMETRIC_SIGNATURE_SIZE + QSTP_CERTIFICATE_HASH_SIZE)
554#define QSTP_CERTIFICATE_TIMESTAMP_SIZE 8
560#define QSTP_CERTIFICATE_VERSION_SIZE 1
566#define QSTP_CONNECTIONS_INIT 1000
575#define QSTP_CONNECTIONS_MAX 50000
581#define QSTP_CONNECTION_MTU 1500
587#define QSTP_KEEPALIVE_TIMEOUT (120 * 1000)
593#define QSTP_MACTAG_SIZE 32
599#define QSTP_NONCE_SIZE 32
605#define QSTP_PACKET_ERROR_SEQUENCE 0xFF00000000000000ULL
611#define QSTP_PACKET_ERROR_SIZE 1
617#define QSTP_PACKET_FLAG_SIZE 1
623#define QSTP_PACKET_HEADER_SIZE 21
629#define QSTP_PACKET_MESSAGE_LENGTH_SIZE 4
635#define QSTP_PACKET_MESSAGE_MAX 0x3D090000
641#define QSTP_PACKET_REVOCATION_SEQUENCE 0xFFUL
647#define QSTP_PACKET_SEQUENCE_SIZE 8
653#define QSTP_PACKET_SEQUENCE_TERMINATOR 0xFFFFFFFFUL
662#define QSTP_PACKET_TIME_THRESHOLD 60
668#define QSTP_SECRET_SIZE 32
674#define QSTP_CLIENT_PORT 32118
680#define QSTP_SERVER_PORT 32119
686#define QSTP_ROOT_PORT 32120
692#define QSTP_SYMMETRIC_KEY_SIZE 32
698#define QSTP_STORAGE_PATH_MAX 260
704#define QSTP_ROOT_CERTIFICATE_SIZE (QSTP_CERTIFICATE_HASH_SIZE + \
705 QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE + \
706 QSTP_CERTIFICATE_ISSUER_SIZE + \
707 QSTP_CERTIFICATE_SERIAL_SIZE + \
708 QSTP_CERTIFICATE_EXPIRATION_SIZE + \
709 QSTP_CERTIFICATE_ALGORITHM_SIZE + \
710 QSTP_CERTIFICATE_VERSION_SIZE)
716#define QSTP_ROOT_SIGNATURE_KEY_SIZE (QSTP_CERTIFICATE_ISSUER_SIZE + \
717 QSTP_CERTIFICATE_SERIAL_SIZE + \
718 QSTP_ASYMMETRIC_SIGNING_KEY_SIZE + \
719 QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE + \
720 QSTP_CERTIFICATE_EXPIRATION_SIZE + \
721 QSTP_CERTIFICATE_ALGORITHM_SIZE + \
722 QSTP_CERTIFICATE_VERSION_SIZE)
728#define QSTP_SERVER_CERTIFICATE_SIZE (QSTP_CERTIFICATE_SIGNED_HASH_SIZE + \
729 QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE + \
730 QSTP_CERTIFICATE_ISSUER_SIZE + \
731 QSTP_CERTIFICATE_SERIAL_SIZE + \
732 QSTP_CERTIFICATE_SERIAL_SIZE + \
733 QSTP_CERTIFICATE_EXPIRATION_SIZE + \
734 QSTP_CERTIFICATE_ALGORITHM_SIZE + \
735 QSTP_CERTIFICATE_DESIGNATION_SIZE + \
736 QSTP_CERTIFICATE_VERSION_SIZE)
742#define QSTP_SERVER_SIGNATURE_KEY_SIZE (QSTP_ASYMMETRIC_SIGNING_KEY_SIZE + \
743 QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE + \
744 QSTP_CERTIFICATE_ISSUER_SIZE + \
745 QSTP_CERTIFICATE_HASH_SIZE + \
746 QSTP_CERTIFICATE_SERIAL_SIZE + \
747 QSTP_CERTIFICATE_EXPIRATION_SIZE + \
748 QSTP_CERTIFICATE_ALGORITHM_SIZE + \
749 QSTP_CERTIFICATE_DESIGNATION_SIZE + \
750 QSTP_CERTIFICATE_VERSION_SIZE)
753#define QSTP_PROTOCOL_SET_DEPTH 12
758 "dilithium-s1_kyber-s1_rcs-256_sha3-256",
759 "dilithium-s3_kyber-s3_rcs-256_sha3-256",
760 "dilithium-s5_kyber-s5_rcs-256_sha3-256",
761 "dilithium-s5_kyber-s6_rcs-256_sha3-256",
762 "dilithium-s1_mceliece-s1_rcs-256_sha3-256",
763 "dilithium-s3_mceliece-s3_rcs-256_sha3-256",
764 "dilithium-s5_mceliece-s5_rcs-256_sha3-256",
765 "sphincs-1f_mceliece-s1_rcs-256_sha3-256",
766 "sphincs-3f_mceliece-s3_rcs-256_sha3-256",
767 "sphincs-5f_mceliece-s5_rcs-256_sha3-256",
768 "sphincs-5f_mceliece-s6_rcs-256_sha3-256",
769 "sphincs-5f_mceliece-s7_rcs-256_sha3-256",
775#define QSTP_MESSAGE_STRING_DEPTH 20
776#define QSTP_MESSAGE_STRING_WIDTH 128
778static const char QSTP_MESSAGE_STRINGS[QSTP_MESSAGE_STRING_DEPTH][QSTP_MESSAGE_STRING_WIDTH] =
780 "No configuration was specified.",
781 "The socket accept failed.",
782 "The listener socket could not connect.",
783 "The listener socket could not bind to the address.",
784 "The listener socket could not be created.",
785 "The server connected to a host.",
786 "The socket receive function failed.",
787 "The server memory allocation request has failed.",
788 "The key exchange has experienced a failure.",
789 "The server has disconnected the client.",
790 "The server has disconnected the client due to an error.",
791 "The server has had a socket level error.",
792 "The server has reached the maximum number of connections.",
793 "The server listener socket has failed.",
794 "The server has run out of socket connections.",
795 "The message decryption has failed.",
796 "The keepalive function has failed.",
797 "The keepalive period has been exceeded",
798 "The connection failed or was interrupted.",
799 "The function received an invalid request."
804#define QSTP_ERROR_STRING_DEPTH 30
805#define QSTP_ERROR_STRING_WIDTH 128
807static const char QSTP_ERROR_STRINGS[QSTP_ERROR_STRING_DEPTH][QSTP_ERROR_STRING_WIDTH] =
809 "No error was detected",
810 "The socket accept function returned an error",
811 "The symmetric cipher had an authentication failure",
812 "The keep alive check failed",
813 "The communications channel has failed",
814 "The device could not make a connection to the remote host",
815 "The transmission failed at the KEX connection phase",
816 "The asymmetric cipher failed to decapsulate the shared secret",
817 "The decryption authentication has failed",
818 "The transmission failed at the KEX establish phase",
819 "The transmission failed at the KEX exchange phase",
820 "The public - key hash is invalid",
821 "The server has run out of socket connections",
822 "The expected input was invalid",
823 "The packet flag was unexpected",
824 "The keep alive has expired with no response",
825 "The decryption authentication has failed",
826 "The QSTP public key has expired ",
827 "The key identity is unrecognized",
828 "The ratchet operation has failed",
829 "The listener function failed to initialize",
830 "The server has run out of memory",
831 "The packet has valid time expired",
832 "The packet was received out of sequence",
833 "The random generator has failed",
834 "The receiver failed at the network layer",
835 "The signing function has failed",
836 "The transmitter failed at the network layer",
837 "The protocol string was not recognized",
838 "The expected data could not be verified"
1094static const char QSTP_CLIENT_DIRECTORY_PATH[] =
"Client";
1095static const char QSTP_ROOT_CERTIFICATE_EXTENSION_NAME[] =
".qrr";
1096static const char QSTP_ROOT_DIRECTORY_PATH[] =
"Root";
1097static const char QSTP_ROOT_PRIVATE_KEY_NAME[] =
"root_secret_key.qsk";
1098static const char QSTP_ROOT_PUBLIC_CERTIFICATE_NAME[] =
"root_public_cert.qrr";
1099static const char QSTP_SERVER_CERTIFICATE_EXTENSION_NAME[] =
".qrc";
1100static const char QSTP_SERVER_DIRECTORY_PATH[] =
"Server";
1101static const char QSTP_SERVER_PRIVATE_KEY_NAME[] =
"server_secret_key.qsk";
1102static const char QSTP_SERVER_PUBLIC_CERTIFICATE_NAME[] =
"server_public_cert.qrc";
1107#define QSTP_CERTIFICATE_SEPERATOR_SIZE 1
1108#define QSTP_CHILD_CERTIFICATE_HEADER_SIZE 54
1109#define QSTP_CHILD_CERTIFICATE_HASH_PREFIX_SIZE 30
1110#define QSTP_CHILD_CERTIFICATE_SIGNATURE_KEY_PREFIX_SIZE 23
1111#define QSTP_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE 9
1112#define QSTP_CHILD_CERTIFICATE_NAME_PREFIX_SIZE 7
1113#define QSTP_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE 9
1114#define QSTP_CHILD_CERTIFICATE_ROOT_SERIAL_PREFIX_SIZE 14
1115#define QSTP_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE 13
1116#define QSTP_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE 11
1117#define QSTP_CHILD_CERTIFICATE_ALGORITHM_PREFIX_SIZE 12
1118#define QSTP_CHILD_CERTIFICATE_VERSION_PREFIX_SIZE 10
1119#define QSTP_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE 14
1120#define QSTP_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE 10
1121#define QSTP_CHILD_CERTIFICATE_PUBLICKEY_PREFIX_SIZE 13
1122#define QSTP_CHILD_CERTIFICATE_FOOTER_SIZE 52
1126static const char QSTP_CHILD_CERTIFICATE_HEADER[QSTP_CHILD_CERTIFICATE_HEADER_SIZE] =
"------BEGIN QSTP CHILD PUBLIC CERTIFICATE BLOCK------";
1127static const char QSTP_CHILD_CERTIFICATE_ROOT_HASH_PREFIX[QSTP_CHILD_CERTIFICATE_HASH_PREFIX_SIZE] =
"Root Signed Public Key Hash: ";
1128static const char QSTP_CHILD_CERTIFICATE_SIGNATURE_KEY_PREFIX[QSTP_CHILD_CERTIFICATE_SIGNATURE_KEY_PREFIX_SIZE] =
"Public Signature Key: ";
1129static const char QSTP_CHILD_CERTIFICATE_ISSUER_PREFIX[QSTP_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE] =
"Issuer: ";
1130static const char QSTP_CHILD_CERTIFICATE_NAME_PREFIX[QSTP_CHILD_CERTIFICATE_NAME_PREFIX_SIZE] =
"Name: ";
1131static const char QSTP_CHILD_CERTIFICATE_SERIAL_PREFIX[QSTP_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE] =
"Serial: ";
1132static const char QSTP_CHILD_CERTIFICATE_ROOT_SERIAL_PREFIX[QSTP_CHILD_CERTIFICATE_ROOT_SERIAL_PREFIX_SIZE] =
"Root Serial: ";
1133static const char QSTP_CHILD_CERTIFICATE_VALID_FROM_PREFIX[QSTP_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE] =
"Valid From: ";
1134static const char QSTP_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX[QSTP_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE] =
"Valid To: ";
1135static const char QSTP_CHILD_CERTIFICATE_PROTOCOL_PREFIX[QSTP_CHILD_CERTIFICATE_ALGORITHM_PREFIX_SIZE] =
"Algorithm: ";
1136static const char QSTP_CHILD_CERTIFICATE_VERSION_PREFIX[QSTP_CHILD_CERTIFICATE_VERSION_PREFIX_SIZE] =
"Version: ";
1137static const char QSTP_CHILD_CERTIFICATE_DESIGNATION_PREFIX[QSTP_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE] =
"Designation: ";
1138static const char QSTP_CHILD_CERTIFICATE_ADDRESS_PREFIX[QSTP_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE] =
"Address: ";
1139static const char QSTP_CHILD_CERTIFICATE_PUBLICKEY_PREFIX[QSTP_CHILD_CERTIFICATE_PUBLICKEY_PREFIX_SIZE] =
"Public Key: ";
1140static const char QSTP_CHILD_CERTIFICATE_FOOTER[QSTP_CHILD_CERTIFICATE_FOOTER_SIZE] =
"------END QSTP CHILD PUBLIC CERTIFICATE BLOCK------";
1144#define QSTP_ROOT_CERTIFICATE_HEADER_SIZE 53
1145#define QSTP_ROOT_CERTIFICATE_HASH_PREFIX_SIZE 19
1146#define QSTP_ROOT_CERTIFICATE_PUBLICKEY_PREFIX_SIZE 13
1147#define QSTP_ROOT_CERTIFICATE_ISSUER_PREFIX_SIZE 9
1148#define QSTP_ROOT_CERTIFICATE_NAME_PREFIX_SIZE 7
1149#define QSTP_ROOT_CERTIFICATE_SERIAL_PREFIX_SIZE 9
1150#define QSTP_ROOT_CERTIFICATE_FOOTER_SIZE 51
1151#define QSTP_ROOT_CERTIFICATE_VALID_FROM_PREFIX_SIZE 13
1152#define QSTP_ROOT_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE 11
1153#define QSTP_ROOT_CERTIFICATE_ALGORITHM_PREFIX_SIZE 12
1154#define QSTP_ROOT_CERTIFICATE_VERSION_PREFIX_SIZE 10
1155#define QSTP_ROOT_CERTIFICATE_DEFAULT_NAME_SIZE 18
1156#define QSTP_ROOT_ACTIVE_VERSION_STRING_SIZE 5
1157#define QSTP_CERTIFICATE_DEFAULT_DOMAIN_SIZE 5
1161static const char QSTP_ROOT_CERTIFICATE_HEADER[QSTP_ROOT_CERTIFICATE_HEADER_SIZE] =
"------BEGIN QSTP ROOT PUBLIC CERTIFICATE BLOCK------";
1162static const char QSTP_ROOT_CERTIFICATE_ISSUER_PREFIX[QSTP_ROOT_CERTIFICATE_ISSUER_PREFIX_SIZE] =
"Issuer: ";
1163static const char QSTP_ROOT_CERTIFICATE_NAME_PREFIX[QSTP_ROOT_CERTIFICATE_NAME_PREFIX_SIZE] =
"Name: ";
1164static const char QSTP_ROOT_CERTIFICATE_SERIAL_PREFIX[QSTP_ROOT_CERTIFICATE_SERIAL_PREFIX_SIZE] =
"Serial: ";
1165static const char QSTP_ROOT_CERTIFICATE_VALID_FROM_PREFIX[QSTP_ROOT_CERTIFICATE_VALID_FROM_PREFIX_SIZE] =
"Valid From: ";
1166static const char QSTP_ROOT_CERTIFICATE_EXPIRATION_TO_PREFIX[QSTP_ROOT_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE] =
"Valid To: ";
1167static const char QSTP_ROOT_CERTIFICATE_PROTOCOL_PREFIX[QSTP_ROOT_CERTIFICATE_ALGORITHM_PREFIX_SIZE] =
"Algorithm: ";
1168static const char QSTP_ROOT_CERTIFICATE_VERSION_PREFIX[QSTP_ROOT_CERTIFICATE_VERSION_PREFIX_SIZE] =
"Version: ";
1169static const char QSTP_ROOT_CERTIFICATE_HASH_PREFIX[QSTP_ROOT_CERTIFICATE_HASH_PREFIX_SIZE] =
"Certificate Hash: ";
1170static const char QSTP_ROOT_CERTIFICATE_PUBLICKEY_PREFIX[QSTP_ROOT_CERTIFICATE_PUBLICKEY_PREFIX_SIZE] =
"Public Key: ";
1171static const char QSTP_ROOT_CERTIFICATE_FOOTER[QSTP_ROOT_CERTIFICATE_FOOTER_SIZE] =
"------END QSTP ROOT PUBLIC CERTIFICATE BLOCK------";
1172static const char QSTP_ROOT_CERTIFICATE_DEFAULT_NAME[QSTP_ROOT_CERTIFICATE_DEFAULT_NAME_SIZE] =
" Root Certificate";
1173static const char QSTP_ACTIVE_VERSION_STRING[QSTP_ROOT_ACTIVE_VERSION_STRING_SIZE] =
"0x01";
1174static const char QSTP_CERTIFICATE_DEFAULT_DOMAIN[QSTP_CERTIFICATE_DEFAULT_DOMAIN_SIZE] =
"QSTP";
QSTP common includes and definitions.
#define QSTP_EXPORT_API
The api export prefix.
Definition common.h:99
#define QSTP_SERVER_CERTIFICATE_SIZE
The total length in bytes of a server certificate.
Definition qstp.h:728
QSTP_EXPORT_API void qstp_packet_set_utc_time(qstp_network_packet *packet)
Set the local UTC time (in seconds) in a QSTP packet header.
Definition qstp.c:466
QSTP_EXPORT_API size_t qstp_root_certificate_encoded_size()
Get the size required to encode a root certificate.
Definition qstp.c:649
QSTP_EXPORT_API void qstp_packet_clear(qstp_network_packet *packet)
Clear the state of a QSTP network packet.
Definition qstp.c:396
#define QSTP_CERTIFICATE_SERIAL_SIZE
The length of the certificate serial number field in bytes.
Definition qstp.h:536
QSTP_EXPORT_API void qstp_server_certificate_serialize(uint8_t output[QSTP_SERVER_CERTIFICATE_SIZE], const qstp_server_certificate *cert)
Serialize a server certificate into a byte array.
Definition qstp.c:1497
QSTP_EXPORT_API void qstp_server_certificate_hash(uint8_t output[QSTP_CERTIFICATE_HASH_SIZE], const qstp_server_certificate *cert)
Compute the hash of a server certificate.
Definition qstp.c:1455
QSTP_EXPORT_API void qstp_log_message(qstp_messages emsg)
Log a QSTP message.
Definition qstp.c:348
QSTP_EXPORT_API size_t qstp_packet_to_stream(const qstp_network_packet *packet, uint8_t *pstream)
Serialize a QSTP packet into a byte array.
Definition qstp.c:493
QSTP_EXPORT_API bool qstp_server_file_to_key(qstp_server_signature_key *kset, const char *fpath)
Read a server signature key from a file into a server key structure.
Definition qstp.c:1575
#define QSTP_ROOT_CERTIFICATE_SIZE
The total length in bytes of the root certificate.
Definition qstp.h:704
QSTP_EXPORT_API void qstp_packet_error_message(qstp_network_packet *packet, qstp_errors error)
Populate a QSTP packet with an error message.
Definition qstp.c:414
QSTP_EXPORT_API void qstp_root_certificate_hash(uint8_t output[QSTP_CERTIFICATE_HASH_SIZE], const qstp_root_certificate *root)
Compute the hash of a root certificate.
Definition qstp.c:814
QSTP_EXPORT_API size_t qstp_root_certificate_encode(char *enck, size_t enclen, const qstp_root_certificate *root)
Encode a root certificate into a readable string.
Definition qstp.c:686
QSTP_EXPORT_API void qstp_server_certificate_deserialize(qstp_server_certificate *cert, const uint8_t input[QSTP_SERVER_CERTIFICATE_SIZE])
Deserialize a server certificate from a serialized byte stream.
Definition qstp.c:1225
#define QSTP_CERTIFICATE_ISSUER_SIZE
The maximum length of the certificate issuer string (including terminator).
Definition qstp.h:488
QSTP_EXPORT_API void qstp_root_certificate_deserialize(qstp_root_certificate *root, const uint8_t input[QSTP_ROOT_CERTIFICATE_SIZE])
Deserialize a root certificate from a serialized byte array.
Definition qstp.c:626
qstp_messages
The logging message enumeration.
Definition qstp.h:847
@ qstp_messages_allocate_fail
Definition qstp.h:855
@ qstp_messages_keepalive_fail
Definition qstp.h:864
@ qstp_messages_listen_fail
Definition qstp.h:850
@ qstp_messages_none
Definition qstp.h:848
@ qstp_messages_invalid_request
Definition qstp.h:867
@ qstp_messages_socket_message
Definition qstp.h:859
@ qstp_messages_connect_success
Definition qstp.h:853
@ qstp_messages_connection_fail
Definition qstp.h:866
@ qstp_messages_disconnect
Definition qstp.h:857
@ qstp_messages_decryption_fail
Definition qstp.h:863
@ qstp_messages_disconnect_fail
Definition qstp.h:858
@ qstp_messages_create_fail
Definition qstp.h:852
@ qstp_messages_keepalive_timeout
Definition qstp.h:865
@ qstp_messages_bind_fail
Definition qstp.h:851
@ qstp_messages_accept_fail
Definition qstp.h:849
@ qstp_messages_queue_empty
Definition qstp.h:860
@ qstp_messages_sockalloc_fail
Definition qstp.h:862
@ qstp_messages_listener_fail
Definition qstp.h:861
@ qstp_messages_kex_fail
Definition qstp.h:856
@ qstp_messages_receive_fail
Definition qstp.h:854
#define QSTP_CERTIFICATE_SIGNED_HASH_SIZE
The size in bytes of the signature and hash field in a certificate.
Definition qstp.h:548
#define QSTP_ASYMMETRIC_SIGNING_KEY_SIZE
The byte size of the asymmetric signature signing-key array (Dilithium)
Definition qstp.h:313
QSTP_EXPORT_API void qstp_log_write(qstp_messages emsg, const char *msg)
Log a QSTP message with an additional description.
Definition qstp.c:358
QSTP_EXPORT_API bool qstp_root_file_to_certificate(qstp_root_certificate *root, const char *fpath)
Read a root certificate from a file into a root certificate structure.
Definition qstp.c:940
QSTP_EXPORT_API bool qstp_root_file_to_key(qstp_root_signature_key *kset, const char *fpath)
Read a root signature key from a file into a root signature key structure.
Definition qstp.c:966
#define QSTP_SERVER_SIGNATURE_KEY_SIZE
The total length in bytes of a server signing key.
Definition qstp.h:742
#define QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE
The byte size of the asymmetric signature verification-key array (Dilithium)
Definition qstp.h:319
QSTP_EXPORT_API void qstp_root_certificate_serialize(uint8_t output[QSTP_ROOT_CERTIFICATE_SIZE], const qstp_root_certificate *root)
Serialize a root certificate into a byte array.
Definition qstp.c:839
QSTP_EXPORT_API size_t qstp_server_certificate_encoded_size()
Get the size required to encode a server certificate.
Definition qstp.c:1252
QSTP_EXPORT_API const char * qstp_configuration_to_string(qstp_configuration_sets cset)
Get the configuration string from the enumerator.
Definition qstp.c:38
QSTP_EXPORT_API bool qstp_root_key_to_file(const qstp_root_signature_key *kset, const char *fpath)
Write a root signature key to a file.
Definition qstp.c:1038
QSTP_EXPORT_API qstp_errors qstp_decrypt_packet(qstp_connection_state *cns, uint8_t *message, size_t *msglen, const qstp_network_packet *packetin)
Decrypt a message from an input packet.
Definition qstp.c:136
qstp_errors
The QSTP error values.
Definition qstp.h:875
@ qstp_error_decryption_failure
Definition qstp.h:884
@ qstp_error_memory_allocation
Definition qstp.h:897
@ qstp_error_accept_fail
Definition qstp.h:877
@ qstp_error_key_expired
Definition qstp.h:893
@ qstp_error_decapsulation_failure
Definition qstp.h:883
@ qstp_error_bad_keep_alive
Definition qstp.h:879
@ qstp_error_keepalive_timeout
Definition qstp.h:892
@ qstp_error_listener_fail
Definition qstp.h:896
@ qstp_error_hash_invalid
Definition qstp.h:887
@ qstp_error_receive_failure
Definition qstp.h:901
@ qstp_error_signature_failure
Definition qstp.h:902
@ qstp_error_hosts_exceeded
Definition qstp.h:888
@ qstp_error_invalid_request
Definition qstp.h:890
@ qstp_error_connect_failure
Definition qstp.h:882
@ qstp_error_keychain_fail
Definition qstp.h:895
@ qstp_error_message_time_invalid
Definition qstp.h:898
@ qstp_error_establish_failure
Definition qstp.h:885
@ qstp_error_authentication_failure
Definition qstp.h:878
@ qstp_error_packet_unsequenced
Definition qstp.h:899
@ qstp_error_unknown_protocol
Definition qstp.h:904
@ qstp_error_random_failure
Definition qstp.h:900
@ qstp_error_connection_failure
Definition qstp.h:881
@ qstp_error_verify_failure
Definition qstp.h:905
@ qstp_error_transmit_failure
Definition qstp.h:903
@ qstp_error_key_unrecognized
Definition qstp.h:894
@ qstp_error_keepalive_expired
Definition qstp.h:891
@ qstp_error_exchange_failure
Definition qstp.h:886
@ qstp_error_none
Definition qstp.h:876
@ qstp_error_invalid_input
Definition qstp.h:889
@ qstp_error_channel_down
Definition qstp.h:880
QSTP_EXPORT_API void qstp_connection_close(qstp_connection_state *cns, qstp_errors err, bool notify)
Close the network connection between hosts.
Definition qstp.c:52
#define QSTP_PROTOCOL_SET_SIZE
The size of the protocol configuration string.
Definition qstp.h:138
QSTP_EXPORT_API void qstp_server_get_issuer(char issuer[QSTP_CERTIFICATE_ISSUER_SIZE])
Get the server certificate issuer name.
Definition qstp.c:1601
QSTP_EXPORT_API const char * qstp_get_error_description(qstp_messages emsg)
Get the error description string for a QSTP logging message.
Definition qstp.c:381
QSTP_EXPORT_API void qstp_server_key_deserialize(qstp_server_signature_key *kset, const uint8_t input[QSTP_SERVER_SIGNATURE_KEY_SIZE])
Deserialize a server signature key from an encoded array.
Definition qstp.c:1623
QSTP_EXPORT_API void qstp_version_to_string(char *sver, uint8_t version)
Convert a version number to a hexadecimal string.
Definition qstp.c:1722
QSTP_EXPORT_API size_t qstp_root_certificate_sign(qstp_server_certificate *cert, const qstp_root_certificate *root, const uint8_t *rsigkey)
Sign a server certificate using the root certificate.
Definition qstp.c:862
QSTP_EXPORT_API bool qstp_server_key_to_file(const qstp_server_signature_key *kset, const char *fpath)
Write a server signature key to a file.
Definition qstp.c:1649
QSTP_EXPORT_API bool qstp_server_file_to_certificate(qstp_server_certificate *cert, const char *fpath)
Read a server certificate from a file into a server certificate structure.
Definition qstp.c:1549
qstp_configuration_sets
The MPDC algorithm configuration sets.
Definition qstp.h:145
@ qstp_configuration_set_dilithium5_mceliece7_rcs256_shake256
Definition qstp.h:155
@ qstp_configuration_set_dilithium5_mceliece6_rcs256_shake256
Definition qstp.h:154
@ qstp_configuration_set_dilithium3_kyber3_rcs256_shake256
Definition qstp.h:148
@ qstp_configuration_set_sphincsplus5s_mceliece5_rcs256_shake256
Definition qstp.h:161
@ qstp_configuration_set_dilithium5_kyber6_rcs512_shake512
Definition qstp.h:150
@ qstp_configuration_set_dilithium5_kyber5_rcs256_shake256
Definition qstp.h:149
@ qstp_configuration_set_dilithium1_mceliece1_rcs256_shake256
Definition qstp.h:151
@ qstp_configuration_set_sphincsplus5f_mceliece5_rcs256_shake256
Definition qstp.h:160
@ qstp_configuration_set_dilithium3_mceliece3_rcs256_shake256
Definition qstp.h:152
@ qstp_configuration_set_sphincsplus5s_mceliece7_rcs256_shake256
Definition qstp.h:165
@ qstp_configuration_set_sphincsplus5s_mceliece6_rcs256_shake256
Definition qstp.h:163
@ qstp_configuration_set_sphincsplus3f_mceliece3_rcs256_shake256
Definition qstp.h:158
@ qstp_configuration_set_none
Definition qstp.h:146
@ qstp_configuration_set_sphincsplus1f_mceliece1_rcs256_shake256
Definition qstp.h:156
@ qstp_configuration_set_sphincsplus1s_mceliece1_rcs256_shake256
Definition qstp.h:157
@ qstp_configuration_set_sphincsplus3s_mceliece3_rcs256_shake256
Definition qstp.h:159
@ qstp_configuration_set_dilithium5_mceliece5_rcs256_shake256
Definition qstp.h:153
@ qstp_configuration_set_sphincsplus5f_mceliece7_rcs256_shake256
Definition qstp.h:164
@ qstp_configuration_set_sphincsplus5f_mceliece6_rcs256_shake256
Definition qstp.h:162
@ qstp_configuration_set_dilithium1_kyber1_rcs256_shake256
Definition qstp.h:147
#define QSTP_CERTIFICATE_HASH_SIZE
The size in bytes of the certificate hash.
Definition qstp.h:482
QSTP_EXPORT_API void qstp_server_certificate_extract(qstp_server_certificate *cert, const qstp_server_signature_key *kset)
Extract the server certificate from a server signature key.
Definition qstp.c:1438
qstp_flags
The QSTP packet flags.
Definition qstp.h:913
@ qstp_flag_establish_request
Definition qstp.h:923
@ qstp_flag_exstart_response
Definition qstp.h:920
@ qstp_flag_remote_terminated
Definition qstp.h:928
@ qstp_flag_transfer_request
Definition qstp.h:933
@ qstp_flag_connect_request
Definition qstp.h:915
@ qstp_flag_session_established
Definition qstp.h:929
@ qstp_flag_encrypted_message
Definition qstp.h:918
@ qstp_flag_establish_response
Definition qstp.h:924
@ qstp_flag_unrecognized_protocol
Definition qstp.h:931
@ qstp_flag_exchange_response
Definition qstp.h:922
@ qstp_flag_keep_alive_response
Definition qstp.h:926
@ qstp_flag_session_establish_verify
Definition qstp.h:930
@ qstp_flag_exchange_request
Definition qstp.h:921
@ qstp_flag_connection_terminate
Definition qstp.h:917
@ qstp_flag_connect_response
Definition qstp.h:916
@ qstp_flag_keep_alive_request
Definition qstp.h:925
@ qstp_flag_exstart_request
Definition qstp.h:919
@ qstp_flag_error_condition
Definition qstp.h:934
@ qstp_flag_none
Definition qstp.h:914
@ qstp_flag_remote_connected
Definition qstp.h:927
@ qstp_flag_certificate_revoke
Definition qstp.h:932
QSTP_EXPORT_API qstp_errors qstp_encrypt_packet(qstp_connection_state *cns, qstp_network_packet *packetout, const uint8_t *message, size_t msglen)
Encrypt a message and build an output packet.
Definition qstp.c:195
QSTP_EXPORT_API void qstp_root_get_issuer(char issuer[QSTP_CERTIFICATE_ISSUER_SIZE])
Get the root certificate issuer name.
Definition qstp.c:992
QSTP_EXPORT_API void qstp_root_certificate_extract(qstp_root_certificate *root, const qstp_root_signature_key *kset)
Extract the root certificate from a root signature key.
Definition qstp.c:797
QSTP_EXPORT_API void qstp_server_key_serialize(uint8_t output[QSTP_SERVER_SIGNATURE_KEY_SIZE], const qstp_server_signature_key *kset)
Serialize a server signature key into a byte array.
Definition qstp.c:1673
QSTP_EXPORT_API void qstp_log_error(qstp_messages emsg, qsc_socket_exceptions err, const char *msg)
Log an error with a message, socket error, and description.
Definition qstp.c:311
QSTP_EXPORT_API const char * qstp_error_to_string(qstp_errors error)
Return a pointer to a string description of an error code.
Definition qstp.c:232
qstp_version_sets
The MPDC version sets.
Definition qstp.h:955
@ qstp_version_set_none
Definition qstp.h:956
@ qstp_version_set_one_zero
Definition qstp.h:957
QSTP_EXPORT_API bool qstp_root_certificate_decode(qstp_root_certificate *root, const char *enck, size_t enclen)
Copy an encoded root certificate into a root certificate structure.
Definition qstp.c:549
QSTP_EXPORT_API bool qstp_root_certificate_to_file(const qstp_root_certificate *root, const char *fpath)
Write a root certificate to a file.
Definition qstp.c:918
QSTP_EXPORT_API void qstp_packet_header_deserialize(const uint8_t *header, qstp_network_packet *packet)
Deserialize a byte array into a QSTP packet header.
Definition qstp.c:428
QSTP_EXPORT_API bool qstp_root_certificate_verify(const qstp_root_certificate *root, const qstp_server_certificate *cert)
Verify that a server certificate is signed by the root.
Definition qstp.c:888
QSTP_EXPORT_API bool qstp_server_certificate_compare(const qstp_server_certificate *a, const qstp_server_certificate *b)
Compare two server certificates for equivalence.
Definition qstp.c:1087
#define QSTP_ROOT_SIGNATURE_KEY_SIZE
The total length in bytes of the root signature key.
Definition qstp.h:716
QSTP_EXPORT_API bool qstp_packet_time_valid(const qstp_network_packet *packet)
Check if a QSTP packet was received within the valid time threshold.
Definition qstp.c:476
QSTP_EXPORT_API size_t qstp_server_certificate_encode(char *enck, size_t enclen, const qstp_server_certificate *cert)
Encode a public server certificate into a readable string.
Definition qstp.c:1296
QSTP_EXPORT_API void qstp_root_key_serialize(uint8_t serk[QSTP_ROOT_SIGNATURE_KEY_SIZE], const qstp_root_signature_key *kset)
Serialize a root signature key into an encoded array.
Definition qstp.c:1062
QSTP_EXPORT_API bool qstp_test_server_certificate_encoding(const qstp_server_certificate *cert)
Test the server certificate encoding and decoding functions.
Definition qstp.c:1769
qstp_network_designations
The MPDC device designations.
Definition qstp.h:942
@ mpdc_network_designation_root
Definition qstp.h:945
@ qstp_network_designation_none
Definition qstp.h:943
@ mpdc_network_designation_all
Definition qstp.h:947
@ mpdc_network_designation_server
Definition qstp.h:946
@ mpdc_network_designation_client
Definition qstp.h:944
QSTP_EXPORT_API bool qstp_root_certificate_compare(const qstp_root_certificate *a, const qstp_root_certificate *b)
Compare two root certificates for equivalence.
Definition qstp.c:520
QSTP_EXPORT_API qstp_errors qstp_header_validate(qstp_connection_state *cns, const qstp_network_packet *packetin, qstp_flags flag, uint64_t sequence, uint32_t msglen)
Validate a packet header and timestamp.
Definition qstp.c:260
QSTP_EXPORT_API uint8_t qstp_version_from_string(const char *sver, size_t sverlen)
Convert a version string to a version number.
Definition qstp.c:1700
QSTP_EXPORT_API bool qstp_server_certificate_to_file(const qstp_server_certificate *cert, const char *fpath)
Write a server certificate to a file.
Definition qstp.c:1525
QSTP_EXPORT_API void qstp_connection_state_dispose(qstp_connection_state *cns)
Reset the connection state to zero.
Definition qstp.c:120
QSTP_EXPORT_API void qstp_header_create(qstp_network_packet *packetout, qstp_flags flag, uint64_t sequence, uint32_t msglen)
Populate a packet header and set its creation time.
Definition qstp.c:246
QSTP_EXPORT_API void qstp_root_key_deserialize(qstp_root_signature_key *kset, const uint8_t input[QSTP_ROOT_SIGNATURE_KEY_SIZE])
Deserialize a root signature key from an encoded array.
Definition qstp.c:1014
QSTP_EXPORT_API void qstp_packet_header_serialize(const qstp_network_packet *packet, uint8_t *header)
Serialize a QSTP packet header into a byte array.
Definition qstp.c:447
QSTP_EXPORT_API void qstp_server_root_certificate_hash(uint8_t rshash[QSTP_CERTIFICATE_HASH_SIZE], const qstp_root_certificate *root, const qstp_server_certificate *cert)
Compute a combined hash of the root and server certificates.
Definition qstp.c:1480
QSTP_EXPORT_API qstp_configuration_sets qstp_configuration_from_string(const char *config)
Get the configuration enumerator from a string.
Definition qstp.c:14
QSTP_EXPORT_API bool qstp_test_root_certificate_encoding(const qstp_root_certificate *root)
Test the root certificate encoding and decoding functions.
Definition qstp.c:1732
Certificate expiration time structure.
Definition qstp.h:967
uint64_t to
Definition qstp.h:969
uint64_t from
Definition qstp.h:968
The QSTP socket connection state structure.
Definition qstp.h:1081
uint64_t txseq
Definition qstp.h:1086
qstp_flags exflag
Definition qstp.h:1088
bool receiver
Definition qstp.h:1089
qsc_rcs_state txcpr
Definition qstp.h:1084
uint64_t rxseq
Definition qstp.h:1085
uint32_t cid
Definition qstp.h:1087
qsc_socket target
Definition qstp.h:1082
qsc_rcs_state rxcpr
Definition qstp.h:1083
The QSTP keep alive state structure.
Definition qstp.h:979
bool recd
Definition qstp.h:983
uint64_t seqctr
Definition qstp.h:982
qsc_socket target
Definition qstp.h:980
uint64_t etime
Definition qstp.h:981
The QSTP network packet structure.
Definition qstp.h:1065
uint8_t * pmessage
Definition qstp.h:1070
uint32_t msglen
Definition qstp.h:1067
uint64_t utctime
Definition qstp.h:1069
uint64_t sequence
Definition qstp.h:1068
uint8_t flag
Definition qstp.h:1066
The root certificate structure.
Definition qstp.h:1031
uint8_t verkey[QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE]
Definition qstp.h:1032
char issuer[QSTP_CERTIFICATE_ISSUER_SIZE]
Definition qstp.h:1033
qstp_certificate_expiration expiration
Definition qstp.h:1035
uint8_t serial[QSTP_CERTIFICATE_SERIAL_SIZE]
Definition qstp.h:1034
qstp_version_sets version
Definition qstp.h:1037
qstp_configuration_sets algorithm
Definition qstp.h:1036
The QSTP root key structure.
Definition qstp.h:1048
uint8_t verkey[QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE]
Definition qstp.h:1052
uint8_t sigkey[QSTP_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition qstp.h:1051
char issuer[QSTP_CERTIFICATE_ISSUER_SIZE]
Definition qstp.h:1049
qstp_certificate_expiration expiration
Definition qstp.h:1053
uint8_t serial[QSTP_CERTIFICATE_SERIAL_SIZE]
Definition qstp.h:1050
qstp_version_sets version
Definition qstp.h:1055
qstp_configuration_sets algorithm
Definition qstp.h:1054
The server certificate structure.
Definition qstp.h:994
uint8_t verkey[QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE]
Definition qstp.h:999
uint8_t csig[QSTP_CERTIFICATE_SIGNED_HASH_SIZE]
Definition qstp.h:995
char issuer[QSTP_CERTIFICATE_ISSUER_SIZE]
Definition qstp.h:996
uint8_t rootser[QSTP_CERTIFICATE_SERIAL_SIZE]
Definition qstp.h:997
qstp_certificate_expiration expiration
Definition qstp.h:1000
uint8_t serial[QSTP_CERTIFICATE_SERIAL_SIZE]
Definition qstp.h:998
qstp_version_sets version
Definition qstp.h:1002
qstp_configuration_sets algorithm
Definition qstp.h:1001
The QSTP server key structure.
Definition qstp.h:1013
uint8_t verkey[QSTP_ASYMMETRIC_VERIFICATION_KEY_SIZE]
Definition qstp.h:1018
uint8_t sigkey[QSTP_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition qstp.h:1017
char issuer[QSTP_CERTIFICATE_ISSUER_SIZE]
Definition qstp.h:1014
qstp_certificate_expiration expiration
Definition qstp.h:1019
uint8_t serial[QSTP_CERTIFICATE_SERIAL_SIZE]
Definition qstp.h:1016
qstp_version_sets version
Definition qstp.h:1021
uint8_t schash[QSTP_CERTIFICATE_HASH_SIZE]
Definition qstp.h:1015
qstp_configuration_sets algorithm
Definition qstp.h:1020