My Project
Loading...
Searching...
No Matches
blake2.h
Go to the documentation of this file.
1/* blake2.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
26#ifndef WOLF_CRYPT_BLAKE2_H
27#define WOLF_CRYPT_BLAKE2_H
28
29#include <wolfssl/wolfcrypt/settings.h>
30
31#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)
32
33#include <wolfssl/wolfcrypt/blake2-int.h>
34
35/* call old functions if using fips for the sake of hmac @wc_fips */
36#ifdef HAVE_FIPS
37 /* Since hmac can call blake functions provide original calls */
38 #define wc_InitBlake2b InitBlake2b
39 #define wc_Blake2bUpdate Blake2bUpdate
40 #define wc_Blake2bFinal Blake2bFinal
41#endif
42
43#ifdef __cplusplus
44 extern "C" {
45#endif
46
47/* in bytes, variable digest size up to 512 bits (64 bytes) */
48enum {
49#ifdef HAVE_BLAKE2B
50 BLAKE2B_ID = WC_HASH_TYPE_BLAKE2B,
51 BLAKE2B_256 = 32, /* 256 bit type, SSL default */
52#endif
53#ifdef HAVE_BLAKE2S
54 BLAKE2S_ID = WC_HASH_TYPE_BLAKE2S,
55 BLAKE2S_256 = 32 /* 256 bit type */
56#endif
57};
58
59
60#ifdef HAVE_BLAKE2B
61/* BLAKE2b digest */
62typedef struct Blake2b {
63 blake2b_state S[1]; /* our state */
64 word32 digestSz; /* digest size used on init */
65} Blake2b;
66#endif
67
68#ifdef HAVE_BLAKE2S
69/* BLAKE2s digest */
70typedef struct Blake2s {
71 blake2s_state S[1]; /* our state */
72 word32 digestSz; /* digest size used on init */
73} Blake2s;
74#endif
75
76
77#ifdef HAVE_BLAKE2B
78WOLFSSL_API int wc_InitBlake2b(Blake2b*, word32);
79WOLFSSL_API int wc_Blake2bUpdate(Blake2b*, const byte*, word32);
80WOLFSSL_API int wc_Blake2bFinal(Blake2b*, byte*, word32);
81#endif
82
83#ifdef HAVE_BLAKE2S
84WOLFSSL_API int wc_InitBlake2s(Blake2s*, word32);
85WOLFSSL_API int wc_Blake2sUpdate(Blake2s*, const byte*, word32);
86WOLFSSL_API int wc_Blake2sFinal(Blake2s*, byte*, word32);
87#endif
88
89
90#ifdef __cplusplus
91 }
92#endif
93
94#endif /* HAVE_BLAKE2 || HAVE_BLAKE2S */
95#endif /* WOLF_CRYPT_BLAKE2_H */
96
WOLFSSL_API int wc_InitBlake2b(Blake2b *, word32)
This function initializes a Blake2b structure for use with the Blake2 hash function.
Definition blake2b.c:422
WOLFSSL_API int wc_Blake2bUpdate(Blake2b *, const byte *, word32)
This function updates the Blake2b hash with the given input data. This function should be called afte...
Definition blake2b.c:434
WOLFSSL_API int wc_Blake2bFinal(Blake2b *, byte *, word32)
This function computes the Blake2b hash of the previously supplied input data. The output hash will b...
Definition blake2b.c:441
Definition blake2.h:62
Definition blake2.h:70