MPDC: Multi Party Domain Cryptosystem 1.0.0.0b (A0)
MPDC Interior protocol
mpdc.h File Reference

MPDC Common Definitions and Protocol Configuration. More...

#include "common.h"
#include "../../QSC/QSC/rcs.h"
#include "../../QSC/QSC/sha3.h"
#include "../../QSC/QSC/socketbase.h"
#include "../../QSC/QSC/dilithium.h"
#include "../../QSC/QSC/kyber.h"

Go to the source code of this file.

Data Structures

struct  mpdc_certificate_expiration
 The certificate expiration time structure. More...
 
struct  mpdc_child_certificate
 The child certificate structure. More...
 
struct  mpdc_idg_hint
 The IDG hint structure. More...
 
struct  mpdc_idg_certificate
 The IDG certificate structure. More...
 
struct  mpdc_connection_state
 The MPDC socket connection state structure. More...
 
struct  mpdc_keep_alive_state
 The MPDC keep alive state structure. More...
 
struct  mpdc_mfkey_state
 The MPDC master fragment key structure. More...
 
struct  mpdc_network_packet
 The MPDC packet structure. More...
 
struct  mpdc_root_certificate
 The root certificate structure. More...
 
struct  mpdc_serialized_symmetric_key
 The structure for a serialized symmetric key. More...
 
struct  mpdc_signature_keypair
 The MPDC asymmetric signature scheme key container. More...
 
struct  mpdc_cipher_keypair
 The MPDC asymmetric cipher key container. More...
 

Macros

#define mpdc_cipher_generate_keypair   qsc_kyber_generate_keypair
 MPDC function mapping macros.
 
#define mpdc_cipher_decapsulate   qsc_kyber_decapsulate
 Decapsulate a shared-secret with the asymmetric cipher.
 
#define mpdc_cipher_encapsulate   qsc_kyber_encapsulate
 Encapsulate a shared-secret with the asymmetric cipher.
 
#define mpdc_signature_generate_keypair   qsc_dilithium_generate_keypair
 Generate an asymmetric signature key-pair.
 
#define mpdc_signature_sign   qsc_dilithium_sign
 Sign a message with the asymmetric signature scheme.
 
#define mpdc_signature_verify   qsc_dilithium_verify
 Verify a message with the asymmetric signature scheme.
 
#define MPDC_ASYMMETRIC_CIPHERTEXT_SIZE   (QSC_KYBER_CIPHERTEXT_SIZE)
 The byte size of the asymmetric cipher-text array.
 
#define MPDC_ASYMMETRIC_PRIVATE_KEY_SIZE   (QSC_KYBER_PRIVATEKEY_SIZE)
 The byte size of the asymmetric cipher private-key array.
 
#define MPDC_ASYMMETRIC_PUBLIC_KEY_SIZE   (QSC_KYBER_PUBLICKEY_SIZE)
 The byte size of the asymmetric cipher public-key array.
 
#define MPDC_ASYMMETRIC_SIGNATURE_SIZE   (QSC_DILITHIUM_SIGNATURE_SIZE)
 The byte size of the asymmetric signature array.
 
#define MPDC_ASYMMETRIC_SIGNING_KEY_SIZE   (QSC_DILITHIUM_PRIVATEKEY_SIZE)
 The byte size of the asymmetric signature signing-key array.
 
#define MPDC_ASYMMETRIC_VERIFICATION_KEY_SIZE   (QSC_DILITHIUM_PUBLICKEY_SIZE)
 The byte size of the asymmetric signature verification-key array.
 
#define MPDC_CHILD_CERTIFICATE_STRING_SIZE   10311
 The encoded certificate string length.
 
#define MPDC_PARAMATERS_DILITHIUM_KYBER_D5K5
 The Dilithium D1K1 parameter set.
 
#define MPDC_ROOT_CERTIFICATE_STRING_SIZE   3919
 The root certificate encoded string size.
 
#define MPDC_SIGNATURE_ENCODING_SIZE   6172
 The encoded signature size.
 
#define MPDC_VERIFICATION_KEY_ENCODING_SIZE   3456
 The verification key size.
 
#define MPDC_ACTIVE_VERSION   1
 The MPDC active version.
 
#define MPDC_ACTIVE_VERSION_SIZE   2
 The MPDC active version size.
 
#define MPDC_APPLICATION_AGENT_PORT   37766
 The default Agent port number.
 
#define MPDC_AGENT_FULL_TRUST   1000001
 The full trust designation number.
 
#define MPDC_AGENT_MINIMUM_TRUST   1
 The minimum trust designation number.
 
#define MPDC_AGENT_NAME_MAX_SIZE   256
 The maximum agent name string length in characters. The last character must be a string terminator.
 
#define MPDC_AGENT_TWOWAY_TRUST   1000002
 The two-way trust designation number.
 
#define MPDC_APPLICATION_CLIENT_PORT   37761
 The default MPDC Client port number.
 
#define MPDC_APPLICATION_DLA_PORT   37762
 The default DLA port number.
 
#define MPDC_APPLICATION_IDG_PORT   37763
 The default MPDC IDG port number.
 
#define MPDC_APPLICATION_RDS_PORT   37764
 The default RDS port number.
 
#define MPDC_APPLICATION_MAS_PORT   37765
 The default MPDC MAS port number.
 
#define MPDC_CANONICAL_NAME_MINIMUM_SIZE   3
 The minimum canonical name size.
 
#define MPDC_CERTIFICATE_ADDRESS_SIZE   22
 The maximum IP address length.
 
#define MPDC_CERTIFICATE_ALGORITHM_SIZE   1
 The algorithm type.
 
#define MPDC_CERTIFICATE_DEFAULT_PERIOD   ((uint64_t)365 * 24 * 60 * 60)
 The default certificate validity period in milliseconds.
 
#define MPDC_CERTIFICATE_DESIGNATION_SIZE   1
 The size of the child certificate designation field.
 
