mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 11:28:26 -06:00
Windows: Add implementation of ChaCha20 based random generator. Use it for driver need of random bytes (currently only wipe bytes but more to come later).
This commit is contained in:
31
src/Crypto/chacha256.h
Normal file
31
src/Crypto/chacha256.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef HEADER_Crypto_ChaCha256
|
||||
#define HEADER_Crypto_ChaCha256
|
||||
|
||||
#include "Common/Tcdefs.h"
|
||||
#include "config.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CRYPTOPP_ALIGN_DATA(16) uint32 block_[16];
|
||||
CRYPTOPP_ALIGN_DATA(16) uint32 input_[16];
|
||||
size_t pos;
|
||||
int internalRounds;
|
||||
} ChaCha256Ctx;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* key must be 32 bytes long and iv must be 8 bytes long
|
||||
*/
|
||||
void ChaCha256Init(ChaCha256Ctx* ctx, const unsigned char* key, const unsigned char* iv, int rounds);
|
||||
void ChaCha256Encrypt(ChaCha256Ctx* ctx, const unsigned char* in, size_t len, unsigned char* out);
|
||||
#define ChaCha256Decrypt ChaCha256Encrypt
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HEADER_Crypto_ChaCha
|
||||
|
||||
Reference in New Issue
Block a user