UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
crypto.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 STANDAARS:
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: contact@qrcscorp.ca
38 */
39
40#ifndef UDIF_CRYPTO_H
41#define UDIF_CRYPTO_H
42
43#include "udifcommon.h"
44#include "udif.h"
45
79
84#define UDIF_CRYPTO_PHASH_CPU_COST 4U
85
90#define UDIF_CRYPTO_PHASH_MEMORY_COST 1U
91
102UDIF_EXPORT_API bool udif_crypto_decrypt_stream(uint8_t* output, const uint8_t* seed, const uint8_t* input, size_t length);
103
112UDIF_EXPORT_API void udif_crypto_encrypt_stream(uint8_t* output, const uint8_t* seed, const uint8_t* input, size_t length);
113
127UDIF_EXPORT_API void udif_crypto_generate_application_keychain(uint8_t* seed, size_t seedlen, const char* password, size_t passlen, const char* username, size_t userlen);
128
138UDIF_EXPORT_API void udif_crypto_generate_application_salt(uint8_t* output, size_t outlen);
139
149UDIF_EXPORT_API void udif_crypto_generate_hash_code(uint8_t* output, const uint8_t* message, size_t msglen);
150
163UDIF_EXPORT_API void udif_crypto_generate_mac_code(uint8_t* output, size_t outlen, const uint8_t* message, size_t msglen, const uint8_t* key, size_t keylen);
164
177UDIF_EXPORT_API void udif_crypto_hash_password(uint8_t* output, size_t outlen, const uint8_t* username, size_t userlen, const uint8_t* password, size_t passlen);
178
190UDIF_EXPORT_API bool udif_crypto_password_minimum_check(const char* password, size_t passlen);
191
206UDIF_EXPORT_API bool udif_crypto_password_verify(const uint8_t* username, size_t userlen, const uint8_t* password, size_t passlen, const uint8_t* hash, size_t hashlen);
207
217UDIF_EXPORT_API uint8_t* udif_crypto_secure_memory_allocate(size_t length);
218
227UDIF_EXPORT_API void udif_crypto_secure_memory_deallocate(uint8_t* block, size_t length);
228
229#endif
UDIF_EXPORT_API void udif_crypto_generate_hash_code(uint8_t *output, const uint8_t *message, size_t msglen)
Hash a message and write the resulting hash to an output array.
Definition crypto.c:143
UDIF_EXPORT_API void udif_crypto_generate_application_salt(uint8_t *output, size_t outlen)
Generate a user-unique application salt from OS sources.
Definition crypto.c:123
UDIF_EXPORT_API bool udif_crypto_password_verify(const uint8_t *username, size_t userlen, const uint8_t *password, size_t passlen, const uint8_t *hash, size_t hashlen)
Verify a password against a stored hash.
Definition crypto.c:237
UDIF_EXPORT_API void udif_crypto_hash_password(uint8_t *output, size_t outlen, const uint8_t *username, size_t userlen, const uint8_t *password, size_t passlen)
Hash a password and user name.
Definition crypto.c:170
UDIF_EXPORT_API void udif_crypto_secure_memory_deallocate(uint8_t *block, size_t length)
Release an allocated block of secure memory.
Definition crypto.c:31
UDIF_EXPORT_API void udif_crypto_generate_application_keychain(uint8_t *seed, size_t seedlen, const char *password, size_t passlen, const char *username, size_t userlen)
Generate a secure application key chain.
Definition crypto.c:44
UDIF_EXPORT_API bool udif_crypto_decrypt_stream(uint8_t *output, const uint8_t *seed, const uint8_t *input, size_t length)
Decrypt a stream of bytes.
Definition crypto.c:69
UDIF_EXPORT_API bool udif_crypto_password_minimum_check(const char *password, size_t passlen)
Check a password for a minimum secure threshold.
Definition crypto.c:188
UDIF_EXPORT_API void udif_crypto_generate_mac_code(uint8_t *output, size_t outlen, const uint8_t *message, size_t msglen, const uint8_t *key, size_t keylen)
Compute a MAC (Message Authentication Code) for a message.
Definition crypto.c:155
UDIF_EXPORT_API uint8_t * udif_crypto_secure_memory_allocate(size_t length)
Allocate a block of secure memory.
Definition crypto.c:10
UDIF_EXPORT_API void udif_crypto_encrypt_stream(uint8_t *output, const uint8_t *seed, const uint8_t *input, size_t length)
Encrypt a stream of bytes.
Definition crypto.c:99
UDIF Common Definitions and Core Library Configuration.