#define MPDC_CERTIFICATE_EXPIRATION_SIZE   16
 The certificate expiration date length.
 
#define MPDC_CERTIFICATE_HASH_SIZE   32
 The size of the certificate hash in bytes.
 
#define MPDC_CERTIFICATE_ISSUER_SIZE   256
 The maximum certificate issuer string length. The last character must be a string terminator.
 
#define MPDC_CERTIFICATE_LINE_LENGTH   64
 The line length of the printed MPDC certificate.
 
#define MPDC_CERTIFICATE_MAXIMUM_PERIOD   (MPDC_CERTIFICATE_DEFAULT_PERIOD * 2)
 The maximum certificate validity period in milliseconds.
 
#define MPDC_CERTIFICATE_MINIMUM_PERIOD   ((uint64_t)1 * 24 * 60 * 60)
 The minimum certificate validity period in milliseconds.
 
#define MPDC_CERTIFICATE_SERIAL_SIZE   16
 The certificate serial number field length.
 
#define MPDC_CERTIFICATE_HINT_SIZE   (MPDC_CERTIFICATE_HASH_SIZE + MPDC_CERTIFICATE_SERIAL_SIZE)
 The topological hint.
 
#define MPDC_CERTIFICATE_SIGNED_HASH_SIZE   (MPDC_ASYMMETRIC_SIGNATURE_SIZE + MPDC_CERTIFICATE_HASH_SIZE)
 The size of the signature and hash field in a certificate.
 
#define MPDC_CERTIFICATE_VERSION_SIZE   1
 The version id.
 
#define MPDC_CERTIFICATE_CHILD_SIZE
 The length of a child certificate.
 
#define MPDC_CERTIFICATE_IDG_SIZE
 The length of an IDG certificate.
 
#define MPDC_CERTIFICATE_ROOT_SIZE
 The length of the root certificate.
 
#define MPDC_CRYPTO_SYMMETRIC_KEY_SIZE   32
 The byte length of the symmetric cipher key.
 
#define MPDC_CRYPTO_SYMMETRIC_NONCE_SIZE   32
 The byte length of the symmetric cipher nonce.
 
#define MPDC_CRYPTO_SEED_SIZE   64
 The seed array byte size.
 
#define MPDC_CRYPTO_SYMMETRIC_TOKEN_SIZE   32
 The byte length of the symmetric token.
 
#define MPDC_CRYPTO_SYMMETRIC_HASH_SIZE   32
 The hash function output byte size.
 
#define MPDC_CRYPTO_SYMMETRIC_MAC_SIZE   32
 The MAC function output byte size.
 
#define MPDC_CRYPTO_SYMMETRIC_SECRET_SIZE   32
 The shared secret byte size.
 
#define MPDC_CRYPTO_SYMMETRIC_SESSION_KEY_SIZE   32
 The session key security size.
 
#define MPDC_DLA_CONVERGENCE_INTERVAL   (60 * 60 * 24)
 The interval between agent convergence checks (default is 24 hours).
 
#define MPDC_DLA_IP_MAX   0x41
 The maximum ip address length.
 
#define MPDC_DLA_PENALTY_MAX   0x100
 The maximum unreachable penalty before the DLA is deemed unreliable.
 
#define MPDC_DLA_REDUCTION_INTERVAL   1000000
 The time before a penalty is reduced for a flapping DLA in milliseconds.
 
#define MPDC_DLA_UPDATE_WAIT_TIME   (7 * 24 * 60 * 60)
 The interval in milliseconds between topology full updates.
 
#define MPDC_ERROR_STRING_DEPTH   26
 The number of error strings.
 
#define MPDC_ERROR_STRING_WIDTH   128
 The maximum size in characters of an error string.
 
#define MPDC_MESSAGE_MAX_SIZE   1400000
 The maximum message size (max signature + max certificate sizes).
 
#define MPDC_MFK_EXPIRATION_PERIOD   ((uint64_t)60 * 24 * 60 * 60)
 The MFK validity period in milliseconds.
 
#define MPDC_MINIMUM_PATH_LENGTH   9
 The minimum file path length.
 
#define MPDC_NETWORK_CONNECTION_MTU   1500
 The MPDC packet buffer size.
 
#define MPDC_NETWORK_DOMAIN_NAME_MAX_SIZE   256
 The maximum domain name length in characters. The last character must be a string terminator.
 
#define MPDC_NETWORK_MAX_AGENTS   1000000
 The maximum number of agent connections in a network.
 
#define MPDC_NETWORK_NODE_ID_SIZE   16
 The node identification string length.
 
#define MPDC_PERIOD_DAY_TO_SECONDS   (24 * 60 * 60)
 A period of one day in seconds.
 
#define MPDC_SOCKET_TERMINATOR_SIZE   1
 The packet delimiter byte size.
 
#define MPDC_PACKET_ERROR_SIZE   1
 The packet error message byte size.
 
#define MPDC_PACKET_HEADER_SIZE   22
 The MPDC packet header size.
 
#define MPDC_PACKET_SUBHEADER_SIZE   16
 The MPDC packet sub-header size.
 
#define MPDC_PACKET_SEQUENCE_TERMINATOR   0xFFFFFFFFUL
 The sequence number of a packet that closes a connection.
 
#define MPDC_PACKET_TIME_SIZE   8
 The byte size of the serialized packet time parameter.
 
#define MPDC_PACKET_TIME_THRESHOLD   60
 The maximum number of seconds a packet is valid.
 
#define MPDC_NETWORK_TERMINATION_MESSAGE_SIZE   1
 The network termination message size.
 
#define MPDC_NETWORK_TERMINATION_PACKET_SIZE   (MPDC_PACKET_HEADER_SIZE + MPDC_NETWORK_TERMINATION_MESSAGE_SIZE)
 The network termination packet size.
 
#define MPDC_X509_CERTIFICATE_SIZE   4096
 x509 implementation where algorithm/signature output size is stored.
 
