Debian Codegraph @

deps/phc-winner-argon2-20190702/_hashcat/blake2/blake2.h

raw symbols SCIP
1 /*
2 * Argon2 reference source code package - reference C implementations
3 *
4 * Copyright 2015
5 * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
6 *
7 * You may use this work under the terms of a Creative Commons CC0 1.0
8 * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9 * these licenses can be found at:
10 *
11 * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
12 * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * You should have received a copy of both of these licenses along with this
15 * software. If not, they may be obtained at the above URLs.
16 */
17
18 #ifndef PORTABLE_BLAKE2_H
19 #define PORTABLE_BLAKE2_H
20
21 #if defined(__cplusplus)
22 extern "C" {
23 #endif
24
25 enum blake2b_constant {
26 BLAKE2B_BLOCKBYTES = 128,
27 BLAKE2B_OUTBYTES = 64,
28 BLAKE2B_KEYBYTES = 64,
29 BLAKE2B_SALTBYTES = 16,
30 BLAKE2B_PERSONALBYTES = 16
31 };
32
33 #pragma pack(push, 1)
34 typedef struct __blake2b_param {
35 uint8_t digest_length; /* 1 */
36 uint8_t key_length; /* 2 */
37 uint8_t fanout; /* 3 */
38 uint8_t depth; /* 4 */
39 uint32_t leaf_length; /* 8 */
40 uint64_t node_offset; /* 16 */
41 uint8_t node_depth; /* 17 */
42 uint8_t inner_length; /* 18 */
43 uint8_t reserved[14]; /* 32 */
44 uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
45 uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
46 } blake2b_param;
47 #pragma pack(pop)
48
49 typedef struct __blake2b_state {
50 uint64_t h[8];
51 uint64_t t[2];
52 uint64_t f[2];
53 uint8_t buf[BLAKE2B_BLOCKBYTES];
54 unsigned buflen;
55 unsigned outlen;
56 uint8_t last_node;
57 } blake2b_state;
58
59 /* Ensure param structs have not been wrongly padded */
60 /* Poor man's static_assert */
61 enum {
62 blake2_size_check_0 = 1 / !!(CHAR_BIT == 8),
63 blake2_size_check_2 =
64 1 / !!(sizeof(blake2b_param) == sizeof(uint64_t) * CHAR_BIT)
65 };
66
67 /* Streaming API */
68 ARGON2_LOCAL int blake2b_init(blake2b_state *S, size_t outlen);
69 ARGON2_LOCAL int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
70 size_t keylen);
71 ARGON2_LOCAL int blake2b_init_param(blake2b_state *S, const blake2b_param *P);
72 ARGON2_LOCAL int blake2b_update(blake2b_state *S, const void *in, size_t inlen);
73 ARGON2_LOCAL int blake2b_final(blake2b_state *S, void *out, size_t outlen);
74
75 /* Simple API */
76 ARGON2_LOCAL int blake2b(void *out, size_t outlen, const void *in, size_t inlen,
77 const void *key, size_t keylen);
78
79 /* Argon2 Team - Begin Code */
80 ARGON2_LOCAL int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen);
81 /* Argon2 Team - End Code */
82
83 #if defined(__cplusplus)
84 }
85 #endif
86
87 #endif