SKDP: Symmetric Key Distribution Protocol 1.1.0.0 (A1)
Encrypted tunneling protocol using pre-shared keys
skdpserver.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 SKDP_SERVER_H
41#define SKDP_SERVER_H
42
43#include "common.h"
44#include "skdp.h"
45#include "../../QSC/QSC/rcs.h"
46#include "../../QSC/QSC/socketserver.h"
47
65
76SKDP_EXPORT_API typedef struct skdp_server_state
77{
78 qsc_rcs_state rxcpr;
79 qsc_rcs_state txcpr;
80 uint8_t did[SKDP_KID_SIZE];
81 uint8_t dsh[SKDP_STH_SIZE];
82 uint8_t kid[SKDP_KID_SIZE];
83 uint8_t ssh[SKDP_STH_SIZE];
84 uint8_t sdk[SKDP_SDK_SIZE];
85 uint64_t expiration;
86 uint64_t rxseq;
87 uint64_t txseq;
90
103SKDP_EXPORT_API void skdp_server_connection_close(skdp_server_state* ctx, qsc_socket* sock, skdp_errors error);
104
114SKDP_EXPORT_API void skdp_server_send_error(const qsc_socket* sock, skdp_errors error);
115
128SKDP_EXPORT_API skdp_errors skdp_server_send_keep_alive(skdp_keep_alive_state* kctx, const qsc_socket* sock);
129
141SKDP_EXPORT_API void skdp_server_initialize(skdp_server_state* ctx, const skdp_server_key* skey);
142
158SKDP_EXPORT_API skdp_errors skdp_server_listen_ipv4(skdp_server_state* ctx, qsc_socket* sock, const qsc_ipinfo_ipv4_address* address, uint16_t port);
159
174SKDP_EXPORT_API skdp_errors skdp_server_listen_ipv6(skdp_server_state* ctx, qsc_socket* sock, const qsc_ipinfo_ipv6_address* address, uint16_t port);
175
191SKDP_EXPORT_API skdp_errors skdp_server_decrypt_packet(skdp_server_state* ctx, const skdp_network_packet* packetin, uint8_t* message, size_t* msglen);
192
208SKDP_EXPORT_API skdp_errors skdp_server_encrypt_packet(skdp_server_state* ctx, const uint8_t* message, size_t msglen, skdp_network_packet* packetout);
209
225
226#endif
The SKDP settings.
#define SKDP_STH_SIZE
The session token hash size (in bytes) for 256-bit security.
Definition skdp.h:347
#define SKDP_KID_SIZE
The SKDP key identity size in bytes.
Definition skdp.h:172
#define SKDP_SDK_SIZE
The server derivation key size (in bytes) for 256-bit security.
Definition skdp.h:335
skdp_errors
The SKDP error values.
Definition skdp.h:630
skdp_flags
The SKDP packet flag values.
Definition skdp.h:658
SKDP_EXPORT_API void skdp_server_send_error(const qsc_socket *sock, skdp_errors error)
Send an error code to the remote host.
Definition skdpserver.c:483
SKDP_EXPORT_API skdp_errors skdp_server_send_keep_alive(skdp_keep_alive_state *kctx, const qsc_socket *sock)
Send a keep-alive message to the remote host.
Definition skdpserver.c:504
SKDP_EXPORT_API skdp_errors skdp_server_ratchet_response(skdp_server_state *ctx, skdp_network_packet *packetout)
Send a ratchet response to the client.
SKDP_EXPORT_API skdp_errors skdp_server_listen_ipv6(skdp_server_state *ctx, qsc_socket *sock, const qsc_ipinfo_ipv6_address *address, uint16_t port)
Run the IPv6 networked key exchange function.
Definition skdpserver.c:599
SKDP_EXPORT_API skdp_errors skdp_server_encrypt_packet(skdp_server_state *ctx, const uint8_t *message, size_t msglen, skdp_network_packet *packetout)
Encrypt a message into an SKDP packet.
Definition skdpserver.c:685
SKDP_EXPORT_API void skdp_server_initialize(skdp_server_state *ctx, const skdp_server_key *skey)
Initialize the SKDP server state.
Definition skdpserver.c:565
SKDP_EXPORT_API skdp_errors skdp_server_decrypt_packet(skdp_server_state *ctx, const skdp_network_packet *packetin, uint8_t *message, size_t *msglen)
Decrypt a received SKDP packet.
Definition skdpserver.c:623
SKDP_EXPORT_API void skdp_server_connection_close(skdp_server_state *ctx, qsc_socket *sock, skdp_errors error)
Close the remote session and dispose of server resources.
Definition skdpserver.c:540
SKDP_EXPORT_API skdp_errors skdp_server_listen_ipv4(skdp_server_state *ctx, qsc_socket *sock, const qsc_ipinfo_ipv4_address *address, uint16_t port)
Run the IPv4 networked key exchange function.
Definition skdpserver.c:575
The SKDP network packet structure.
Definition skdp.h:614
The SKDP server key structure.
Definition skdp.h:569
The SKDP server state structure.
Definition skdpserver.h:77
uint64_t txseq
Definition skdpserver.h:87
uint8_t ssh[SKDP_STH_SIZE]
Definition skdpserver.h:83
uint8_t kid[SKDP_KID_SIZE]
Definition skdpserver.h:82
uint64_t expiration
Definition skdpserver.h:85
qsc_rcs_state txcpr
Definition skdpserver.h:79
uint64_t rxseq
Definition skdpserver.h:86
skdp_flags exflag
Definition skdpserver.h:88
uint8_t did[SKDP_KID_SIZE]
Definition skdpserver.h:80
qsc_rcs_state rxcpr
Definition skdpserver.h:78
uint8_t sdk[SKDP_SDK_SIZE]
Definition skdpserver.h:84
uint8_t dsh[SKDP_STH_SIZE]
Definition skdpserver.h:81