#define MPDC_IDG_HINT_SIZE   (MPDC_CERTIFICATE_HASH_SIZE + MPDC_CERTIFICATE_SERIAL_SIZE)
 Hint query; certificate hash, root serial number hi=(H(cert) | rsn) idg query asks if a peer knows of the root security server for a domain; if the peer does know the root of the other domain, it sends back information about that rds (address, certificate hash, root serial number, and trust metric).
 
#define MPDC_PROTOCOL_SET_SIZE   41
 The size of the protocol configuration string.
 
#define MPDC_NETWORK_ERROR_STRING_DEPTH   28
 
#define MPDC_NETWORK_ERROR_STRING_SIZE   128
 

Typedefs

typedef MPDC_EXPORT_API enum mpdc_configuration_sets mpdc_configuration_sets
 
typedef MPDC_EXPORT_API enum mpdc_network_designations mpdc_network_designations
 
typedef MPDC_EXPORT_API enum mpdc_network_errors mpdc_network_errors
 
typedef MPDC_EXPORT_API enum mpdc_network_flags mpdc_network_flags
 
typedef MPDC_EXPORT_API enum mpdc_protocol_errors mpdc_protocol_errors
 
typedef MPDC_EXPORT_API enum mpdc_version_sets mpdc_version_sets
 
typedef MPDC_EXPORT_API struct mpdc_certificate_expiration mpdc_certificate_expiration
 
typedef MPDC_EXPORT_API struct mpdc_child_certificate mpdc_child_certificate
 
typedef MPDC_EXPORT_API struct mpdc_idg_hint mpdc_idg_hint
 
typedef MPDC_EXPORT_API struct mpdc_idg_certificate mpdc_idg_certificate
 
typedef MPDC_EXPORT_API struct mpdc_connection_state mpdc_connection_state
 
typedef MPDC_EXPORT_API struct mpdc_keep_alive_state mpdc_keep_alive_state
 
typedef struct mpdc_mfkey_state mpdc_mfkey_state
 
typedef MPDC_EXPORT_API struct mpdc_network_packet mpdc_network_packet
 
typedef MPDC_EXPORT_API struct mpdc_root_certificate mpdc_root_certificate
 
typedef MPDC_EXPORT_API struct mpdc_serialized_symmetric_key mpdc_serialized_symmetric_key
 
typedef MPDC_EXPORT_API struct mpdc_signature_keypair mpdc_signature_keypair
 
typedef MPDC_EXPORT_API struct mpdc_cipher_keypair mpdc_cipher_keypair
 

Enumerations

enum  mpdc_configuration_sets {
  mpdc_configuration_set_none = 0x00 , mpdc_configuration_set_dilithium1_kyber1_rcs256_shake256 = 0x01 , mpdc_configuration_set_dilithium3_kyber3_rcs256_shake256 = 0x02 , mpdc_configuration_set_dilithium5_kyber5_rcs256_shake256 = 0x03 ,
  mpdc_configuration_set_dilithium5_kyber6_rcs512_shake256 = 0x04 , mpdc_configuration_set_sphincsplus1f_mceliece1_rcs256_shake256 = 0x05 , mpdc_configuration_set_sphincsplus1s_mceliece1_rcs256_shake256 = 0x06 , mpdc_configuration_set_sphincsplus3f_mceliece3_rcs256_shake256 = 0x07 ,
  mpdc_configuration_set_sphincsplus3s_mceliece3_rcs256_shake256 = 0x08 , mpdc_configuration_set_sphincsplus5f_mceliece5_rcs256_shake256 = 0x09 , mpdc_configuration_set_sphincsplus5s_mceliece5_rcs256_shake256 = 0x0A , mpdc_configuration_set_sphincsplus5f_mceliece6_rcs256_shake256 = 0x0B ,
  mpdc_configuration_set_sphincsplus5s_mceliece6_rcs256_shake256 = 0x0C , mpdc_configuration_set_sphincsplus5f_mceliece7_rcs256_shake256 = 0x0D , mpdc_configuration_set_sphincsplus5s_mceliece7_rcs256_shake256 = 0x0E
}
 The MPDC algorithm configuration sets. More...
 
enum  mpdc_network_designations {
  mpdc_network_designation_none = 0x00 , mpdc_network_designation_agent = 0x01 , mpdc_network_designation_client = 0x02 , mpdc_network_designation_dla = 0x03 ,
  mpdc_network_designation_idg = 0x04 , mpdc_network_designation_mas = 0x05 , mpdc_network_designation_remote = 0x06 , mpdc_network_designation_rds = 0x07 ,
  mpdc_network_designation_revoked = 0x08 , mpdc_network_designation_all = 0xFF
}
 The MPDC device designation. More...
 
enum  mpdc_network_errors {
  mpdc_network_error_none = 0x00 , mpdc_network_error_accept_fail = 0x01 , mpdc_network_error_auth_failure = 0x02 , mpdc_network_error_bad_keep_alive = 0x03 ,
  mpdc_network_error_channel_down = 0x04 , mpdc_network_error_connection_failure = 0x05 , mpdc_network_error_decryption_failure = 0x06 , mpdc_network_error_establish_failure = 0x07 ,
  mpdc_network_error_general_failure = 0x08 , mpdc_network_error_hosts_exceeded = 0x09 , mpdc_network_error_identity_unknown = 0x10 , mpdc_network_error_invalid_input = 0x1A ,
  mpdc_network_error_invalid_request = 0x1B , mpdc_network_error_keep_alive_expired = 0x1C , mpdc_network_error_keep_alive_timeout = 0x1D , mpdc_network_error_kex_auth_failure = 0x1E ,
  mpdc_network_error_key_not_recognized = 0x1F , mpdc_network_error_key_has_expired = 0x20 , mpdc_network_error_listener_fail = 0x21 , mpdc_network_error_memory_allocation = 0x22 ,
  mpdc_network_error_packet_unsequenced = 0x23 , mpdc_network_error_random_failure = 0x24 , mpdc_network_error_ratchet_fail = 0x25 , mpdc_network_error_receive_failure = 0x26 ,
  mpdc_network_error_transmit_failure = 0x27 , mpdc_network_error_unknown_protocol = 0x28 , mpdc_network_error_unsequenced = 0x29 , mpdc_network_error_verify_failure = 0x2A
}
 The MPDC network error values. More...
 
