QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
collection.h
Go to the documentation of this file.
1/*
2 * 2025 Quantum Resistant Cryptographic Solutions Corporation
3 * All Rights Reserved.
4 *
5 * NOTICE: This software and all accompanying materials are the exclusive
6 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
7 * The intellectual and technical concepts contained within this implementation
8 * are proprietary to QRCS and its authorized licensors and are protected under
9 * applicable U.S. and international copyright, patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC STANDARDS:
12 * - This software includes implementations of cryptographic algorithms such as
13 * SHA3, AES, and others. These algorithms are public domain or standardized
14 * by organizations such as NIST and are NOT the property of QRCS.
15 * - However, all source code, optimizations, and implementations in this library
16 * are original works of QRCS and are protected under this license.
17 *
18 * RESTRICTIONS:
19 * - Redistribution, modification, or unauthorized distribution of this software,
20 * in whole or in part, is strictly prohibited.
21 * - This software is provided for non-commercial, educational, and research
22 * purposes only. Commercial use in any form is expressly forbidden.
23 * - Licensing and authorized distribution are solely at the discretion of QRCS.
24 * - Any use of this software implies acceptance of these restrictions.
25 *
26 * DISCLAIMER:
27 * This software is provided "as is," without warranty of any kind, express or
28 * implied, including but not limited to warranties of merchantability or fitness
29 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
30 * incidental, or consequential damages resulting from the use or misuse of this software.
31 *
32 * FULL LICENSE:
33 * This software is subject to the **Quantum Resistant Cryptographic Solutions
34 * Proprietary License (QRCS-PL)**. The complete license terms are included
35 * in the LICENSE.txt file distributed with this software.
36 *
37 * Written by: John G. Underhill
38 * Contact: john.underhill@protonmail.com
39 */
40
41#ifndef QSC_COLLECTION_H
42#define QSC_COLLECTION_H
43
44#include "common.h"
45
46QSC_CPLUSPLUS_ENABLED_START
47
89
94#define QSC_COLLECTION_KEY_WIDTH 16ULL
95
104typedef struct
105{
106 uint8_t* items;
107 uint8_t* keys;
108 uint32_t count;
109 uint32_t width;
111
121QSC_EXPORT_API void qsc_collection_add(qsc_collection_state* ctx, const uint8_t* item, const uint8_t* key);
122
131QSC_EXPORT_API void qsc_collection_deserialize(qsc_collection_state* ctx, const uint8_t* input);
132
141
150
161QSC_EXPORT_API bool qsc_collection_item_exists(const qsc_collection_state* ctx, const uint8_t* key);
162
174QSC_EXPORT_API bool qsc_collection_find(const qsc_collection_state* ctx, uint8_t* item, const uint8_t* key);
175
185
195QSC_EXPORT_API void qsc_collection_item(qsc_collection_state* ctx, uint8_t* item, size_t index);
196
205QSC_EXPORT_API void qsc_collection_remove(qsc_collection_state* ctx, const uint8_t* key);
206
217QSC_EXPORT_API size_t qsc_collection_serialize(uint8_t* output, const qsc_collection_state* ctx);
218
229
230#if defined(QSC_DEBUG_MODE)
238QSC_EXPORT_API bool qsc_collection_test(void);
239#endif
240
241QSC_CPLUSPLUS_ENABLED_END
242
243#endif
QSC_EXPORT_API void qsc_collection_initialize(qsc_collection_state *ctx, size_t width)
Initialize the collection.
Definition collection.c:172
QSC_EXPORT_API size_t qsc_collection_size(const qsc_collection_state *ctx)
Get the serialized collection size.
Definition collection.c:315
QSC_EXPORT_API void qsc_collection_erase(qsc_collection_state *ctx)
Erase the collection.
Definition collection.c:103
QSC_EXPORT_API bool qsc_collection_find(const qsc_collection_state *ctx, uint8_t *item, const uint8_t *key)
Find an item in the collection.
Definition collection.c:114
QSC_EXPORT_API void qsc_collection_deserialize(qsc_collection_state *ctx, const uint8_t *input)
Deserialize a collection.
Definition collection.c:55
QSC_EXPORT_API void qsc_collection_remove(qsc_collection_state *ctx, const uint8_t *key)
Remove an item from the collection.
Definition collection.c:205
QSC_EXPORT_API void qsc_collection_dispose(qsc_collection_state *ctx)
Dispose of the collection.
Definition collection.c:78
QSC_EXPORT_API void qsc_collection_item(qsc_collection_state *ctx, uint8_t *item, size_t index)
Retrieve a collection item by index.
Definition collection.c:188
QSC_EXPORT_API size_t qsc_collection_serialize(uint8_t *output, const qsc_collection_state *ctx)
Serialize the collection.
Definition collection.c:287
QSC_EXPORT_API void qsc_collection_add(qsc_collection_state *ctx, const uint8_t *item, const uint8_t *key)
Add an item to the collection.
Definition collection.c:9
QSC_EXPORT_API bool qsc_collection_item_exists(const qsc_collection_state *ctx, const uint8_t *key)
Check if an item exists in the collection.
Definition collection.c:148
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
Collection state structure.
Definition collection.h:105
uint8_t * keys
Definition collection.h:107
uint32_t width
Definition collection.h:109
uint32_t count
Definition collection.h:108
uint8_t * items
Definition collection.h:106