HKDS: Heirarchal Key Derivation System 1.0.0.2 (A2)
A fast post-quantum secure replacement for DUKPT
hkds_factory.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 HKDS_FACTORY_H
41#define HKDS_FACTORY_H
42
43#include "common.h"
44#include "hkds_config.h"
45
59
60/* convert header to serialized packet */
61
68HKDS_EXPORT_API void hkds_factory_serialize_packet_header(uint8_t* output, const hkds_packet_header* header);
69
76HKDS_EXPORT_API void hkds_factory_serialize_client_message(uint8_t* output, const hkds_client_message_request* header);
77
84HKDS_EXPORT_API void hkds_factory_serialize_client_token(uint8_t* output, const hkds_client_token_request* header);
85
92HKDS_EXPORT_API void hkds_factory_serialize_server_message(uint8_t* output, const hkds_server_message_response* header);
93
100HKDS_EXPORT_API void hkds_factory_serialize_server_token(uint8_t* output, const hkds_server_token_response* header);
101
108HKDS_EXPORT_API void hkds_factory_serialize_administrative_message(uint8_t* output, const hkds_administrative_message* header);
109
116HKDS_EXPORT_API void hkds_factory_serialize_error_message(uint8_t* output, const hkds_error_message* header);
117
118/* convert serialized packet to header */
119
126HKDS_EXPORT_API hkds_packet_header hkds_factory_extract_packet_header(const uint8_t* input);
127
134HKDS_EXPORT_API hkds_client_message_request hkds_factory_extract_client_message(const uint8_t* input);
135
142HKDS_EXPORT_API hkds_client_token_request hkds_factory_extract_client_token(const uint8_t* input);
143
150HKDS_EXPORT_API hkds_server_message_response hkds_factory_extract_server_message(const uint8_t* input);
151
158HKDS_EXPORT_API hkds_server_token_response hkds_factory_extract_server_token(const uint8_t* input);
159
167
174HKDS_EXPORT_API hkds_error_message hkds_factory_extract_error_message(const uint8_t* input);
175
176/* packet construction */
177
186HKDS_EXPORT_API hkds_client_message_request hkds_factory_create_client_message_request(const uint8_t* message, const uint8_t* ksn, const uint8_t* tag);
187
195
203
211
218HKDS_EXPORT_API hkds_administrative_message hkds_factory_create_administrative_message(const uint8_t* message);
219
227HKDS_EXPORT_API hkds_error_message hkds_factory_create_error_message(const uint8_t* message, hkds_error_type err);
228
229/* raw packet value extraction */
230
237HKDS_EXPORT_API hkds_packet_type hkds_factory_extract_packet_type(const uint8_t* input);
238
245HKDS_EXPORT_API hkds_protocol_id hkds_factory_extract_protocol_id(const uint8_t* input);
246
253HKDS_EXPORT_API size_t hkds_factory_extract_packet_size(const uint8_t* input);
254
261HKDS_EXPORT_API uint8_t hkds_factory_extract_packet_sequence(const uint8_t* input);
262
263#endif
HKDS configuration definitions.
hkds_error_type
Enumerates the error types for HKDS packet communications.
Definition hkds_config.h:119
hkds_packet_type
Enumerates the types of packets used in HKDS communications.
Definition hkds_config.h:79
hkds_protocol_id
Enumerates the supported cryptographic protocol identifiers.
Definition hkds_config.h:98
HKDS_EXPORT_API hkds_client_message_request hkds_factory_create_client_message_request(const uint8_t *message, const uint8_t *ksn, const uint8_t *tag)
Build a client message request from components.
Definition hkds_factory.c:108
HKDS_EXPORT_API hkds_packet_type hkds_factory_extract_packet_type(const uint8_t *input)
Extract the packet type enumeral from a serialized packet header.
Definition hkds_factory.c:224
HKDS_EXPORT_API void hkds_factory_serialize_server_message(uint8_t *output, const hkds_server_message_response *header)
Serialize a server message response to a byte array.
Definition hkds_factory.c:21
HKDS_EXPORT_API hkds_client_token_request hkds_factory_create_client_token_request(const uint8_t *ksn)
Build a client token request from components.
Definition hkds_factory.c:132
HKDS_EXPORT_API hkds_error_message hkds_factory_create_error_message(const uint8_t *message, hkds_error_type err)
Build an error message from components.
Definition hkds_factory.c:204
HKDS_EXPORT_API void hkds_factory_serialize_client_message(uint8_t *output, const hkds_client_message_request *header)
Serialize a client message request to a byte array.
Definition hkds_factory.c:11
HKDS_EXPORT_API hkds_packet_header hkds_factory_extract_packet_header(const uint8_t *input)
Extract a packet header structure from a byte array.
Definition hkds_factory.c:43
HKDS_EXPORT_API void hkds_factory_serialize_server_token(uint8_t *output, const hkds_server_token_response *header)
Serialize a server token response to a byte array.
Definition hkds_factory.c:26
HKDS_EXPORT_API void hkds_factory_serialize_error_message(uint8_t *output, const hkds_error_message *header)
Serialize an error message to a byte array.
Definition hkds_factory.c:36
HKDS_EXPORT_API hkds_server_message_response hkds_factory_create_server_message_response(const uint8_t *message)
Build a server message response from components.
Definition hkds_factory.c:150
HKDS_EXPORT_API hkds_client_message_request hkds_factory_extract_client_message(const uint8_t *input)
Extract a client message request from a byte array.
Definition hkds_factory.c:52
HKDS_EXPORT_API void hkds_factory_serialize_client_token(uint8_t *output, const hkds_client_token_request *header)
Serialize a client token request to a byte array.
Definition hkds_factory.c:16
HKDS_EXPORT_API hkds_administrative_message hkds_factory_extract_administrative_message(const uint8_t *input)
Extract an administrative message from a byte array.
Definition hkds_factory.c:88
HKDS_EXPORT_API void hkds_factory_serialize_packet_header(uint8_t *output, const hkds_packet_header *header)
Serialize a packet header to a byte array.
Definition hkds_factory.c:6
HKDS_EXPORT_API hkds_error_message hkds_factory_extract_error_message(const uint8_t *input)
Extract an error message from a byte array.
Definition hkds_factory.c:97
HKDS_EXPORT_API uint8_t hkds_factory_extract_packet_sequence(const uint8_t *input)
Extract the packet sequence from a serialized packet header.
Definition hkds_factory.c:251
HKDS_EXPORT_API hkds_server_message_response hkds_factory_extract_server_message(const uint8_t *input)
Extract a server message response from a byte array.
Definition hkds_factory.c:70
HKDS_EXPORT_API size_t hkds_factory_extract_packet_size(const uint8_t *input)
Extract the packet size from a serialized packet header.
Definition hkds_factory.c:242
HKDS_EXPORT_API hkds_server_token_response hkds_factory_create_server_token_reponse(const uint8_t *etok)
Build a server token response from components.
Definition hkds_factory.c:168
HKDS_EXPORT_API hkds_server_token_response hkds_factory_extract_server_token(const uint8_t *input)
Extract a server token response from a byte array.
Definition hkds_factory.c:79
HKDS_EXPORT_API hkds_protocol_id hkds_factory_extract_protocol_id(const uint8_t *input)
Extract the protocol id numeral from a serialized packet header.
Definition hkds_factory.c:233
HKDS_EXPORT_API hkds_client_token_request hkds_factory_extract_client_token(const uint8_t *input)
Extract a client token request from a byte array.
Definition hkds_factory.c:61
HKDS_EXPORT_API hkds_administrative_message hkds_factory_create_administrative_message(const uint8_t *message)
Build an administrative message from components.
Definition hkds_factory.c:186
HKDS_EXPORT_API void hkds_factory_serialize_administrative_message(uint8_t *output, const hkds_administrative_message *header)
Serialize an administrative message to a byte array.
Definition hkds_factory.c:31
Represents an administrative message packet.
Definition hkds_config.h:639
Represents the client's encrypted message request packet.
Definition hkds_config.h:573
Represents the client token request packet.
Definition hkds_config.h:591
Represents an error message packet.
Definition hkds_config.h:654
The primary header for all HKDS messages.
Definition hkds_config.h:554
Represents the server's plaintext message response packet.
Definition hkds_config.h:607
Represents the server's token response packet.
Definition hkds_config.h:623