enum  mpdc_network_flags {
  mpdc_network_flag_none = 0x00 , mpdc_network_flag_connection_terminate_request = 0x01 , mpdc_network_flag_error_condition = 0x02 , mpdc_network_flag_fragment_collection_request = 0x03 ,
  mpdc_network_flag_fragment_collection_response = 0x04 , mpdc_network_flag_fragment_request = 0x05 , mpdc_network_flag_fragment_response = 0x06 , mpdc_network_flag_fragment_query_request = 0x07 ,
  mpdc_network_flag_fragment_query_response = 0x08 , mpdc_network_flag_incremental_update_request = 0x09 , mpdc_network_flag_incremental_update_response = 0x0A , mpdc_network_flag_register_request = 0x0B ,
  mpdc_network_flag_register_response = 0x0C , mpdc_network_flag_register_update_request = 0x0D , mpdc_network_flag_register_update_response = 0x0E , mpdc_network_flag_keep_alive_request = 0x0F ,
  mpdc_network_flag_keep_alive_response = 0x10 , mpdc_network_flag_mfk_establish = 0x11 , mpdc_network_flag_mfk_request = 0x12 , mpdc_network_flag_mfk_response = 0x13 ,
  mpdc_network_flag_mfk_verify = 0x14 , mpdc_network_flag_network_announce_broadcast = 0x15 , mpdc_network_flag_network_converge_request = 0x16 , mpdc_network_flag_network_converge_response = 0x17 ,
  mpdc_network_flag_network_converge_update = 0x18 , mpdc_network_flag_network_resign_request = 0x19 , mpdc_network_flag_network_resign_response = 0x1A , mpdc_network_flag_network_revocation_broadcast = 0x1B ,
  mpdc_network_flag_network_signature_request = 0x1C , mpdc_network_flag_system_error_condition = 0x1D , mpdc_network_flag_tunnel_connection_terminate = 0x1E , mpdc_network_flag_tunnel_encrypted_message = 0x1F ,
  mpdc_network_flag_tunnel_session_established = 0x20 , mpdc_network_flag_tunnel_transfer_request = 0x21 , mpdc_network_flag_topology_query_request = 0x22 , mpdc_network_flag_topology_query_response = 0x23 ,
  mpdc_network_flag_topology_status_request = 0x24 , mpdc_network_flag_topology_status_response = 0x25 , mpdc_network_flag_topology_status_available = 0x26 , mpdc_network_flag_topology_status_synchronized = 0x27 ,
  mpdc_network_flag_topology_status_unavailable = 0x28 , mpdc_network_flag_network_remote_signing_request = 0x29 , mpdc_network_flag_network_remote_signing_response = 0x2A
}
 The MPDC network flags. More...
 
enum  mpdc_protocol_errors {
  mpdc_protocol_error_none = 0x00 , mpdc_protocol_error_authentication_failure = 0x01 , mpdc_protocol_error_certificate_not_found = 0x02 , mpdc_protocol_error_channel_down = 0x03 ,
  mpdc_protocol_error_connection_failure = 0x04 , mpdc_protocol_error_connect_failure = 0x05 , mpdc_protocol_error_convergence_failure = 0x06 , mpdc_protocol_error_convergence_synchronized = 0x07 ,
  mpdc_protocol_error_decapsulation_failure = 0x08 , mpdc_protocol_error_decoding_failure = 0x09 , mpdc_protocol_error_decryption_failure = 0x0A , mpdc_protocol_error_establish_failure = 0x0B ,
  mpdc_protocol_error_exchange_failure = 0x0C , mpdc_protocol_error_file_not_deleted = 0x0D , mpdc_protocol_error_file_not_found = 0x0E , mpdc_protocol_error_file_not_written = 0x0F ,
  mpdc_protocol_error_hash_invalid = 0x10 , mpdc_protocol_error_hosts_exceeded = 0x11 , mpdc_protocol_error_invalid_request = 0x12 , mpdc_protocol_error_certificate_expired = 0x13 ,
  mpdc_protocol_error_key_expired = 0x14 , mpdc_protocol_error_key_unrecognized = 0x15 , mpdc_protocol_error_listener_fail = 0x16 , mpdc_protocol_error_memory_allocation = 0x17 ,
  mpdc_protocol_error_message_time_invalid = 0x18 , mpdc_protocol_error_message_verification_failure = 0x19 , mpdc_protocol_error_no_usable_address = 0x1A , mpdc_protocol_error_node_not_available = 0x1B ,
  mpdc_protocol_error_node_not_found = 0x1C , mpdc_protocol_error_node_was_registered = 0x1D , mpdc_protocol_error_operation_cancelled = 0x1E , mpdc_protocol_error_packet_header_invalid = 0x1F ,
  mpdc_protocol_error_packet_unsequenced = 0x20 , mpdc_protocol_error_receive_failure = 0x21 , mpdc_protocol_error_root_signature_invalid = 0x22 , mpdc_protocol_error_serialization_failure = 0x23 ,
  mpdc_protocol_error_signature_failure = 0x24 , mpdc_protocol_error_signing_failure = 0x25 , mpdc_protocol_error_socket_binding = 0x26 , mpdc_protocol_error_socket_creation = 0x27 ,
  mpdc_protocol_error_transmit_failure = 0x28 , mpdc_protocol_error_topology_no_agent = 0x29 , mpdc_protocol_error_unknown_protocol = 0x2A , mpdc_protocol_error_verification_failure = 0x2B
}
 The MPDC protocol error values. More...
 
enum  mpdc_version_sets { mpdc_version_set_none = 0x00 , mpdc_version_set_one_zero = 0x01 }
 The MPDC version sets. More...
 

Functions

