MPDC: Multi Party Domain Cryptosystem 1.0.0.0b (A0)
MPDC Interior protocol
network.h
Go to the documentation of this file.
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: This software and all accompanying materials are the exclusive
5 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
6 * The intellectual and technical concepts contained within this implementation
7 * are proprietary to QRCS and its authorized licensors and are protected under
8 * applicable U.S. and international copyright, patent, and trade secret laws.
9 *
10 * CRYPTOGRAPHIC STANDARDS:
11 * - This software includes implementations of cryptographic algorithms such as
12 * SHA3, AES, and others. These algorithms are public domain or standardized
13 * by organizations such as NIST and are NOT the property of QRCS.
14 * - However, all source code, optimizations, and implementations in this library
15 * are original works of QRCS and are protected under this license.
16 *
17 * RESTRICTIONS:
18 * - Redistribution, modification, or unauthorized distribution of this software,
19 * in whole or in part, is strictly prohibited.
20 * - This software is provided for non-commercial, educational, and research
21 * purposes only. Commercial use in any form is expressly forbidden.
22 * - Licensing and authorized distribution are solely at the discretion of QRCS.
23 * - Any use of this software implies acceptance of these restrictions.
24 *
25 * DISCLAIMER:
26 * This software is provided "as is," without warranty of any kind, express or
27 * implied, including but not limited to warranties of merchantability or fitness
28 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
29 * incidental, or consequential damages resulting from the use or misuse of this software.
30 *
31 * FULL LICENSE:
32 * This software is subject to the **Quantum Resistant Cryptographic Solutions
33 * Proprietary License (QRCS-PL)**. The complete license terms are included
34 * in the LICENSE.txt file distributed with this software.
35 *
36 * Written by: John G. Underhill
37 * Contact: john.underhill@protonmail.com
38 */
39
40#ifndef MPDC_NETWORK_H
41#define MPDC_NETWORK_H
42
43#include "common.h"
44#include "topology.h"
45#include "../../QSC/QSC/collection.h"
46#include "../../QSC/QSC/sha3.h"
47#include "../../QSC/QSC/socket.h"
48
81
92
103
114
127
138
150
163
168MPDC_EXPORT_API typedef struct mpdc_network_fkey_response_state
169{
170 qsc_socket* csock;
171 uint8_t* frag;
173 const uint8_t* mfk;
176
187
198
211
224
238
252
266
281
293
306
311MPDC_EXPORT_API typedef struct mpdc_network_resign_request_state
312{
313 const char* address;
315 const uint8_t* sigkey;
317
329
341
352
366
378
390
402
417
434
447
460
473
486
487/*---------------------------------------------------------------------------
488 Public Function Prototypes
489---------------------------------------------------------------------------*/
490
498
507
514MPDC_EXPORT_API uint16_t mpdc_network_application_to_port(mpdc_network_designations tnode);
515
524MPDC_EXPORT_API void mpdc_network_broadcast_message(const mpdc_topology_list_state* list, const uint8_t* message, size_t msglen, mpdc_network_designations tnode);
525
534MPDC_EXPORT_API qsc_socket_exceptions mpdc_network_connect_to_device(qsc_socket* csock, const char* address, mpdc_network_designations designation);
535
543
552
561
570MPDC_EXPORT_API qsc_socket_exceptions mpdc_network_connect_to_address(qsc_socket* csock, const char* address, uint16_t port);
571
579
588
596
605
614
621MPDC_EXPORT_API bool mpdc_network_get_local_address(char address[MPDC_CERTIFICATE_ADDRESS_SIZE]);
622
630MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_send_error(const qsc_socket* csock, mpdc_protocol_errors error);
631
637MPDC_EXPORT_API void mpdc_network_socket_dispose(qsc_socket* csock);
638
646
654
662
670
679
688
696
705
713
722
730
739
747
756
764
773
781
790
799
808
817
818#if defined(QSC_DEBUG_MODE)
819MPDC_EXPORT_API bool mpdc_network_protocols_test();
820#endif
821
822#endif
#define MPDC_CERTIFICATE_ADDRESS_SIZE
The maximum IP address length.
Definition mpdc.h:758
mpdc_network_designations
The MPDC device designation.
Definition mpdc.h:1114
mpdc_protocol_errors
The MPDC protocol error values.
Definition mpdc.h:1219
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_certificate_verify(const mpdc_child_certificate *ccert, const mpdc_root_certificate *root)
Verify a certificates format and root signature.
Definition network.c:4163
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_announce_broadcast(mpdc_network_announce_request_state *state)
Announce a certificate using the dla, and broadcast it to the network.
Definition network.c:473
MPDC_EXPORT_API bool mpdc_network_get_local_address(char address[MPDC_CERTIFICATE_ADDRESS_SIZE])
Get the local IP address.
Definition network.c:4415
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_topological_status_verify(const mpdc_network_topological_status_request_state *state, const mpdc_network_packet *packetin)
Verify the status response from the DLA.
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_incremental_update_request(const mpdc_network_incremental_update_request_state *state)
Send an incremental update request.
Definition network.c:2105
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_mfk_exchange_request(mpdc_network_mfk_request_state *state)
Request and execute a key exchange request for a master fragmentation key.
Definition network.c:2327
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_incremental_update_response(const mpdc_network_incremental_update_response_state *state, const mpdc_network_packet *packetin)
Send a copy of a certificate to a remote host.
Definition network.c:2206
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_fragment_collection_request(mpdc_network_fragment_collection_request_state *state)
A Client requests a fragment collection from a MAS.
Definition network.c:1321
MPDC_EXPORT_API uint16_t mpdc_network_application_to_port(mpdc_network_designations tnode)
Gets the network designation from a port number.
Definition network.c:4234
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_register_request(mpdc_network_register_request_state *state)
Send an Agent join request to the DLA.
Definition network.c:2634
MPDC_EXPORT_API mpdc_network_designations mpdc_network_port_to_application(uint16_t port)
Gets the network designation from a port number.
Definition network.c:4198
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_topological_query_request(const mpdc_network_topological_query_request_state *state)
Query a device for its topological information.
Definition network.c:3729
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_register_update_request(mpdc_network_register_update_request_state *state)
Send a MAS or Client join update request to the DLA.
Definition network.c:2897
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_fkey_response(mpdc_network_fkey_response_state *state, const mpdc_network_packet *packetin)
Respond and execute a key exchange for a fragmentation key.
Definition network.c:1063
MPDC_EXPORT_API qsc_socket_exceptions mpdc_network_connect_to_address(qsc_socket *csock, const char *address, uint16_t port)
Connect a socket to a remote address and port.
Definition network.c:4360
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_fragment_collection_response(mpdc_network_fragment_collection_response_state *state, const mpdc_network_packet *packetin)
A MAS sends a collection response to a Client.
Definition network.c:1654
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_register_update_response(mpdc_network_register_update_response_state *state, const mpdc_network_packet *packetin)
Send a join update response to the server or client.
Definition network.c:3098
MPDC_EXPORT_API void mpdc_network_broadcast_message(const mpdc_topology_list_state *list, const uint8_t *message, size_t msglen, mpdc_network_designations tnode)
Broadcast a message to a node type on the network.
Definition network.c:4270
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_topological_status_request(const mpdc_network_topological_status_request_state *state)
Send a status request from the DLA to a client device.
Definition network.c:3981
MPDC_EXPORT_API void mpdc_network_socket_dispose(qsc_socket *csock)
Shut down and dispose of a socket instance.
Definition network.c:4484
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_fragment_query_response(const mpdc_network_fragment_query_response_state *state, const mpdc_network_packet *packetin)
An Agent sends a fragment query response to a MAS.
Definition network.c:2009
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_topological_query_response(const mpdc_network_topological_query_response_state *state, const mpdc_network_packet *packetin)
Respond to a topological query request.
Definition network.c:3860
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_register_response(mpdc_network_register_response_state *state, const mpdc_network_packet *packetin)
Send a join response to the agent.
Definition network.c:2749
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_revoke_response(mpdc_network_revoke_response_state *state, const mpdc_network_packet *packetin)
Verify a revocation request sent from the DLA.
Definition network.c:3639
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_resign_response(mpdc_network_resign_response_state *state, const mpdc_network_packet *packetin)
Send a resign response to the agent or server.
Definition network.c:3489
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_resign_request(const mpdc_network_resign_request_state *state)
Send a resign request to the dla.
Definition network.c:3430
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_converge_update_verify(mpdc_network_converge_update_verify_state *state, const mpdc_network_packet *packetin)
Process a converge response update message.
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_converge_response(const mpdc_network_converge_response_state *state, const mpdc_network_packet *packetin)
Respond to a dla network converge request.
Definition network.c:808
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_mfk_exchange_response(mpdc_network_mfk_response_state *state, const mpdc_network_packet *packetin)
Request and execute a key exchange response for a master fragmentation key.
Definition network.c:2514
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_topological_status_response(const mpdc_network_topological_status_response_state *state, const mpdc_network_packet *packetin)
Process the status response from the client device and send a response.
Definition network.c:4112
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_send_error(const qsc_socket *csock, mpdc_protocol_errors error)
Send an error message.
Definition network.c:4442
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_fkey_request(mpdc_network_fkey_request_state *state)
Request and execute a key exchange for a fragmentation key.
Definition network.c:932
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_revoke_broadcast(mpdc_network_revoke_request_state *state)
Send a revocation request from the DLA.
Definition network.c:3569
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_announce_response(mpdc_network_announce_response_state *state, const mpdc_network_packet *packetin)
Process a announce response message.
Definition network.c:522
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_remote_signing_request(mpdc_network_remote_signing_request_state *state)
Send a certificate signing request from the DLA to the RDS.
Definition network.c:3209
MPDC_EXPORT_API qsc_socket_exceptions mpdc_network_connect_to_device(qsc_socket *csock, const char *address, mpdc_network_designations designation)
Connect a socket to a remote address.
Definition network.c:4303
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_remote_signing_response(mpdc_network_remote_signing_response_state *state, const mpdc_network_packet *packetin)
Send a signed certificate response from the RDS to the DLA.
Definition network.c:3358
MPDC_EXPORT_API mpdc_protocol_errors mpdc_network_converge_request(const mpdc_network_converge_request_state *state)
The DLA sends out a convergence request, and broadcast it to the network.
Definition network.c:642
The child certificate structure.
Definition mpdc.h:1293
The MPDC asymmetric cipher key container.
Definition mpdc.h:1446
The MPDC socket connection state structure.
Definition mpdc.h:1357
The certificate announce request function state.
Definition network.h:87
const uint8_t * sigkey
Definition network.h:90
const mpdc_topology_node_state * rnode
Definition network.h:89
const mpdc_topology_list_state * list
Definition network.h:88
The certificate announce response function state.
Definition network.h:98
mpdc_topology_node_state * rnode
Definition network.h:100
const mpdc_root_certificate * root
Definition network.h:101
const mpdc_child_certificate * dcert
Definition network.h:99
The certificate converge request function state.
Definition network.h:109
mpdc_topology_node_state * rnode
Definition network.h:111
const uint8_t * sigkey
Definition network.h:112
const mpdc_child_certificate * rcert
Definition network.h:110
The certificate converge response function state.
Definition network.h:120
const mpdc_topology_node_state * lnode
Definition network.h:123
const mpdc_child_certificate * lcert
Definition network.h:122
const qsc_socket * csock
Definition network.h:121
const uint8_t * sigkey
Definition network.h:125
const mpdc_child_certificate * rcert
Definition network.h:124
The certificate converge verify function state.
Definition network.h:133
const qsc_socket * csock
Definition network.h:134
const mpdc_child_certificate * rcert
Definition network.h:136
const mpdc_topology_node_state * rnode
Definition network.h:135
The certificate converge update verify function state.
Definition network.h:144
mpdc_child_certificate * rcert
Definition network.h:146
const qsc_socket * csock
Definition network.h:145
const uint8_t * sigkey
Definition network.h:148
const mpdc_root_certificate * root
Definition network.h:147
The fkey request function state.
Definition network.h:156
const mpdc_topology_node_state * lnode
Definition network.h:158
const uint8_t * mfk
Definition network.h:159
const mpdc_topology_node_state * rnode
Definition network.h:160
uint8_t * frag
Definition network.h:157
uint8_t * token
Definition network.h:161
The fkey response function state.
Definition network.h:169
const mpdc_topology_node_state * lnode
Definition network.h:172
const uint8_t * mfk
Definition network.h:173
const mpdc_topology_node_state * rnode
Definition network.h:174
uint8_t * frag
Definition network.h:171
qsc_socket * csock
Definition network.h:170
The fkey collection request function state.
Definition network.h:408
const mpdc_topology_node_state * lnode
Definition network.h:413
qsc_collection_state * lmfk
Definition network.h:412
const mpdc_topology_node_state * rnode
Definition network.h:414
uint8_t * hfkey
Definition network.h:410
qsc_socket * csock
Definition network.h:409
const mpdc_topology_list_state * list
Definition network.h:411
uint8_t * token
Definition network.h:415
The fkey collection response function state.
Definition network.h:423
const mpdc_topology_node_state * lnode
Definition network.h:429
qsc_collection_state * lmfk
Definition network.h:428
const qsc_socket * csock
Definition network.h:424
const mpdc_topology_node_state * rnode
Definition network.h:430
uint8_t * hfkey
Definition network.h:426
uint8_t * frag
Definition network.h:425
const mpdc_topology_list_state * list
Definition network.h:427
uint8_t * ctok
Definition network.h:431
uint8_t * mtok
Definition network.h:432
The fkey query request function state.
Definition network.h:440
const uint8_t * token
Definition network.h:445
const mpdc_topology_node_state * lnode
Definition network.h:443
qsc_collection_state * lmfk
Definition network.h:442
const mpdc_topology_node_state * rnode
Definition network.h:444
const mpdc_topology_list_state * list
Definition network.h:441
The fkey query response function state.
Definition network.h:453
const mpdc_topology_node_state * lnode
Definition network.h:455
qsc_collection_state * lmfk
Definition network.h:457
const qsc_socket * csock
Definition network.h:454
const mpdc_topology_node_state * rnode
Definition network.h:458
const mpdc_topology_list_state * list
Definition network.h:456
The incremental update request function state.
Definition network.h:182
mpdc_child_certificate * rcert
Definition network.h:183
const mpdc_topology_node_state * rnode
Definition network.h:184
const mpdc_root_certificate * root
Definition network.h:185
The incremental update response function state.
Definition network.h:193
const qsc_socket * csock
Definition network.h:194
const uint8_t * sigkey
Definition network.h:196
const mpdc_child_certificate * rcert
Definition network.h:195
The key exchange request function state.
Definition network.h:466
mpdc_connection_state * cns
Definition network.h:468
const uint8_t * token
Definition network.h:471
const char * address
Definition network.h:467
const mpdc_child_certificate * rcert
Definition network.h:470
const mpdc_topology_list_state * list
Definition network.h:469
The key exchange response function state.
Definition network.h:479
mpdc_connection_state * cns
Definition network.h:480
const qsc_socket * csock
Definition network.h:481
const uint8_t * sigkey
Definition network.h:484
const mpdc_child_certificate * rcert
Definition network.h:483
const mpdc_topology_list_state * list
Definition network.h:482
The mfk request function state.
Definition network.h:258
const mpdc_child_certificate * lcert
Definition network.h:259
const uint8_t * sigkey
Definition network.h:264
const mpdc_child_certificate * rcert
Definition network.h:261
const mpdc_topology_node_state * rnode
Definition network.h:262
const mpdc_root_certificate * root
Definition network.h:263
uint8_t * mfk
Definition network.h:260
The mfk response function state.
Definition network.h:272
mpdc_child_certificate * rcert
Definition network.h:277
const mpdc_child_certificate * lcert
Definition network.h:275
const qsc_socket * csock
Definition network.h:273
const uint8_t * sigkey
Definition network.h:279
const mpdc_root_certificate * root
Definition network.h:278
mpdc_cipher_keypair ckp
Definition network.h:274
uint8_t * mfk
Definition network.h:276
The MPDC packet structure.
Definition mpdc.h:1394
The network join request function state.
Definition network.h:204
mpdc_child_certificate * rcert
Definition network.h:207
const mpdc_child_certificate * lcert
Definition network.h:206
const char * address
Definition network.h:205
const uint8_t * sigkey
Definition network.h:209
const mpdc_root_certificate * root
Definition network.h:208
The network join response function state.
Definition network.h:217
mpdc_child_certificate * rcert
Definition network.h:220
const mpdc_child_certificate * lcert
Definition network.h:219
const qsc_socket * csock
Definition network.h:218
const uint8_t * sigkey
Definition network.h:222
const mpdc_root_certificate * root
Definition network.h:221
The network join request function state.
Definition network.h:230
mpdc_child_certificate * rcert
Definition network.h:234
const mpdc_child_certificate * lcert
Definition network.h:232
const char * address
Definition network.h:231
const uint8_t * sigkey
Definition network.h:236
const mpdc_root_certificate * root
Definition network.h:235
mpdc_topology_list_state * list
Definition network.h:233
The network join update response function state.
Definition network.h:244
mpdc_child_certificate * rcert
Definition network.h:248
const mpdc_child_certificate * lcert
Definition network.h:246
const qsc_socket * csock
Definition network.h:245
const uint8_t * sigkey
Definition network.h:250
const mpdc_root_certificate * root
Definition network.h:249
const mpdc_topology_list_state * list
Definition network.h:247
The certificate remote signing request function state.
Definition network.h:287
mpdc_child_certificate * rcert
Definition network.h:289
const char * address
Definition network.h:288
const uint8_t * sigkey
Definition network.h:291
const mpdc_root_certificate * root
Definition network.h:290
The certificate remote signing response function state.
Definition network.h:299
mpdc_child_certificate * rcert
Definition network.h:302
mpdc_child_certificate * dcert
Definition network.h:301
const uint8_t * sigkey
Definition network.h:304
const mpdc_root_certificate * root
Definition network.h:303
qsc_socket * csock
Definition network.h:300
The certificate resign request function state.
Definition network.h:312
const mpdc_topology_node_state * lnode
Definition network.h:314
const char * address
Definition network.h:313
const uint8_t * sigkey
Definition network.h:315
The certificate resign request function state.
Definition network.h:323
mpdc_child_certificate * rcert
Definition network.h:325
mpdc_topology_node_state * rnode
Definition network.h:326
const uint8_t * sigkey
Definition network.h:327
const mpdc_topology_list_state * list
Definition network.h:324
The certificate revoke request function state.
Definition network.h:335
const uint8_t * sigkey
Definition network.h:339
const mpdc_topology_node_state * rnode
Definition network.h:338
mpdc_network_designations designation
Definition network.h:336
const mpdc_topology_list_state * list
Definition network.h:337
The certificate revoke response function state.
Definition network.h:347
mpdc_topology_node_state * rnode
Definition network.h:349
const mpdc_child_certificate * dcert
Definition network.h:350
const mpdc_topology_list_state * list
Definition network.h:348
The topological query request function state.
Definition network.h:358
mpdc_topology_node_state * rnode
Definition network.h:362
const uint8_t * sigkey
Definition network.h:364
const uint8_t * serial
Definition network.h:363
const char * issuer
Definition network.h:361
mpdc_topology_node_state * dnode
Definition network.h:360
const mpdc_child_certificate * dcert
Definition network.h:359
const mpdc_child_certificate * ccert
Definition network.h:374
const qsc_socket * csock
Definition network.h:373
const uint8_t * sigkey
Definition network.h:376
const mpdc_topology_node_state * rnode
Definition network.h:375
The topological status request function state.
Definition network.h:384
const mpdc_topology_node_state * lnode
Definition network.h:385
const uint8_t * sigkey
Definition network.h:388
const mpdc_child_certificate * rcert
Definition network.h:386
const mpdc_topology_node_state * rnode
Definition network.h:387
The topological status response function state.
Definition network.h:396
const mpdc_topology_node_state * lnode
Definition network.h:398
const qsc_socket * csock
Definition network.h:397
const uint8_t * sigkey
Definition network.h:400
const mpdc_child_certificate * rcert
Definition network.h:399
The root certificate structure.
Definition mpdc.h:1411
The MPDC topology list structure.
Definition topology.h:185
The MPDC topology node structure.
Definition topology.h:169
The MPDC topology functions.