Fabcoin Core  0.16.2
P2P Digital Currency
blake2.h
Go to the documentation of this file.
1 /*
2  BLAKE2 reference source code package - optimized C implementations
3 
4  Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
5 
6  To the extent possible under law, the author(s) have dedicated all copyright
7  and related and neighboring rights to this software to the public domain
8  worldwide. This software is distributed without any warranty.
9 
10  You should have received a copy of the CC0 Public Domain Dedication along with
11  this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
12 */
13 #pragma once
14 #ifndef __BLAKE2_H__
15 #define __BLAKE2_H__
16 
17 #include <stddef.h>
18 #include <stdint.h>
19 
20 #if defined(_MSC_VER)
21 #define ALIGN(x) __declspec(align(x))
22 #else
23 #define ALIGN(x) __attribute__ ((__aligned__(x)))
24 #endif
25 
26 #if defined(__cplusplus)
27 extern "C" {
28 #endif
29 
31  {
37  };
38 
39 #pragma pack(push, 1)
40  typedef struct __blake2b_param
41  {
42  uint8_t digest_length; // 1
43  uint8_t key_length; // 2
44  uint8_t fanout; // 3
45  uint8_t depth; // 4
46  uint32_t leaf_length; // 8
47  uint64_t node_offset; // 16
48  uint8_t node_depth; // 17
49  uint8_t inner_length; // 18
50  uint8_t reserved[14]; // 32
51  uint8_t salt[BLAKE2B_SALTBYTES]; // 48
53  } blake2b_param;
54 
55  ALIGN( 64 ) typedef struct __blake2b_state
56  {
57  uint64_t h[8];
58  uint8_t buf[BLAKE2B_BLOCKBYTES];
59  uint16_t counter;
60  uint8_t buflen;
61  uint8_t lastblock;
63 
64 #pragma pack(pop)
65 
66  int eq_blake2b_init( blake2b_state *S, const uint8_t outlen );
67  int eq_blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen );
69  int eq_blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen );
70  int eq_blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen );
71 
72  // Simple API
73  int eq_blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
74 
75  static inline int eq_blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
76  {
77  return eq_blake2b( out, in, key, outlen, inlen, keylen );
78  }
79 
80 #if defined(__cplusplus)
81 }
82 #endif
83 
84 #endif
85 
uint8_t inner_length
Definition: blake2.h:49
uint8_t salt[BLAKE2B_SALTBYTES]
Definition: blake2.h:51
#define h(i)
Definition: sha.cpp:736
int eq_blake2b_init_key(blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen)
Definition: blake2bx.cpp:88
int eq_blake2b_init_param(blake2b_state *S, const blake2b_param *P)
Definition: blake2bx.cpp:52
blake2b_constant
Definition: blake2.h:30
int eq_blake2b_update(blake2b_state *S, const uint8_t *in, uint64_t inlen)
Definition: blake2bx.cpp:192
uint8_t depth
Definition: blake2.h:45
int eq_blake2b(uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen)
Definition: blake2bx.cpp:242
blake2b_state
Definition: blake2.h:62
int eq_blake2b_final(blake2b_state *S, uint8_t *out, uint8_t outlen)
Definition: blake2bx.cpp:220
uint8_t fanout
Definition: blake2.h:44
uint8_t reserved[14]
Definition: blake2.h:50
uint64_t node_offset
Definition: blake2.h:47
#define P
struct __blake2b_param blake2b_param
int eq_blake2b_init(blake2b_state *S, const uint8_t outlen)
Definition: blake2bx.cpp:67
#define S(a)
Definition: mars.cpp:50
#define ALIGN(x)
Definition: blake2.h:23
uint8_t key_length
Definition: blake2.h:43
uint8_t personal[BLAKE2B_PERSONALBYTES]
Definition: blake2.h:52
uint32_t leaf_length
Definition: blake2.h:46
uint8_t node_depth
Definition: blake2.h:48
uint8_t digest_length
Definition: blake2.h:42