MPDC_EXPORT_API void mpdc_connection_close (qsc_socket *rsock, mpdc_network_errors err, bool notify)
 Close the network connection between hosts.
 
MPDC_EXPORT_API mpdc_network_errors mpdc_decrypt_packet (mpdc_connection_state *cns, uint8_t *message, size_t *msglen, const mpdc_network_packet *packetin)
 Decrypt a message and copy it to the output buffer.
 
MPDC_EXPORT_API mpdc_network_errors mpdc_encrypt_packet (mpdc_connection_state *cns, mpdc_network_packet *packetout, const uint8_t *message, size_t msglen)
 Encrypt a message and build an output packet.
 
MPDC_EXPORT_API void mpdc_connection_state_dispose (mpdc_connection_state *cns)
 Dispose of the tunnel connection state.
 
MPDC_EXPORT_API const char * mpdc_network_error_to_string (mpdc_network_errors error)
 Return a pointer to a string description of a network error code.
 
MPDC_EXPORT_API const char * mpdc_protocol_error_to_string (mpdc_protocol_errors error)
 Return a pointer to a string description of a protocol error code.
 
MPDC_EXPORT_API void mpdc_packet_clear (mpdc_network_packet *packet)
 Clear the state of a network packet.
 
MPDC_EXPORT_API void mpdc_packet_error_message (mpdc_network_packet *packet, mpdc_protocol_errors error)
 Populate a packet structure with an error message.
 
MPDC_EXPORT_API void mpdc_packet_header_deserialize (const uint8_t *header, mpdc_network_packet *packet)
 Deserialize a byte array into a packet header.
 
MPDC_EXPORT_API void mpdc_packet_header_serialize (const mpdc_network_packet *packet, uint8_t *header)
 Serialize a packet header into a byte array.
 
MPDC_EXPORT_API void mpdc_packet_set_utc_time (mpdc_network_packet *packet)
 Set the local UTC time in the packet header.
 
MPDC_EXPORT_API bool mpdc_packet_time_valid (const mpdc_network_packet *packet)
 Check if the packet's UTC time is within the valid time threshold.
 
MPDC_EXPORT_API size_t mpdc_packet_to_stream (const mpdc_network_packet *packet, uint8_t *pstream)
 Serialize a network packet to a byte stream.
 
MPDC_EXPORT_API void mpdc_stream_to_packet (const uint8_t *pstream, mpdc_network_packet *packet)
 Deserialize a byte stream into a network packet.
 

Detailed Description

MPDC Common Definitions and Protocol Configuration.

This header defines the common constants, macros, enumerations, structures, and function prototypes for the Multi-Party Domain Cryptosystem (MPDC). It provides configuration for the cryptographic parameter sets, certificate handling, network protocol operations, and socket communication required to implement the MPDC protocol.

The MPDC protocol leverages a combination of asymmetric cipher and signature schemes from the QSC library. The parameter sets can be configured in the QSC library's common.h file. For maximum security, the McEliece/SPHINCS+ parameter set is recommended; for a balance of performance and security, the Dilithium/Kyber parameter set is advised.

Key components defined in this header include:

  • Function Mapping Macros: Aliases that map MPDC high-level cryptographic operations (key generation, encapsulation/decapsulation, signing, and verification) to the corresponding functions in the QSC library, based on the selected configuration.
  • Modifiable Constants: Preprocessor definitions that enable or disable protocol features (e.g., client-to-client encrypted tunneling, master fragment key cycling, IPv6 networking, and extended session security).
  • Parameter Macros: Definitions for key sizes, certificate field sizes, network settings, and timing values that ensure consistency across the MPDC protocol implementation.
  • Enumerations: Enumerated types for MPDC configuration sets, network designations, network and protocol error codes, and version sets.
  • Structures: Data structures representing various certificates (child, IDG, root), connection and keep alive states, network packets, and cryptographic key pairs. These structures are central to protocol operations such as certificate management and secure message exchange.
  • Static Constants: Predefined strings for certificate header/footer information and network designation labels.
  • Public API Functions: Prototypes for functions handling connection management, packet encryption/decryption, packet serialization/deserialization, and error string conversion.
Note
When using the McEliece/SPHINCS+ configuration in Visual Studio, it is recommended to increase the maximum stack size (for example, to 200KB) to accommodate the larger key sizes.
Test
Although this header does not directly implement test routines, it underpins multiple test modules that validate:
  • The correct mapping of MPDC high-level function calls to the underlying QSC library routines.
  • The consistency and accuracy of defined constants (e.g., key sizes, certificate sizes, network parameters).
  • The proper serialization/deserialization of packet headers and full packets (via mpdc_packet_header_serialize and mpdc_stream_to_packet).
  • The correct conversion of error codes to descriptive strings (using mpdc_network_error_to_string and mpdc_protocol_error_to_string).

These tests collectively ensure the robustness, consistency, and security of the MPDC protocol configuration.

Macro Definition Documentation

◆ MPDC_CERTIFICATE_CHILD_SIZE

#define MPDC_CERTIFICATE_CHILD_SIZE
Value:
#define MPDC_CERTIFICATE_EXPIRATION_SIZE
The certificate expiration date length.
Definition mpdc.h:782
#define MPDC_ASYMMETRIC_VERIFICATION_KEY_SIZE
The byte size of the asymmetric signature verification-key array.
Definition mpdc.h:245
#define MPDC_CERTIFICATE_ISSUER_SIZE
The maximum certificate issuer string length. The last character must be a string terminator.
Definition mpdc.h:795
#define MPDC_CERTIFICATE_ALGORITHM_SIZE
The algorithm type.
Definition mpdc.h:764
#define MPDC_CERTIFICATE_DESIGNATION_SIZE
The size of the child certificate designation field.
Definition mpdc.h:776
#define MPDC_CERTIFICATE_VERSION_SIZE
The version id.
Definition mpdc.h:837
#define MPDC_CERTIFICATE_SERIAL_SIZE
The certificate serial number field length.
Definition mpdc.h:819
#define MPDC_CERTIFICATE_SIGNED_HASH_SIZE
The size of the signature and hash field in a certificate.
Definition mpdc.h:831

