xref: /freebsd/crypto/openssl/providers/implementations/digests/blake2_prov.c (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery  *
4*b077aed3SPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b077aed3SPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*b077aed3SPierre Pronchery  * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery  * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery  */
9*b077aed3SPierre Pronchery 
10*b077aed3SPierre Pronchery #include <openssl/crypto.h>
11*b077aed3SPierre Pronchery #include "prov/blake2.h"
12*b077aed3SPierre Pronchery #include "prov/digestcommon.h"
13*b077aed3SPierre Pronchery #include "prov/implementations.h"
14*b077aed3SPierre Pronchery 
ossl_blake2s256_init(void * ctx)15*b077aed3SPierre Pronchery int ossl_blake2s256_init(void *ctx)
16*b077aed3SPierre Pronchery {
17*b077aed3SPierre Pronchery     BLAKE2S_PARAM P;
18*b077aed3SPierre Pronchery 
19*b077aed3SPierre Pronchery     ossl_blake2s_param_init(&P);
20*b077aed3SPierre Pronchery     return ossl_blake2s_init((BLAKE2S_CTX *)ctx, &P);
21*b077aed3SPierre Pronchery }
22*b077aed3SPierre Pronchery 
ossl_blake2b512_init(void * ctx)23*b077aed3SPierre Pronchery int ossl_blake2b512_init(void *ctx)
24*b077aed3SPierre Pronchery {
25*b077aed3SPierre Pronchery     BLAKE2B_PARAM P;
26*b077aed3SPierre Pronchery 
27*b077aed3SPierre Pronchery     ossl_blake2b_param_init(&P);
28*b077aed3SPierre Pronchery     return ossl_blake2b_init((BLAKE2B_CTX *)ctx, &P);
29*b077aed3SPierre Pronchery }
30*b077aed3SPierre Pronchery 
31*b077aed3SPierre Pronchery /* ossl_blake2s256_functions */
32*b077aed3SPierre Pronchery IMPLEMENT_digest_functions(blake2s256, BLAKE2S_CTX,
33*b077aed3SPierre Pronchery                            BLAKE2S_BLOCKBYTES, BLAKE2S_DIGEST_LENGTH, 0,
34*b077aed3SPierre Pronchery                            ossl_blake2s256_init, ossl_blake2s_update,
35*b077aed3SPierre Pronchery                            ossl_blake2s_final)
36*b077aed3SPierre Pronchery 
37*b077aed3SPierre Pronchery /* ossl_blake2b512_functions */
38*b077aed3SPierre Pronchery IMPLEMENT_digest_functions(blake2b512, BLAKE2B_CTX,
39*b077aed3SPierre Pronchery                            BLAKE2B_BLOCKBYTES, BLAKE2B_DIGEST_LENGTH, 0,
40*b077aed3SPierre Pronchery                            ossl_blake2b512_init, ossl_blake2b_update,
41*b077aed3SPierre Pronchery                            ossl_blake2b_final)
42