VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/kuznyechik.h
blob: f0b45b6401abec4e0ab658e6c0565bbefe4321fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/)
and released into public domain.
*/

/* Adapted to VeraCrypt */

#ifndef CPPCRYPTO_KUZNYECHIK_H
#define CPPCRYPTO_KUZNYECHIK_H

#include "Common/Tcdefs.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _kuznyechik_kds
{
	uint64 rke[20];
	uint64 rkd[20];
} kuznyechik_kds;

#define KUZNYECHIK_KS				(sizeof(kuznyechik_kds))

void kuznyechik_encrypt_block(byte* out, const byte* in, kuznyechik_kds* kds);
void kuznyechik_encrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds);
void kuznyechik_decrypt_block(byte* out, const byte* in, kuznyechik_kds* kds);
void kuznyechik_decrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds);
void kuznyechik_set_key(const byte* key, kuznyechik_kds *kds);

#ifdef __cplusplus
}
#endif

#endif
>bad_alloc(); return bufPtr; } void *Memory::AllocateAligned (std::size_t size, std::size_t alignment) { if (size < 1) throw ParameterIncorrect (SRC_POS); #ifdef TC_WINDOWS void *bufPtr = _aligned_malloc (size, alignment); #else void *bufPtr = NULL; if (0 != posix_memalign (&bufPtr, alignment, size)) bufPtr = NULL; #endif if (!bufPtr) throw bad_alloc(); return bufPtr; } int Memory::Compare (const void *memory1, size_t size1, const void *memory2, size_t size2) { if (size1 > size2) return 1; else if (size1 < size2) return -1; return memcmp (memory1, memory2, size1); } void Memory::Copy (void *memoryDestination, const void *memorySource, size_t size) { assert (memoryDestination != nullptr && memorySource != nullptr); memcpy (memoryDestination, memorySource, size); } void Memory::Erase (void *memory, size_t size) { burn (memory, size); } void Memory::Zero (void *memory, size_t size) { memset (memory, 0, size); } void Memory::Free (void *memory) { assert (memory != nullptr); free (memory); } void Memory::FreeAligned (void *memory) { assert (memory != nullptr); #ifdef TC_WINDOWS _aligned_free (memory); #else free (memory); #endif } }