The length of a child certificate.

◆ MPDC_CERTIFICATE_IDG_SIZE

#define MPDC_CERTIFICATE_IDG_SIZE
Value:
#define MPDC_ASYMMETRIC_SIGNATURE_SIZE
The byte size of the asymmetric signature array.
Definition mpdc.h:233
#define MPDC_CERTIFICATE_ADDRESS_SIZE
The maximum IP address length.
Definition mpdc.h:758
#define MPDC_CERTIFICATE_HASH_SIZE
The size of the certificate hash in bytes.
Definition mpdc.h:788

The length of an IDG certificate.

◆ MPDC_CERTIFICATE_ROOT_SIZE

◆ mpdc_cipher_generate_keypair

#define mpdc_cipher_generate_keypair   qsc_kyber_generate_keypair

MPDC function mapping macros.

These macros alias the high-level MPDC cryptographic operations to the corresponding QSC library functions. The mapping depends on the selected parameter set. For instance, if MPDC_CONFIG_SPHINCS_MCELIECE is defined, then the MPDC cipher and signature functions map to the McEliece/SPHINCS+ routines. Alternatively, if MPDC_CONFIG_DILITHIUM_KYBER is defined, the corresponding Dilithium/Kyber routines are used.

Generate an asymmetric cipher key-pair

◆ MPDC_DLA_UPDATE_WAIT_TIME

#define MPDC_DLA_UPDATE_WAIT_TIME   (7 * 24 * 60 * 60)

The interval in milliseconds between topology full updates.

Note: Default is 7 days.

Enumeration Type Documentation

◆ mpdc_configuration_sets

The MPDC algorithm configuration sets.

Enumerator
mpdc_configuration_set_none 

No algorithm identifier is set

mpdc_configuration_set_dilithium1_kyber1_rcs256_shake256 

The Dilithium-S1/Kyber-S1/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_dilithium3_kyber3_rcs256_shake256 

The Dilithium-S3/Kyber-S3/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_dilithium5_kyber5_rcs256_shake256 

The Dilithium-S5/Kyber-S5/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_dilithium5_kyber6_rcs512_shake256 

The Dilithium-S5/Kyber-S6/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus1f_mceliece1_rcs256_shake256 

The SPHINCS+-S1F/McEliece-S1/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus1s_mceliece1_rcs256_shake256 

The SPHINCS+-S1S/McEliece-S1/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus3f_mceliece3_rcs256_shake256 

The SPHINCS+-S3F/McEliece-S3/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus3s_mceliece3_rcs256_shake256 

The SPHINCS+-S3S/McEliece-S3/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5f_mceliece5_rcs256_shake256 

The SPHINCS+-S5F/McEliece-S5a/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5s_mceliece5_rcs256_shake256 

The SPHINCS+-S5S/McEliece-S5a/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5f_mceliece6_rcs256_shake256 

The SPHINCS+-S5F/McEliece-S5b/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5s_mceliece6_rcs256_shake256 

The SPHINCS+-S5S/McEliece-S5b/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5f_mceliece7_rcs256_shake256 

The SPHINCS+-S5F/McEliece-S5c/RCS-256/SHAKE-256 algorithm set

mpdc_configuration_set_sphincsplus5s_mceliece7_rcs256_shake256 

The SPHINCS+-S5S/McEliece-S5c/RCS-256/SHAKE-256 algorithm set

◆ mpdc_network_designations

The MPDC device designation.

Enumerator
mpdc_network_designation_none 

No designation was selected

mpdc_network_designation_agent 

The device is an agent

mpdc_network_designation_client 

The device is a client

mpdc_network_designation_dla 

The device is the DLA

mpdc_network_designation_idg 

The device is an inter-domain gateway

mpdc_network_designation_mas 

The device is a server

mpdc_network_designation_remote 

The device is a remote agent

mpdc_network_designation_rds 

The device is an RDS security server

mpdc_network_designation_revoked 

The device has been revoked

mpdc_network_designation_all 

Every server and client device on the network

◆ mpdc_network_errors

The MPDC network error values.

Enumerator
mpdc_network_error_none 

No error was detected

mpdc_network_error_accept_fail 

The socket accept function returned an error

mpdc_network_error_auth_failure 

The cipher authentication has failed

mpdc_network_error_bad_keep_alive 

The keep alive check failed

mpdc_network_error_channel_down 

The communications channel has failed

mpdc_network_error_connection_failure 

The device could not make a connection to the remote host

mpdc_network_error_decryption_failure 

The decryption authentication has failed

mpdc_network_error_establish_failure 

The transmission failed at the kex establish phase

mpdc_network_error_general_failure 

The connection experienced an unexpected error

mpdc_network_error_hosts_exceeded 

The server has run out of socket connections

mpdc_network_error_identity_unknown 

The random generator experienced a failure

mpdc_network_error_invalid_input 

The input is invalid

mpdc_network_error_invalid_request 

The request is invalid

mpdc_network_error_keep_alive_expired 

The keep alive has expired with no response

mpdc_network_error_keep_alive_timeout 

The keepalive failure counter has exceeded maximum

mpdc_network_error_kex_auth_failure 

The kex authentication has failed

mpdc_network_error_key_not_recognized 

The key-id is not recognized

mpdc_network_error_key_has_expired 

The certificate has expired

mpdc_network_error_listener_fail 

The listener function failed to initialize

mpdc_network_error_memory_allocation 

The server has run out of memory

mpdc_network_error_packet_unsequenced 

The random generator experienced a failure

mpdc_network_error_random_failure 

The random generator experienced a failure

mpdc_network_error_ratchet_fail 

The ratchet operation has failed

mpdc_network_error_receive_failure 

The receiver failed at the network layer

mpdc_network_error_transmit_failure 

The transmitter failed at the network layer

