91#define DKTP_CONFIG_DILITHIUM_KYBER
105#include "dktpcommon.h"
106#include "socketbase.h"
108#if defined(DKTP_CONFIG_DILITHIUM_KYBER)
109# include "dilithium.h"
111#elif defined(DKTP_CONFIG_DILITHIUM_MCELIECE)
112# include "dilithium.h"
113# include "mceliece.h"
114#elif defined(DKTP_CONFIG_SPHINCS_MCELIECE)
115# include "sphincsplus.h"
116# include "mceliece.h"
118# error Invalid parameter set!
126#define DKTP_DOMAIN_IDENTITY_SIZE 16U
142#define DKTP_ASYMMETRIC_RATCHET
148#define DKTP_CONFIG_SIZE 48U
154#define DKTP_HASH_SIZE 64U
160#define DKTP_MACKEY_SIZE 64U
166#define DKTP_MACTAG_SIZE 64U
172#define DKTP_SYMMETRIC_KEY_SIZE 64U
178#define DKTP_SYMMETRIC_NONCE_SIZE 32U
184#define DKTP_ASYMMETRIC_KEYCHAIN_COUNT 10U
190#define DKTP_CLIENT_PORT 31118U
196#define DKTP_CONNECTIONS_INIT 1000U
205#define DKTP_CONNECTIONS_MAX 50000U
211#define DKTP_CONNECTION_MTU 1500U
217#define DKTP_ERROR_SEQUENCE 0xFF00000000000000ULL
223#define DKTP_ERROR_MESSAGE_SIZE 1U
229#define DKTP_FLAG_SIZE 1U
235#define DKTP_HEADER_SIZE 21U
241#define DKTP_KEEPALIVE_STRING 20U
247#define DKTP_KEEPALIVE_TIMEOUT (120U * 1000U)
253#define DKTP_KEYID_SIZE 16U
259#define DKTP_MSGLEN_SIZE 4U
265#define DKTP_NONCE_SIZE 32U
271#define DKTP_SERVER_PORT 31119U
280#define DKTP_PACKET_TIME_THRESHOLD 60U
286#define DKTP_POLLING_INTERVAL (120U * 1000U)
292#define DKTP_PUBKEY_DURATION_DAYS 365U
298#define DKTP_PUBKEY_DURATION_SECONDS (DKTP_PUBKEY_DURATION_DAYS * 24U * 60U * 60U)
304#define DKTP_PUBKEY_LINE_LENGTH 64U
310#define DKTP_SECRET_SIZE 32U
316#define DKTP_SEQUENCE_SIZE 8U
322#define DKTP_SEQUENCE_TERMINATOR 0xFFFFFFFFUL
328#define DKTP_TIMESTAMP_SIZE 8U
334#define DKTP_TIMESTAMP_STRING_SIZE 20U
340#define DKTP_MESSAGE_MAX 0x3D090000UL
342#if defined(DKTP_CONFIG_DILITHIUM_KYBER)
348# define dktp_cipher_generate_keypair qsc_kyber_generate_keypair
353# define dktp_cipher_decapsulate qsc_kyber_decapsulate
358# define dktp_cipher_encapsulate qsc_kyber_encapsulate
363# define dktp_signature_generate_keypair qsc_dilithium_generate_keypair
368# define dktp_signature_sign qsc_dilithium_sign
373# define dktp_signature_verify qsc_dilithium_verify
376# if defined(QSC_DILITHIUM_S1P44) && defined(QSC_KYBER_S1K2P512)
377static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s1_kyber-s1_sha3_rcs";
378# elif defined(QSC_DILITHIUM_S3P65) && defined(QSC_KYBER_S3K3P768)
379static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s3_kyber-s3_sha3_rcs";
380# elif defined(QSC_DILITHIUM_S5P87) && defined(QSC_KYBER_S5K4P1024)
381static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s5_kyber-s5_sha3_rcs";
382# elif defined(QSC_DILITHIUM_S5P87) && defined(QSC_KYBER_S6K5P1280)
383static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s5_kyber-s6_sha3_rcs";
385# error Invalid parameter set!
393# define DKTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_KYBER_CIPHERTEXT_SIZE)
399# define DKTP_ASYMMETRIC_DECAPSULATION_KEY_SIZE (QSC_KYBER_PRIVATEKEY_SIZE)
405# define DKTP_ASYMMETRIC_ENCAPSULATION_KEY_SIZE (QSC_KYBER_PUBLICKEY_SIZE)
411# define DKTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
417# define DKTP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
423# define DKTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
425#elif defined(DKTP_CONFIG_DILITHIUM_MCELIECE)
430# define dktp_cipher_generate_keypair qsc_mceliece_generate_keypair
435# define dktp_cipher_decapsulate qsc_mceliece_decapsulate
440# define dktp_cipher_encapsulate qsc_mceliece_encapsulate
445# define dktp_signature_generate_keypair qsc_dilithium_generate_keypair
450# define dktp_signature_sign qsc_dilithium_sign
455# define dktp_signature_verify qsc_dilithium_verify
458# if defined(QSC_DILITHIUM_S1P44) && defined(QSC_MCELIECE_S1N3488T64)
459static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s1_mceliece-s1_sha3_rcs";
460# elif defined(QSC_DILITHIUM_S3P65) && defined(QSC_MCELIECE_S3N4608T96)
461static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s3_mceliece-s3_sha3_rcs";
462# elif defined(QSC_DILITHIUM_S5P87) && defined(QSC_MCELIECE_S5N6688T128)
463static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s5_sha3_rcs";
464# elif defined(QSC_DILITHIUM_S5P87) && defined(QSC_MCELIECE_S6N6960T119)
465static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s6_sha3_rcs";
466# elif defined(QSC_DILITHIUM_S5P87) && defined(QSC_MCELIECE_S7N8192T128)
467static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"dilithium-s5_mceliece-s7_sha3_rcs";
469# error Invalid parameter set!
477# define DKTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
483# define DKTP_ASYMMETRIC_DECAPSULATION_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
489# define DKTP_ASYMMETRIC_ENCAPSULATION_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
495# define DKTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_DILITHIUM_PRIVATEKEY_SIZE)
501# define DKTP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_DILITHIUM_PUBLICKEY_SIZE)
507# define DKTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_DILITHIUM_SIGNATURE_SIZE)
509#elif defined(DKTP_CONFIG_SPHINCS_MCELIECE)
515# define dktp_cipher_generate_keypair qsc_mceliece_generate_keypair
520# define dktp_cipher_decapsulate qsc_mceliece_decapsulate
525# define dktp_cipher_encapsulate qsc_mceliece_encapsulate
530# define dktp_signature_generate_keypair qsc_sphincsplus_generate_keypair
535# define dktp_signature_sign qsc_sphincsplus_sign
540# define dktp_signature_verify qsc_sphincsplus_verify
543# if defined(QSC_SPHINCSPLUS_S1S128SHAKERF) && defined(QSC_MCELIECE_S1N3488T64)
544static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s1f_mceliece-s1_sha3_rcs";
545# elif defined(QSC_SPHINCSPLUS_S1S128SHAKERS) && defined(QSC_MCELIECE_S1N3488T64)
546static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s1s_mceliece-s1_sha3_rcs";
547# elif defined(QSC_SPHINCSPLUS_S3S192SHAKERF) && defined(QSC_MCELIECE_S3N4608T96)
548static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-3f_mceliece-s3_sha3_rcs";
549# elif defined(QSC_SPHINCSPLUS_S3S192SHAKERS) && defined(QSC_MCELIECE_S3N4608T96)
550static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-3s_mceliece-s3_sha3_rcs";
551# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S5N6688T128)
552static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s5_sha3_rcs";
553# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S5N6688T128)
554static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s5_sha3_rcs";
555# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S6N6960T119)
556static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s6_sha3_rcs";
557# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S6N6960T119)
558static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s6_sha3_rcs";
559# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF) && defined(QSC_MCELIECE_S7N8192T128)
560static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5f_mceliece-s7_sha3_rcs";
561# elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS) && defined(QSC_MCELIECE_S7N8192T128)
562static const char DKTP_CONFIG_STRING[
DKTP_CONFIG_SIZE] =
"sphincs-s5s_mceliece-s7_sha3_rcs";
564# error Invalid parameter set!
572# define DKTP_ASYMMETRIC_CIPHER_TEXT_SIZE (QSC_MCELIECE_CIPHERTEXT_SIZE)
578# define DKTP_ASYMMETRIC_DECAPSULATION_KEY_SIZE (QSC_MCELIECE_PRIVATEKEY_SIZE)
584# define DKTP_ASYMMETRIC_ENCAPSULATION_KEY_SIZE (QSC_MCELIECE_PUBLICKEY_SIZE)
590# define DKTP_ASYMMETRIC_SIGNING_KEY_SIZE (QSC_SPHINCSPLUS_PRIVATEKEY_SIZE)
596# define DKTP_ASYMMETRIC_VERIFY_KEY_SIZE (QSC_SPHINCSPLUS_PUBLICKEY_SIZE)
602# define DKTP_ASYMMETRIC_SIGNATURE_SIZE (QSC_SPHINCSPLUS_SIGNATURE_SIZE)
605# error invalid parameter set!
614#define DKTP_REMOTE_PEER_KEY_ENCODED_SIZE (DKTP_KEYID_SIZE + DKTP_TIMESTAMP_SIZE + DKTP_CONFIG_SIZE + DKTP_SECRET_SIZE + DKTP_ASYMMETRIC_VERIFY_KEY_SIZE)
620#define DKTP_LOCAL_PEER_KEY_ENCODED_SIZE (DKTP_KEYID_SIZE + DKTP_KEYID_SIZE + DKTP_TIMESTAMP_SIZE + DKTP_CONFIG_SIZE + DKTP_SECRET_SIZE + DKTP_ASYMMETRIC_SIGNING_KEY_SIZE + DKTP_ASYMMETRIC_VERIFY_KEY_SIZE)
628#define DKTP_ERROR_STRING_DEPTH 30U
634#define DKTP_ERROR_STRING_WIDTH 128U
639 "No error was detected",
640 "The socket accept function returned an error",
641 "The symmetric cipher had an authentication failure",
642 "The keep alive check failed",
643 "The communications channel has failed",
644 "The device could not make a connection to the remote host",
645 "The transmission failed at the KEX connection phase",
646 "The asymmetric cipher failed to decapsulate the shared secret",
647 "The decryption authentication has failed",
648 "The transmission failed at the KEX establish phase",
649 "The transmission failed at the KEX exchange phase",
650 "The public - key hash is invalid",
651 "The server has run out of socket connections",
652 "The expected input was invalid",
653 "The packet flag was unexpected",
654 "The keep alive has expired with no response",
655 "The decryption authentication has failed",
656 "The DKTP public key has expired ",
657 "The key identity is unrecognized",
658 "The ratchet operation has failed",
659 "The listener function failed to initialize",
660 "The server has run out of memory",
661 "The packet has valid time expired",
662 "The packet was received out of sequence",
663 "The random generator has failed",
664 "The receiver failed at the network layer",
665 "The transmitter failed at the network layer",
666 "The protocol string was not recognized",
667 "The expected data could not be verified",
668 "The remote peer key identity does not match the local key",
676#define DKTP_MESSAGE_STRING_DEPTH 21U
681#define DKTP_MESSAGE_STRING_WIDTH 128U
686 "The operation completed succesfully.",
687 "The socket server accept function failed.",
688 "The listener socket listener could not connect.",
689 "The listener socket could not bind to the address.",
690 "The listener socket could not be created.",
691 "The server is connected to remote host: ",
692 "The socket receive function failed.",
693 "The server had a memory allocation failure.",
694 "The key exchange has experienced a failure.",
695 "The server has disconnected from the remote host: ",
696 "The server has disconnected the client due to an error",
697 "The server has had a socket level error: ",
698 "The server has reached the maximum number of connections",
699 "The server listener socket has failed.",
700 "The server has run out of socket connections",
701 "The message decryption has failed",
702 "The keepalive function has failed",
703 "The keepalive period has been exceeded",
704 "The connection failed or was interrupted",
705 "The function received an invalid request",
706 "The remote peer identity does not match the local key",
906#if defined(DKTP_ASYMMETRIC_RATCHET)
#define DKTP_REMOTE_PEER_KEY_ENCODED_SIZE
The peer key size.
Definition dktp.h:614
#define DKTP_ERROR_STRING_DEPTH
The depth of the DKTP error string array.
Definition dktp.h:628
DKTP_EXPORT_API void dktp_generate_keypair(dktp_remote_peer_key *enckey, dktp_local_peer_key *deckey, const uint8_t keyid[DKTP_KEYID_SIZE])
Generate a DKTP key-pair; generates the public and private asymmetric signature keys.
Definition dktp.c:180
DKTP_EXPORT_API void dktp_packet_clear(dktp_network_packet *packet)
Clear a packet's state.
Definition dktp.c:297
#define DKTP_ASYMMETRIC_SIGNING_KEY_SIZE
The byte size of the asymmetric signature signing-key array.
Definition dktp.h:411
#define DKTP_DOMAIN_IDENTITY_SIZE
The size of the domain identity string. This string size can be modified to accomodate different leng...
Definition dktp.h:126
DKTP_EXPORT_API dktp_errors dktp_packet_decrypt(dktp_connection_state *cns, uint8_t *message, size_t *msglen, const dktp_network_packet *packetin)
Decrypt a message and copy it to the message output.
Definition dktp.c:310
DKTP_EXPORT_API void dktp_connection_close(dktp_connection_state *cns, dktp_errors err, bool notify)
Close the network connection between hosts.
Definition dktp.c:11
DKTP_EXPORT_API bool dktp_packet_time_valid(const dktp_network_packet *packet)
Checks the local UTC seconds time against the packet sent time for validity within the packet time th...
Definition dktp.c:463
DKTP_EXPORT_API void dktp_local_peer_key_serialize(uint8_t slpk[DKTP_LOCAL_PEER_KEY_ENCODED_SIZE], const dktp_local_peer_key *lpk)
Serialize a local peer key structure.
Definition dktp.c:504
#define DKTP_CONFIG_SIZE
The size of the protocol configuration string.
Definition dktp.h:148
DKTP_EXPORT_API void dktp_log_message(dktp_messages emsg)
Log a message.
Definition dktp.c:260
DKTP_EXPORT_API void dktp_packet_set_utc_time(dktp_network_packet *packet)
Sets the local UTC seconds time in the packet header.
Definition dktp.c:458
#define DKTP_LOCAL_PEER_KEY_ENCODED_SIZE
The secret signature key size.
Definition dktp.h:620
DKTP_EXPORT_API bool dktp_remote_peer_key_compare(const dktp_remote_peer_key *a, const dktp_remote_peer_key *b)
Compares two public keys for equality.
Definition dktp.c:525
dktp_flags
The DKTP packet flags.
Definition dktp.h:798
@ dktp_flag_establish_response
Definition dktp.h:809
@ dktp_flag_session_establish_verify
Definition dktp.h:815
@ dktp_flag_unrecognized_protocol
Definition dktp.h:816
@ dktp_flag_establish_request
Definition dktp.h:808
@ dktp_flag_exchange_response
Definition dktp.h:807
@ dktp_flag_keep_alive_request
Definition dktp.h:810
@ dktp_flag_keep_alive_response
Definition dktp.h:811
@ dktp_flag_encrypted_message
Definition dktp.h:803
@ dktp_flag_asymmetric_ratchet_response
Definition dktp.h:818
@ dktp_flag_none
Definition dktp.h:799
@ dktp_flag_exstart_request
Definition dktp.h:804
@ dktp_flag_error_condition
Definition dktp.h:821
@ dktp_flag_connect_response
Definition dktp.h:801
@ dktp_flag_remote_connected
Definition dktp.h:812
@ dktp_flag_transfer_request
Definition dktp.h:820
@ dktp_flag_exchange_request
Definition dktp.h:806
@ dktp_flag_remote_terminated
Definition dktp.h:813
@ dktp_flag_connect_request
Definition dktp.h:800
@ dktp_flag_asymmetric_ratchet_request
Definition dktp.h:817
@ dktp_flag_session_established
Definition dktp.h:814
@ dktp_flag_connection_terminate
Definition dktp.h:802
@ dktp_flag_symmetric_ratchet_request
Definition dktp.h:819
@ dktp_flag_exstart_response
Definition dktp.h:805
DKTP_EXPORT_API const char * dktp_error_to_string(dktp_errors error)
Return a pointer to a string description of an error code.
Definition dktp.c:105
DKTP_EXPORT_API void dktp_connection_state_dispose(dktp_connection_state *cns)
Reset the connection state.
Definition dktp.c:80
#define DKTP_MESSAGE_STRING_DEPTH
The depth of the DKTP message string array.
Definition dktp.h:676
DKTP_EXPORT_API void dktp_local_peer_key_erase(dktp_local_peer_key *lpk)
Erase a local peer key.
Definition dktp.c:493
DKTP_EXPORT_API size_t dktp_packet_to_stream(const dktp_network_packet *packet, uint8_t *pstream)
Serialize a packet to a byte array.
Definition dktp.c:612
#define DKTP_MESSAGE_STRING_WIDTH
The width of each DKTP message string.
Definition dktp.h:681
DKTP_EXPORT_API void dktp_header_create(dktp_network_packet *packetout, dktp_flags flag, uint64_t sequence, uint32_t msglen)
Populate a packet header and set the creation time.
Definition dktp.c:119
dktp_messages
The logging message enumeration.
Definition dktp.h:731
@ dktp_messages_connect_success
Definition dktp.h:737
@ dktp_messages_peer_key_mismatch
Definition dktp.h:752
@ dktp_messages_keepalive_fail
Definition dktp.h:748
@ dktp_messages_listen_fail
Definition dktp.h:734
@ dktp_messages_connection_fail
Definition dktp.h:750
@ dktp_messages_queue_empty
Definition dktp.h:744
@ dktp_messages_listener_fail
Definition dktp.h:745
@ dktp_messages_socket_message
Definition dktp.h:743
@ dktp_messages_none
Definition dktp.h:732
@ dktp_messages_create_fail
Definition dktp.h:736
@ dktp_messages_kex_fail
Definition dktp.h:740
@ dktp_messages_disconnect_fail
Definition dktp.h:742
@ dktp_messages_decryption_fail
Definition dktp.h:747
@ dktp_messages_bind_fail
Definition dktp.h:735
@ dktp_messages_allocate_fail
Definition dktp.h:739
@ dktp_messages_accept_fail
Definition dktp.h:733
@ dktp_messages_sockalloc_fail
Definition dktp.h:746
@ dktp_messages_keepalive_timeout
Definition dktp.h:749
@ dktp_messages_receive_fail
Definition dktp.h:738
@ dktp_messages_invalid_request
Definition dktp.h:751
@ dktp_messages_disconnect
Definition dktp.h:741
DKTP_EXPORT_API dktp_errors dktp_header_validate(dktp_connection_state *cns, const dktp_network_packet *packetin, dktp_flags kexflag, dktp_flags pktflag, uint64_t sequence, uint32_t msglen)
Validate a packet header and timestamp.
Definition dktp.c:128
#define DKTP_SECRET_SIZE
The size of the shared secret for each channel.
Definition dktp.h:310
dktp_errors
The DKTP error values.
Definition dktp.h:760
@ dktp_error_none
Definition dktp.h:761
@ dktp_error_transmit_failure
Definition dktp.h:787
@ dktp_error_hash_invalid
Definition dktp.h:772
@ dktp_error_key_unrecognized
Definition dktp.h:779
@ dktp_error_decapsulation_failure
Definition dktp.h:768
@ dktp_error_receive_failure
Definition dktp.h:786
@ dktp_error_memory_allocation
Definition dktp.h:782
@ dktp_error_decryption_failure
Definition dktp.h:769
@ dktp_error_exchange_failure
Definition dktp.h:771
@ dktp_error_unknown_protocol
Definition dktp.h:788
@ dktp_error_peer_key_mismatch
Definition dktp.h:790
@ dktp_error_random_failure
Definition dktp.h:785
@ dktp_error_keychain_fail
Definition dktp.h:780
@ dktp_error_verify_failure
Definition dktp.h:789
@ dktp_error_packet_unsequenced
Definition dktp.h:784
@ dktp_error_invalid_input
Definition dktp.h:774
@ dktp_error_invalid_request
Definition dktp.h:775
@ dktp_error_accept_fail
Definition dktp.h:762
@ dktp_error_hosts_exceeded
Definition dktp.h:773
@ dktp_error_message_time_invalid
Definition dktp.h:783
@ dktp_error_bad_keep_alive
Definition dktp.h:764
@ dktp_error_establish_failure
Definition dktp.h:770
@ dktp_error_keepalive_expired
Definition dktp.h:776
@ dktp_error_connection_failure
Definition dktp.h:766
@ dktp_error_authentication_failure
Definition dktp.h:763
@ dktp_error_keepalive_timeout
Definition dktp.h:777
@ dktp_error_connect_failure
Definition dktp.h:767
@ dktp_error_listener_fail
Definition dktp.h:781
@ dktp_error_channel_down
Definition dktp.h:765
@ dktp_error_key_expired
Definition dktp.h:778
DKTP_EXPORT_API void dktp_packet_error_message(dktp_network_packet *packet, dktp_errors error)
Populate a packet structure with an error message.
Definition dktp.c:406
DKTP_EXPORT_API void dktp_local_peer_key_deserialize(dktp_local_peer_key *lpk, const uint8_t slpk[DKTP_LOCAL_PEER_KEY_ENCODED_SIZE])
Deserialize a local peer key structure and copy to an array.
Definition dktp.c:472
#define DKTP_ASYMMETRIC_VERIFY_KEY_SIZE
The byte size of the asymmetric signature verification-key array.
Definition dktp.h:417
DKTP_EXPORT_API void dktp_remote_peer_key_deserialize(dktp_remote_peer_key *rpk, const uint8_t srpk[DKTP_REMOTE_PEER_KEY_ENCODED_SIZE])
Deserialize a remote peer key and populate a remote peer key structure.
Definition dktp.c:548
DKTP_EXPORT_API void dktp_remote_peer_key_serialize(uint8_t srpk[DKTP_REMOTE_PEER_KEY_ENCODED_SIZE], const dktp_remote_peer_key *rpk)
Serialize a remote peer key structure and copy to an array.
Definition dktp.c:574
DKTP_EXPORT_API void dktp_packet_header_serialize(const dktp_network_packet *packet, uint8_t *header)
Serialize a packet header to a byte array.
Definition dktp.c:439
#define DKTP_ASYMMETRIC_ENCAPSULATION_KEY_SIZE
The byte size of the asymmetric cipher public-key array.
Definition dktp.h:405
DKTP_EXPORT_API const char * dktp_get_error_description(dktp_messages emsg)
Get the error string description.
Definition dktp.c:208
#define DKTP_ERROR_STRING_WIDTH
The width of each DKTP error string.
Definition dktp.h:634
DKTP_EXPORT_API void dktp_remote_peer_key_erase(dktp_remote_peer_key *rpk)
Erase a remote peer key.
Definition dktp.c:565
dktp_configuration
The asymmetric cryptographic primitive configuration.
Definition dktp.h:715
@ dktp_configuration_dilithium_ntru
Definition dktp.h:720
@ dktp_configuration_dilithium_kyber
Definition dktp.h:718
@ dktp_configuration_falcon_ntru
Definition dktp.h:723
@ dktp_configuration_falcon_kyber
Definition dktp.h:721
@ dktp_configuration_none
Definition dktp.h:716
@ dktp_configuration_falcon_mceliece
Definition dktp.h:722
@ dktp_configuration_dilithium_mceliece
Definition dktp.h:719
@ dktp_configuration_sphincs_mceliece
Definition dktp.h:717
DKTP_EXPORT_API void dktp_packet_header_deserialize(const uint8_t *header, dktp_network_packet *packet)
Deserialize a byte array to a packet header.
Definition dktp.c:420
DKTP_EXPORT_API void dktp_log_write(dktp_messages emsg, const char *msg)
Log a message and description.
Definition dktp.c:270
DKTP_EXPORT_API void dktp_stream_to_packet(const uint8_t *pstream, dktp_network_packet *packet)
Deserialize a byte array to a packet.
Definition dktp.c:591
DKTP_EXPORT_API dktp_errors dktp_packet_encrypt(dktp_connection_state *cns, dktp_network_packet *packetout, const uint8_t *message, size_t msglen)
Encrypt a message and build an output packet.
Definition dktp.c:369
#define DKTP_ASYMMETRIC_DECAPSULATION_KEY_SIZE
The byte size of the asymmetric cipher private-key array.
Definition dktp.h:399
DKTP_EXPORT_API void dktp_log_error(dktp_messages emsg, qsc_socket_exceptions err, const char *msg)
Log the message, socket error, and string description.
Definition dktp.c:223
#define DKTP_KEYID_SIZE
The DKTP key identity size.
Definition dktp.h:253
The DKTP asymmetric cipher key container.
Definition dktp.h:829
The DKTP asymmetric signature key container.
Definition dktp.h:839
The DKTP socket connection state structure.
Definition dktp.h:902
uint8_t enckey[DKTP_ASYMMETRIC_ENCAPSULATION_KEY_SIZE]
Definition dktp.h:908
uint64_t txseq
Definition dktp.h:915
dktp_flags exflag
Definition dktp.h:917
uint8_t pssr[DKTP_SECRET_SIZE]
Definition dktp.h:910
bool receiver
Definition dktp.h:918
qsc_rcs_state txcpr
Definition dktp.h:905
uint64_t rxseq
Definition dktp.h:914
uint8_t verkey[DKTP_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition dktp.h:912
uint8_t deckey[DKTP_ASYMMETRIC_DECAPSULATION_KEY_SIZE]
Definition dktp.h:907
uint8_t pssl[DKTP_SECRET_SIZE]
Definition dktp.h:909
uint8_t sigkey[DKTP_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition dktp.h:911
uint32_t cid
Definition dktp.h:916
qsc_socket target
Definition dktp.h:903
qsc_rcs_state rxcpr
Definition dktp.h:904
The DKTP keep alive state structure.
Definition dktp.h:890
bool recd
Definition dktp.h:894
uint64_t seqctr
Definition dktp.h:893
qsc_socket target
Definition dktp.h:891
uint64_t etime
Definition dktp.h:892
The DKTP server key structure.
Definition dktp.h:875
uint8_t peerid[DKTP_KEYID_SIZE]
Definition dktp.h:879
uint8_t pss[DKTP_SECRET_SIZE]
Definition dktp.h:880
uint64_t expiration
Definition dktp.h:876
uint8_t config[DKTP_CONFIG_SIZE]
Definition dktp.h:877
uint8_t keyid[DKTP_KEYID_SIZE]
Definition dktp.h:878
uint8_t verkey[DKTP_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition dktp.h:882
uint8_t sigkey[DKTP_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition dktp.h:881
The DKTP packet structure.
Definition dktp.h:849
uint8_t * pmessage
Definition dktp.h:854
uint32_t msglen
Definition dktp.h:851
uint64_t utctime
Definition dktp.h:853
uint64_t sequence
Definition dktp.h:852
uint8_t flag
Definition dktp.h:850
The DKTP client key structure.
Definition dktp.h:862
uint8_t pss[DKTP_SECRET_SIZE]
Definition dktp.h:866
uint64_t expiration
Definition dktp.h:863
uint8_t config[DKTP_CONFIG_SIZE]
Definition dktp.h:864
uint8_t keyid[DKTP_KEYID_SIZE]
Definition dktp.h:865
uint8_t verkey[DKTP_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition dktp.h:867