MPDC: Multi Party Domain Cryptosystem 1.0.0.0b (A0)
MPDC Interior protocol
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 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 MPDC_CRYPTO_H
41#define MPDC_CRYPTO_H
42
43#include "common.h"
44#include "mpdc.h"
45
79
84#define MPDC_CRYPTO_PHASH_CPU_COST 4
85
90#define MPDC_CRYPTO_PHASH_MEMORY_COST 1
91
102MPDC_EXPORT_API bool mpdc_crypto_decrypt_stream(uint8_t* output, const uint8_t* seed, const uint8_t* input, size_t length);
103
112MPDC_EXPORT_API void mpdc_crypto_encrypt_stream(uint8_t* output, const uint8_t* seed, const uint8_t* input, size_t length);
113
127MPDC_EXPORT_API void mpdc_crypto_generate_application_keychain(uint8_t* seed, size_t seedlen, const char* password, size_t passlen, const char* username, size_t userlen);
128
138MPDC_EXPORT_API void mpdc_crypto_generate_application_salt(uint8_t* output, size_t outlen);
139
149MPDC_EXPORT_API void mpdc_crypto_generate_hash_code(char* output, const char* message, size_t msglen);
150
163MPDC_EXPORT_API void mpdc_crypto_generate_mac_code(char* output, size_t outlen, const char* message, size_t msglen, const char* key, size_t keylen);
164
177MPDC_EXPORT_API void mpdc_crypto_hash_password(char* output, size_t outlen, const char* username, size_t userlen, const char* password, size_t passlen);
178
190MPDC_EXPORT_API bool mpdc_crypto_password_minimum_check(const char* password, size_t passlen);
191
206MPDC_EXPORT_API bool mpdc_crypto_password_verify(const char* username, size_t userlen, const char* password, size_t passlen, const char* hash, size_t hashlen);
207
217MPDC_EXPORT_API uint8_t* mpdc_crypto_secure_memory_allocate(size_t length);
218
227MPDC_EXPORT_API void mpdc_crypto_secure_memory_deallocate(uint8_t* block, size_t length);
228
229
230#endif
MPDC_EXPORT_API uint8_t * mpdc_crypto_secure_memory_allocate(size_t length)
Allocate a block of secure memory.
Definition crypto.c:12
MPDC_EXPORT_API void mpdc_crypto_generate_hash_code(char *output, const char *message, size_t msglen)
Hash a message and write the resulting hash to an output array.
Definition crypto.c:145
MPDC_EXPORT_API void mpdc_crypto_generate_application_salt(uint8_t *output, size_t outlen)
Generate a user-unique application salt from OS sources.
Definition crypto.c:125
MPDC_EXPORT_API void mpdc_crypto_secure_memory_deallocate(uint8_t *block, size_t length)
Release an allocated block of secure memory.
Definition crypto.c:33
MPDC_EXPORT_API bool mpdc_crypto_password_verify(const char *username, size_t userlen, const char *password, size_t passlen, const char *hash, size_t hashlen)
Verify a password against a stored hash.
Definition crypto.c:239
MPDC_EXPORT_API bool mpdc_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:71
MPDC_EXPORT_API void mpdc_crypto_hash_password(char *output, size_t outlen, const char *username, size_t userlen, const char *password, size_t passlen)
Hash a password and user name.
Definition crypto.c:172
MPDC_EXPORT_API void mpdc_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:46
MPDC_EXPORT_API bool mpdc_crypto_password_minimum_check(const char *password, size_t passlen)
Check a password for a minimum secure threshold.
Definition crypto.c:190
MPDC_EXPORT_API void mpdc_crypto_generate_mac_code(char *output, size_t outlen, const char *message, size_t msglen, const char *key, size_t keylen)
Compute a MAC (Message Authentication Code) for a message.
Definition crypto.c:157
MPDC_EXPORT_API void mpdc_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:101
MPDC Common Definitions and Protocol Configuration.