mpdc_network_error_unknown_protocol 

The protocol version is unknown

mpdc_network_error_unsequenced 

The packet was received out of sequence

mpdc_network_error_verify_failure 

The expected data could not be verified

◆ mpdc_network_flags

The MPDC network flags.

Enumerator
mpdc_network_flag_none 

No flag was selected

mpdc_network_flag_connection_terminate_request 

The packet contains a connection termination message

mpdc_network_flag_error_condition 

The connection experienced an error message

mpdc_network_flag_fragment_collection_request 

The packet contains a server fragment collection request message

mpdc_network_flag_fragment_collection_response 

The packet contains an agent fragment collection response message

mpdc_network_flag_fragment_request 

The packet contains a server fragment key request message

mpdc_network_flag_fragment_response 

The packet contains an agent fragment key response message

mpdc_network_flag_fragment_query_request 

The packet contains a server fragment key request message

mpdc_network_flag_fragment_query_response 

The packet contains an agent fragment key response message

mpdc_network_flag_incremental_update_request 

The packet contains an incremental update request message

mpdc_network_flag_incremental_update_response 

The packet contains an incremental update response message

mpdc_network_flag_register_request 

The packet contains a join request message

mpdc_network_flag_register_response 

The packet contains a join response message

mpdc_network_flag_register_update_request 

The packet contains a join update request message

mpdc_network_flag_register_update_response 

The packet contains a join update response message

mpdc_network_flag_keep_alive_request 

The packet contains a keep alive request

mpdc_network_flag_keep_alive_response 

The packet contains a keep alive response

mpdc_network_flag_mfk_establish 

The packet contains a server master fragment key establish message

mpdc_network_flag_mfk_request 

The packet contains a server master fragment key request message

mpdc_network_flag_mfk_response 

The packet contains a client mfk exchange response message

mpdc_network_flag_mfk_verify 

The packet contains a server master fragment key verify message

mpdc_network_flag_network_announce_broadcast 

The packet contains a topology announce broadcast

mpdc_network_flag_network_converge_request 

The packet contains a network converge request message

mpdc_network_flag_network_converge_response 

The packet contains a network converge response message

mpdc_network_flag_network_converge_update 

The packet contains a network converge update message

mpdc_network_flag_network_resign_request 

The packet contains a network resignation request message

mpdc_network_flag_network_resign_response 

The packet contains a network resignation response message

mpdc_network_flag_network_revocation_broadcast 

The packet contains a certificate revocation broadcast

mpdc_network_flag_network_signature_request 

The packet contains a certificate signing request

mpdc_network_flag_system_error_condition 

The packet contains an error condition message

mpdc_network_flag_tunnel_connection_terminate 

The packet contains a socket close message

mpdc_network_flag_tunnel_encrypted_message 

The packet contains an encrypted message

mpdc_network_flag_tunnel_session_established 

The exchange is in the established state

mpdc_network_flag_tunnel_transfer_request 

Reserved - The host has received a transfer request

mpdc_network_flag_topology_query_request 

The packet contains a topology query request message

mpdc_network_flag_topology_query_response 

The packet contains a topology query response message

mpdc_network_flag_topology_status_request 

The packet contains a topology status request message

mpdc_network_flag_topology_status_response 

The packet contains a topology status response message

mpdc_network_flag_topology_status_available 

The packet contains a topology status available message

mpdc_network_flag_topology_status_synchronized 

The packet contains a topology status synchronized message

mpdc_network_flag_topology_status_unavailable 

The packet contains a topology status unavailable message

mpdc_network_flag_network_remote_signing_request 

The packet contains a remote signing request message

mpdc_network_flag_network_remote_signing_response 

The packet contains a remote signing response message

◆ mpdc_protocol_errors

The MPDC protocol error values.

Enumerator
mpdc_protocol_error_none 

No error was detected

mpdc_protocol_error_authentication_failure 

The symmetric cipher had an authentication failure

mpdc_protocol_error_certificate_not_found 

The node certificate could not be found

mpdc_protocol_error_channel_down 

The communications channel has failed

mpdc_protocol_error_connection_failure 

The device could not make a connection to the remote host

mpdc_protocol_error_connect_failure 

The transmission failed at the KEX connection phase

mpdc_protocol_error_convergence_failure 

The convergence call has returned an error

mpdc_protocol_error_convergence_synchronized 

The database is already synchronized

mpdc_protocol_error_decapsulation_failure 

The asymmetric cipher failed to decapsulate the shared secret

mpdc_protocol_error_decoding_failure 

The node or certificate decoding failed

mpdc_protocol_error_decryption_failure 

The decryption authentication has failed

mpdc_protocol_error_establish_failure 

The transmission failed at the KEX establish phase

mpdc_protocol_error_exchange_failure 

The transmission failed at the KEX exchange phase

mpdc_protocol_error_file_not_deleted 

The application could not delete a local file

mpdc_protocol_error_file_not_found 

The file could not be found

mpdc_protocol_error_file_not_written 

The file could not be written to storage

mpdc_protocol_error_hash_invalid 

The public-key hash is invalid

mpdc_protocol_error_hosts_exceeded 

The server has run out of socket connections

mpdc_protocol_error_invalid_request 

The packet flag was unexpected

mpdc_protocol_error_certificate_expired 

The certificate has expired

mpdc_protocol_error_key_expired 

The MPDC public key has expired

mpdc_protocol_error_key_unrecognized 

The key identity is unrecognized

mpdc_protocol_error_listener_fail 

The listener function failed to initialize

mpdc_protocol_error_memory_allocation 

The server has run out of memory

mpdc_protocol_error_message_time_invalid 

The network time is invalid or has substantial delay

mpdc_protocol_error_message_verification_failure 

The expected data could not be verified

mpdc_protocol_error_no_usable_address 

The server has no usable IP address, assign in configuration

mpdc_protocol_error_node_not_available 

The node is not available for a session

mpdc_protocol_error_node_not_found 

The node could not be found in the database

