SKDP: Symmetric Key Distribution Protocol 1.1.0.0 (A1)
Encrypted tunneling protocol using pre-shared keys
skdpclient.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_CLIENT_H
41#define SKDP_CLIENT_H
42
43#include "common.h"
44#include "skdp.h"
45#include "../../QSC/QSC/rcs.h"
46#include "../../QSC/QSC/socketclient.h"
47
64
84SKDP_EXPORT_API typedef struct skdp_client_state
85{
86 qsc_rcs_state rxcpr;
87 qsc_rcs_state txcpr;
88 uint8_t ddk[SKDP_DDK_SIZE];
89 uint8_t dsh[SKDP_STH_SIZE];
90 uint8_t kid[SKDP_KID_SIZE];
91 uint8_t ssh[SKDP_STH_SIZE];
92 uint64_t expiration;
93 uint64_t rxseq;
94 uint64_t txseq;
97
108SKDP_EXPORT_API void skdp_client_send_error(const qsc_socket* sock, skdp_errors error);
109
121SKDP_EXPORT_API void skdp_client_initialize(skdp_client_state* ctx, const skdp_device_key* ckey);
122
139SKDP_EXPORT_API skdp_errors skdp_client_connect_ipv4(skdp_client_state* ctx, qsc_socket* sock, const qsc_ipinfo_ipv4_address* address, uint16_t port);
140
156SKDP_EXPORT_API skdp_errors skdp_client_connect_ipv6(skdp_client_state* ctx, qsc_socket* sock, const qsc_ipinfo_ipv6_address* address, uint16_t port);
157
169SKDP_EXPORT_API void skdp_client_connection_close(skdp_client_state* ctx, qsc_socket* sock, skdp_errors error);
170
186SKDP_EXPORT_API skdp_errors skdp_client_decrypt_packet(skdp_client_state* ctx, const skdp_network_packet* packetin, uint8_t* message, size_t* msglen);
187
204SKDP_EXPORT_API skdp_errors skdp_client_encrypt_packet(skdp_client_state* ctx, const uint8_t* message, size_t msglen, skdp_network_packet* packetout);
205
220
221#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_DDK_SIZE
The device derivation key size (in bytes) for 256-bit security.
Definition skdp.h:293
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_client_initialize(skdp_client_state *ctx, const skdp_device_key *ckey)
Initialize the SKDP client state.
Definition skdpclient.c:508
SKDP_EXPORT_API skdp_errors skdp_client_decrypt_packet(skdp_client_state *ctx, const skdp_network_packet *packetin, uint8_t *message, size_t *msglen)
Decrypt an SKDP packet.
Definition skdpclient.c:588
SKDP_EXPORT_API skdp_errors skdp_client_connect_ipv6(skdp_client_state *ctx, qsc_socket *sock, const qsc_ipinfo_ipv6_address *address, uint16_t port)
Establish an IPv6 connection and perform the SKDP key exchange.
Definition skdpclient.c:541
SKDP_EXPORT_API skdp_errors skdp_client_ratchet_request(skdp_client_state *ctx, skdp_network_packet *packetout)
Send a ratchet request to the server.
SKDP_EXPORT_API void skdp_client_send_error(const qsc_socket *sock, skdp_errors error)
Send an error code to the remote host.
Definition skdpclient.c:487
SKDP_EXPORT_API skdp_errors skdp_client_encrypt_packet(skdp_client_state *ctx, const uint8_t *message, size_t msglen, skdp_network_packet *packetout)
Encrypt a message into an SKDP packet.
Definition skdpclient.c:650
SKDP_EXPORT_API skdp_errors skdp_client_connect_ipv4(skdp_client_state *ctx, qsc_socket *sock, const qsc_ipinfo_ipv4_address *address, uint16_t port)
Establish an IPv4 connection and perform the SKDP key exchange.
Definition skdpclient.c:520
SKDP_EXPORT_API void skdp_client_connection_close(skdp_client_state *ctx, qsc_socket *sock, skdp_errors error)
Close the remote session and dispose of client resources.
Definition skdpclient.c:562
The SKDP client state structure.
Definition skdpclient.h:85
uint64_t txseq
Definition skdpclient.h:94
uint8_t ssh[SKDP_STH_SIZE]
Definition skdpclient.h:91
uint8_t kid[SKDP_KID_SIZE]
Definition skdpclient.h:90
uint64_t expiration
Definition skdpclient.h:92
qsc_rcs_state txcpr
Definition skdpclient.h:87
uint64_t rxseq
Definition skdpclient.h:93
skdp_flags exflag
Definition skdpclient.h:95
uint8_t ddk[SKDP_DDK_SIZE]
Definition skdpclient.h:88
qsc_rcs_state rxcpr
Definition skdpclient.h:86
uint8_t dsh[SKDP_STH_SIZE]
Definition skdpclient.h:89
The SKDP device key structure.
Definition skdp.h:584
The SKDP network packet structure.
Definition skdp.h:614