From f19f813537c7aea1c20749c914e756b54a9c3cf5 Mon Sep 17 00:00:00 2001 From: Igor Pavlov <87184205+ip7z@users.noreply.github.com> Date: Mon, 27 Dec 2021 00:00:00 +0000 Subject: '21.07' --- C/Blake2.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 C/Blake2.h (limited to 'C/Blake2.h') diff --git a/C/Blake2.h b/C/Blake2.h new file mode 100644 index 0000000..14f3cb6 --- /dev/null +++ b/C/Blake2.h @@ -0,0 +1,48 @@ +/* Blake2.h -- BLAKE2 Hash +2015-06-30 : Igor Pavlov : Public domain +2015 : Samuel Neves : Public domain */ + +#ifndef __BLAKE2_H +#define __BLAKE2_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define BLAKE2S_BLOCK_SIZE 64 +#define BLAKE2S_DIGEST_SIZE 32 +#define BLAKE2SP_PARALLEL_DEGREE 8 + +typedef struct +{ + UInt32 h[8]; + UInt32 t[2]; + UInt32 f[2]; + Byte buf[BLAKE2S_BLOCK_SIZE]; + UInt32 bufPos; + UInt32 lastNode_f1; + UInt32 dummy[2]; /* for sizeof(CBlake2s) alignment */ +} CBlake2s; + +/* You need to xor CBlake2s::h[i] with input parameter block after Blake2s_Init0() */ +/* +void Blake2s_Init0(CBlake2s *p); +void Blake2s_Update(CBlake2s *p, const Byte *data, size_t size); +void Blake2s_Final(CBlake2s *p, Byte *digest); +*/ + + +typedef struct +{ + CBlake2s S[BLAKE2SP_PARALLEL_DEGREE]; + unsigned bufPos; +} CBlake2sp; + + +void Blake2sp_Init(CBlake2sp *p); +void Blake2sp_Update(CBlake2sp *p, const Byte *data, size_t size); +void Blake2sp_Final(CBlake2sp *p, Byte *digest); + +EXTERN_C_END + +#endif -- cgit v1.2.3-55-g6feb