mpdc_protocol_error_node_was_registered 

The node was previously registered in the database

mpdc_protocol_error_operation_cancelled 

The operation was cancelled by the user

mpdc_protocol_error_packet_header_invalid 

The packet header received was invalid

mpdc_protocol_error_packet_unsequenced 

The packet was received out of sequence

mpdc_protocol_error_receive_failure 

The receiver failed at the network layer

mpdc_protocol_error_root_signature_invalid 

The root signature failed authentication

mpdc_protocol_error_serialization_failure 

The certificate could not be serialized

mpdc_protocol_error_signature_failure 

The signature scheme could not sign a message

mpdc_protocol_error_signing_failure 

The transmission failed to sign the data

mpdc_protocol_error_socket_binding 

The socket could not be bound to an IP address

mpdc_protocol_error_socket_creation 

The socket could not be created

mpdc_protocol_error_transmit_failure 

The transmitter failed at the network layer

mpdc_protocol_error_topology_no_agent 

The topological database has no agent entries

mpdc_protocol_error_unknown_protocol 

The protocol string was not recognized

mpdc_protocol_error_verification_failure 

The transmission failed at the KEX verify phase

◆ mpdc_version_sets

The MPDC version sets.

Enumerator
mpdc_version_set_none 

No version identifier is set

mpdc_version_set_one_zero 

The 1.0 version identifier

Function Documentation

◆ mpdc_connection_close()

MPDC_EXPORT_API void mpdc_connection_close ( qsc_socket * rsock,
mpdc_network_errors err,
bool notify )

Close the network connection between hosts.

Parameters
rsockA pointer to the socket structure representing the connection.
errThe network error code to report.
notifyIf true, notify the remote host that the connection is closing.

◆ mpdc_connection_state_dispose()

MPDC_EXPORT_API void mpdc_connection_state_dispose ( mpdc_connection_state * cns)

Dispose of the tunnel connection state.

Parameters
cnsA pointer to the connection state structure to dispose.

◆ mpdc_decrypt_packet()

MPDC_EXPORT_API mpdc_network_errors mpdc_decrypt_packet ( mpdc_connection_state * cns,
uint8_t * message,
size_t * msglen,
const mpdc_network_packet * packetin )

Decrypt a message and copy it to the output buffer.

Parameters
cnsA pointer to the connection state structure.
messageThe output array for the decrypted message.
msglenA pointer to a variable that will receive the length of the decrypted message.
packetin[const] A pointer to the input packet structure.
Returns
Returns the network error state.

◆ mpdc_encrypt_packet()

MPDC_EXPORT_API mpdc_network_errors mpdc_encrypt_packet ( mpdc_connection_state * cns,
mpdc_network_packet * packetout,
const uint8_t * message,
size_t msglen )

Encrypt a message and build an output packet.

Parameters
cnsA pointer to the connection state structure.
packetoutA pointer to the output packet structure.
message[const] The input message array.
msglenThe length of the input message.
Returns
Returns the network error state.

◆ mpdc_network_error_to_string()

MPDC_EXPORT_API const char * mpdc_network_error_to_string ( mpdc_network_errors error)

Return a pointer to a string description of a network error code.

Parameters
errorThe network error code.
Returns
Returns a pointer to an error string or NULL if the code is unrecognized.

◆ mpdc_packet_clear()

MPDC_EXPORT_API void mpdc_packet_clear ( mpdc_network_packet * packet)

Clear the state of a network packet.

Parameters
packetA pointer to the packet structure to clear.

◆ mpdc_packet_error_message()

MPDC_EXPORT_API void mpdc_packet_error_message ( mpdc_network_packet * packet,
mpdc_protocol_errors error )

Populate a packet structure with an error message.

Parameters
packetA pointer to the packet structure.
errorThe protocol error code to embed in the packet.

◆ mpdc_packet_header_deserialize()

MPDC_EXPORT_API void mpdc_packet_header_deserialize ( const uint8_t * header,
mpdc_network_packet * packet )

Deserialize a byte array into a packet header.

Parameters
header[const] The header byte array to deserialize.
packetA pointer to the packet structure that will be populated.

◆ mpdc_packet_header_serialize()

MPDC_EXPORT_API void mpdc_packet_header_serialize ( const mpdc_network_packet * packet,
uint8_t * header )

Serialize a packet header into a byte array.

Parameters
packet[const] A pointer to the packet structure to serialize.
headerThe byte array that will receive the serialized header.

◆ mpdc_packet_set_utc_time()

MPDC_EXPORT_API void mpdc_packet_set_utc_time ( mpdc_network_packet * packet)

Set the local UTC time in the packet header.

Parameters
packetA pointer to the network packet.

◆ mpdc_packet_time_valid()

MPDC_EXPORT_API bool mpdc_packet_time_valid ( const mpdc_network_packet * packet)

Check if the packet's UTC time is within the valid time threshold.

Parameters
packet[const] A pointer to the network packet.
Returns
Returns true if the packet was received within the valid time threshold.

◆ mpdc_packet_to_stream()

MPDC_EXPORT_API size_t mpdc_packet_to_stream ( const mpdc_network_packet * packet,
uint8_t * pstream )

Serialize a network packet to a byte stream.

Parameters
packet[const] A pointer to the packet.
pstreamA pointer to the output byte stream.
Returns
Returns the size of the serialized byte stream.

◆ mpdc_protocol_error_to_string()

MPDC_EXPORT_API const char * mpdc_protocol_error_to_string ( mpdc_protocol_errors error)

Return a pointer to a string description of a protocol error code.

Parameters
errorThe protocol error code.
Returns
Returns a pointer to an error string or NULL if the code is unrecognized.

◆ mpdc_stream_to_packet()

MPDC_EXPORT_API void mpdc_stream_to_packet ( const uint8_t * pstream,
mpdc_network_packet * packet )

Deserialize a byte stream into a network packet.

Parameters
pstream[const] The byte stream containing the packet data.
packetA pointer to the packet structure to populate.