VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.2/providers/implementations/include/prov/blake2.h@ 101021

Last change on this file since 101021 was 101021, checked in by vboxsync, 15 months ago

openssl-3.1.2: Applied and adjusted our OpenSSL changes to 3.1.0. bugref:10519

File size: 4.0 KB
Line 
1/*
2 * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_PROV_BLAKE2_H
11# define OSSL_PROV_BLAKE2_H
12
13# include <openssl/opensslconf.h>
14
15# include <openssl/e_os2.h>
16# include <stddef.h>
17
18# define BLAKE2S_BLOCKBYTES 64
19# define BLAKE2S_OUTBYTES 32
20# define BLAKE2S_KEYBYTES 32
21# define BLAKE2S_SALTBYTES 8
22# define BLAKE2S_PERSONALBYTES 8
23
24# define BLAKE2B_BLOCKBYTES 128
25# define BLAKE2B_OUTBYTES 64
26# define BLAKE2B_KEYBYTES 64
27# define BLAKE2B_SALTBYTES 16
28# define BLAKE2B_PERSONALBYTES 16
29
30struct blake2s_param_st {
31 uint8_t digest_length; /* 1 */
32 uint8_t key_length; /* 2 */
33 uint8_t fanout; /* 3 */
34 uint8_t depth; /* 4 */
35 uint8_t leaf_length[4];/* 8 */
36 uint8_t node_offset[6];/* 14 */
37 uint8_t node_depth; /* 15 */
38 uint8_t inner_length; /* 16 */
39 uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
40 uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
41};
42
43typedef struct blake2s_param_st BLAKE2S_PARAM;
44
45struct blake2s_ctx_st {
46 uint32_t h[8];
47 uint32_t t[2];
48 uint32_t f[2];
49 uint8_t buf[BLAKE2S_BLOCKBYTES];
50 size_t buflen;
51 size_t outlen;
52};
53
54struct blake2b_param_st {
55 uint8_t digest_length; /* 1 */
56 uint8_t key_length; /* 2 */
57 uint8_t fanout; /* 3 */
58 uint8_t depth; /* 4 */
59 uint8_t leaf_length[4];/* 8 */
60 uint8_t node_offset[8];/* 16 */
61 uint8_t node_depth; /* 17 */
62 uint8_t inner_length; /* 18 */
63 uint8_t reserved[14]; /* 32 */
64 uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
65 uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
66};
67
68typedef struct blake2b_param_st BLAKE2B_PARAM;
69
70struct blake2b_ctx_st {
71 uint64_t h[8];
72 uint64_t t[2];
73 uint64_t f[2];
74 uint8_t buf[BLAKE2B_BLOCKBYTES];
75 size_t buflen;
76 size_t outlen;
77};
78
79#define BLAKE2B_DIGEST_LENGTH 64
80#define BLAKE2S_DIGEST_LENGTH 32
81
82typedef struct blake2s_ctx_st BLAKE2S_CTX;
83typedef struct blake2b_ctx_st BLAKE2B_CTX;
84
85int ossl_blake2s256_init(void *ctx);
86int ossl_blake2b512_init(void *ctx);
87
88int ossl_blake2b_init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P);
89int ossl_blake2b_init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P,
90 const void *key);
91int ossl_blake2b_update(BLAKE2B_CTX *c, const void *data, size_t datalen);
92int ossl_blake2b_final(unsigned char *md, BLAKE2B_CTX *c);
93
94/*
95 * These setters are internal and do not check the validity of their parameters.
96 * See blake2b_mac_ctrl for validation logic.
97 */
98
99void ossl_blake2b_param_init(BLAKE2B_PARAM *P);
100void ossl_blake2b_param_set_digest_length(BLAKE2B_PARAM *P, uint8_t outlen);
101void ossl_blake2b_param_set_key_length(BLAKE2B_PARAM *P, uint8_t keylen);
102void ossl_blake2b_param_set_personal(BLAKE2B_PARAM *P, const uint8_t *personal,
103 size_t length);
104void ossl_blake2b_param_set_salt(BLAKE2B_PARAM *P, const uint8_t *salt,
105 size_t length);
106int ossl_blake2s_init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P);
107int ossl_blake2s_init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P,
108 const void *key);
109int ossl_blake2s_update(BLAKE2S_CTX *c, const void *data, size_t datalen);
110int ossl_blake2s_final(unsigned char *md, BLAKE2S_CTX *c);
111
112void ossl_blake2s_param_init(BLAKE2S_PARAM *P);
113void ossl_blake2s_param_set_digest_length(BLAKE2S_PARAM *P, uint8_t outlen);
114void ossl_blake2s_param_set_key_length(BLAKE2S_PARAM *P, uint8_t keylen);
115void ossl_blake2s_param_set_personal(BLAKE2S_PARAM *P, const uint8_t *personal,
116 size_t length);
117void ossl_blake2s_param_set_salt(BLAKE2S_PARAM *P, const uint8_t *salt,
118 size_t length);
119
120#endif /* OSSL_PROV_BLAKE2_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette