Monero
Loading...
Searching...
No Matches
blake2.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018-2019, tevador <tevador@gmail.com>
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the copyright holder nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29/* Original code from Argon2 reference source code package used under CC0 Licence
30 * https://github.com/P-H-C/phc-winner-argon2
31 * Copyright 2015
32 * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
33*/
34
35#ifndef PORTABLE_BLAKE2_H
36#define PORTABLE_BLAKE2_H
37
38#include <stdint.h>
39#include <limits.h>
40
41#if defined(__cplusplus)
42extern "C" {
43#endif
44
52
53#pragma pack(push, 1)
67#pragma pack(pop)
68
78
79 /* Ensure param structs have not been wrongly padded */
80 /* Poor man's static_assert */
81 enum {
82 blake2_size_check_0 = 1 / !!(CHAR_BIT == 8),
84 1 / !!(sizeof(blake2b_param) == sizeof(uint64_t) * CHAR_BIT)
85 };
86
87 //randomx namespace
88#define blake2b_init randomx_blake2b_init
89#define blake2b_init_key randomx_blake2b_init_key
90#define blake2b_init_param randomx_blake2b_init_param
91#define blake2b_update randomx_blake2b_update
92#define blake2b_final randomx_blake2b_final
93#define blake2b randomx_blake2b
94#define blake2b_long randomx_blake2b_long
95
96 /* Streaming API */
97 int blake2b_init(blake2b_state *S, size_t outlen);
98 int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
99 size_t keylen);
101 int blake2b_update(blake2b_state *S, const void *in, size_t inlen);
102 int blake2b_final(blake2b_state *S, void *out, size_t outlen);
103
104 /* Simple API */
105 int blake2b(void *out, size_t outlen, const void *in, size_t inlen,
106 const void *key, size_t keylen);
107
108 /* Argon2 Team - Begin Code */
109 int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen);
110 /* Argon2 Team - End Code */
111
112#if defined(__cplusplus)
113}
114#endif
115
116#endif
struct __blake2b_state blake2b_state
#define blake2b_update
Definition blake2.h:91
#define blake2b
Definition blake2.h:93
blake2b_constant
Definition blake2.h:45
@ BLAKE2B_PERSONALBYTES
Definition blake2.h:50
@ BLAKE2B_KEYBYTES
Definition blake2.h:48
@ BLAKE2B_OUTBYTES
Definition blake2.h:47
@ BLAKE2B_SALTBYTES
Definition blake2.h:49
@ BLAKE2B_BLOCKBYTES
Definition blake2.h:46
@ blake2_size_check_0
Definition blake2.h:82
@ blake2_size_check_2
Definition blake2.h:83
#define blake2b_final
Definition blake2.h:92
#define blake2b_init
Definition blake2.h:88
#define blake2b_long
Definition blake2.h:94
#define blake2b_init_key
Definition blake2.h:89
#define blake2b_init_param
Definition blake2.h:90
struct __blake2b_param blake2b_param
const char * key
Definition hmac_keccak.cpp:40
#define S(s)
Definition mdb_load.c:52
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition blake2.h:54
uint8_t reserved[14]
Definition blake2.h:63
uint8_t inner_length
Definition blake2.h:62
uint32_t leaf_length
Definition blake2.h:59
uint8_t node_depth
Definition blake2.h:61
uint8_t fanout
Definition blake2.h:57
uint8_t digest_length
Definition blake2.h:55
uint8_t salt[BLAKE2B_SALTBYTES]
Definition blake2.h:64
uint8_t depth
Definition blake2.h:58
uint64_t node_offset
Definition blake2.h:60
uint8_t key_length
Definition blake2.h:56
uint8_t personal[BLAKE2B_PERSONALBYTES]
Definition blake2.h:65
Definition blake2.h:69
uint8_t last_node
Definition blake2.h:76
uint64_t t[2]
Definition blake2.h:71
uint64_t f[2]
Definition blake2.h:72
unsigned buflen
Definition blake2.h:74
uint64_t h[8]
Definition blake2.h:70
unsigned outlen
Definition blake2.h:75
uint8_t buf[BLAKE2B_BLOCKBYTES]
Definition blake2.h:73