From 781b2a91f056b53cb847bc1b2a8745ca34cc7b55 Mon Sep 17 00:00:00 2001 From: Knogle Date: Wed, 13 Mar 2024 21:16:32 +0000 Subject: [PATCH] We need to know who's responsible for the stuff here if something breaks :) Public domain comment. --- src/aes/aes_ctr_prng.c | 24 ++++++++++++++++++++++++ src/aes/aes_ctr_prng.h | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/aes/aes_ctr_prng.c b/src/aes/aes_ctr_prng.c index 639e54a2..4b127dc8 100644 --- a/src/aes/aes_ctr_prng.c +++ b/src/aes/aes_ctr_prng.c @@ -1,3 +1,27 @@ +/* + * AES CTR PRNG Implementation + * Author: Fabian Druschke + * Date: 2024-03-13 + * + * This is an AES (Advanced Encryption Standard) implementation in CTR (Counter) mode + * for pseudorandom number generation, utilizing OpenSSL for cryptographic functions. + * + * As the author of this implementation, I, Fabian Druschke, hereby release this work into + * the public domain. I dedicate any and all copyright interest in this work to the public + * domain, making it free to use for anyone for any purpose without any conditions, unless + * such conditions are required by law. + * + * This software is provided "as is", without warranty of any kind, express or implied, + * including but not limited to the warranties of merchantability, fitness for a particular + * purpose and noninfringement. In no event shall the authors be liable for any claim, + * damages or other liability, whether in an action of contract, tort or otherwise, arising + * from, out of or in connection with the software or the use or other dealings in the software. + * + * USAGE OF OPENSSL IN THIS SOFTWARE: + * This software uses OpenSSL for cryptographic operations. Users are responsible for + * ensuring compliance with OpenSSL's licensing terms. + */ + #include "aes_ctr_prng.h" #include #include diff --git a/src/aes/aes_ctr_prng.h b/src/aes/aes_ctr_prng.h index 0542c2d7..24917026 100644 --- a/src/aes/aes_ctr_prng.h +++ b/src/aes/aes_ctr_prng.h @@ -1,3 +1,28 @@ +/* + * AES CTR PRNG Definitions + * Author: Fabian Druschke + * Date: 2024-03-13 + * + * This header file contains definitions for the AES (Advanced Encryption Standard) + * implementation in CTR (Counter) mode for pseudorandom number generation, utilizing + * OpenSSL for cryptographic functions. + * + * As the author of this work, I, Fabian Druschke, hereby release this work into the public + * domain. I dedicate any and all copyright interest in this work to the public domain, + * making it free to use for anyone for any purpose without any conditions, unless such + * conditions are required by law. + * + * This software is provided "as is", without warranty of any kind, express or implied, + * including but not limited to the warranties of merchantability, fitness for a particular + * purpose and noninfringement. In no event shall the authors be liable for any claim, + * damages or other liability, whether in an action of contract, tort or otherwise, arising + * from, out of or in connection with the software or the use or other dealings in the software. + * + * USAGE OF OPENSSL IN THIS SOFTWARE: + * This software uses OpenSSL for cryptographic operations. Users are responsible for + * ensuring compliance with OpenSSL's licensing terms. + */ + #ifndef AES_CTR_RNG_H #define AES_CTR_RNG_H @@ -5,18 +30,18 @@ #include // Structure to store the state of the AES-CTR random number generator -typedef struct { - AES_KEY aes_key; // AES key for encryption - unsigned char ivec[AES_BLOCK_SIZE]; // Initialization vector - unsigned int num; // Number of bytes that have been processed - unsigned char ecount[AES_BLOCK_SIZE]; // Encryption counter block +typedef struct +{ + AES_KEY aes_key; // AES key for encryption + unsigned char ivec[AES_BLOCK_SIZE]; // Initialization vector + unsigned int num; // Number of bytes that have been processed + unsigned char ecount[AES_BLOCK_SIZE]; // Encryption counter block } aes_ctr_state_t; // Initializes the AES-CTR random number generator -void init_aes_ctr(aes_ctr_state_t* state, const unsigned char* key); +void init_aes_ctr( aes_ctr_state_t* state, const unsigned char* key ); // Generates a 128-bit random number using AES-CTR and stores it directly in the output buffer -void aes_ctr_prng_genrand_uint128_to_buf(aes_ctr_state_t* state, unsigned char* bufpos); +void aes_ctr_prng_genrand_uint128_to_buf( aes_ctr_state_t* state, unsigned char* bufpos ); #endif // AES_CTR_RNG_H -