FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
blake2s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Doc.ai and/or its affiliates.
3  * Copyright (c) 2012 Samuel Neves <sneves@dei.uc.pt>.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /*
17  More information about the BLAKE2 hash function can be found at
18  https://blake2.net.
19 */
20 
21 #ifndef __included_crypto_blake2s_h__
22 #define __included_crypto_blake2s_h__
23 
24 #include <vlib/vlib.h>
25 
26 #if defined(_MSC_VER)
27 #define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
28 #else
29 #define BLAKE2_PACKED(x) x __attribute__((packed))
30 #endif
31 
33 {
40 };
41 
42 typedef struct blake2s_state
43 {
44  uint32_t h[8];
45  uint32_t t[2];
46  uint32_t f[2];
48  size_t buflen;
49  size_t outlen;
50  uint8_t last_node;
52 
53 BLAKE2_PACKED (struct blake2s_param
54  {
55  uint8_t digest_length; /* 1 */
56  uint8_t key_length; /* 2 */
57  uint8_t fanout; /* 3 */
58  uint8_t depth; /* 4 */
59  uint32_t leaf_length; /* 8 */
60  uint32_t node_offset; /* 12 */
61  uint16_t xof_length; /* 14 */
62  uint8_t node_depth; /* 15 */
63  uint8_t inner_length; /* 16 */
64  /* uint8_t reserved[0]; */
65  uint8_t salt[BLAKE2S_SALT_BYTES]; /* 24 */
66  uint8_t personal[BLAKE2S_PERSONAL_BYTES]; /* 32 */
67  });
68 
69 typedef struct blake2s_param blake2s_param_t;
70 
71 /* Streaming API */
72 int blake2s_init (blake2s_state_t * S, size_t outlen);
73 int blake2s_init_key (blake2s_state_t * S, size_t outlen, const void *key,
74  size_t keylen);
76 int blake2s_update (blake2s_state_t * S, const void *in, size_t inlen);
77 int blake2s_final (blake2s_state_t * S, void *out, size_t outlen);
78 
79 int blake2s (void *out, size_t outlen, const void *in, size_t inlen,
80  const void *key, size_t keylen);
81 
82 #endif /* __included_crypto_blake2s_h__ */
83 
84 /*
85  * fd.io coding-style-patch-verification: ON
86  *
87  * Local Variables:
88  * eval: (c-set-style "gnu")
89  * End:
90  */
vlib.h
blake2s_init_key
int blake2s_init_key(blake2s_state_t *S, size_t outlen, const void *key, size_t keylen)
Definition: blake2s.c:129
blake2s_constant
blake2s_constant
Definition: blake2s.h:32
blake2s_state
Definition: blake2s.h:42
S
#define S(mp)
Definition: vat_helper_macros.h:79
blake2s_final
int blake2s_final(blake2s_state_t *S, void *out, size_t outlen)
Definition: blake2s.c:267
blake2s_state::buf
uint8_t buf[BLAKE2S_BLOCK_BYTES]
Definition: blake2s.h:47
BLAKE2S_OUT_BYTES
@ BLAKE2S_OUT_BYTES
Definition: blake2s.h:35
P
#define P(fmt,...)
BLAKE2S_BLOCK_BYTES
@ BLAKE2S_BLOCK_BYTES
Definition: blake2s.h:34
key
typedef key
Definition: ipsec_types.api:91
blake2s_state::t
uint32_t t[2]
Definition: blake2s.h:45
blake2s_state::last_node
uint8_t last_node
Definition: blake2s.h:50
BLAKE2S_HASH_SIZE
@ BLAKE2S_HASH_SIZE
Definition: blake2s.h:37
blake2s_update
int blake2s_update(blake2s_state_t *S, const void *in, size_t inlen)
Definition: blake2s.c:237
blake2s_state::buflen
size_t buflen
Definition: blake2s.h:48
blake2s_state::outlen
size_t outlen
Definition: blake2s.h:49
BLAKE2S_KEY_BYTES
@ BLAKE2S_KEY_BYTES
Definition: blake2s.h:36
blake2s
int blake2s(void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen)
Definition: blake2s.c:292
salt
u32 salt
Definition: ipsec_types.api:139
blake2s_state::h
uint32_t h[8]
Definition: blake2s.h:44
BLAKE2S_PERSONAL_BYTES
@ BLAKE2S_PERSONAL_BYTES
Definition: blake2s.h:39
BLAKE2_PACKED
#define BLAKE2_PACKED(x)
Definition: blake2s.h:29
blake2s_init
int blake2s_init(blake2s_state_t *S, size_t outlen)
Definition: blake2s.c:105
blake2s_init_param
int blake2s_init_param(blake2s_state_t *S, const blake2s_param_t *P)
Definition: blake2s.c:87
blake2s_state::f
uint32_t f[2]
Definition: blake2s.h:46
blake2s_param_t
struct blake2s_param blake2s_param_t
Definition: blake2s.h:69
blake2s_state_t
struct blake2s_state blake2s_state_t
BLAKE2S_SALT_BYTES
@ BLAKE2S_SALT_BYTES
Definition: blake2s.h:38