1 | /*
|
---|
2 | * Copyright 2019-2023 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 | #include "crypto/evp.h"
|
---|
11 | #include "prov/blake2.h" /* diverse BLAKE2 macros */
|
---|
12 | #include "legacy_meth.h"
|
---|
13 |
|
---|
14 | // #ifdef OPENSSL_MANGLER /* VBOX */
|
---|
15 | // # undef ossl_blake2b_init /* VBOX */
|
---|
16 | // # undef ossl_blake2s_init /* VBOX */
|
---|
17 | // # define ossl_blake2b_init OPENSSL_MANGLER(ossl_blake2b_init) /* VBOX */
|
---|
18 | // # define ossl_blake2s_init OPENSSL_MANGLER(ossl_blake2s_init) /* VBOX */
|
---|
19 | // #endif /* VBOX */
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Local hack to adapt the BLAKE2 init functions to what the
|
---|
23 | * legacy function signatures demand.
|
---|
24 | */
|
---|
25 | static int blake2s_init(BLAKE2S_CTX *C)
|
---|
26 | {
|
---|
27 | BLAKE2S_PARAM P;
|
---|
28 |
|
---|
29 | ossl_blake2s_param_init(&P);
|
---|
30 | return ossl_blake2s_init(C, &P);
|
---|
31 | }
|
---|
32 | static int blake2b_init(BLAKE2B_CTX *C)
|
---|
33 | {
|
---|
34 | BLAKE2B_PARAM P;
|
---|
35 |
|
---|
36 | ossl_blake2b_param_init(&P);
|
---|
37 | return ossl_blake2b_init(C, &P);
|
---|
38 | }
|
---|
39 | #define blake2s_update ossl_blake2s_update
|
---|
40 | #define blake2b_update ossl_blake2b_update
|
---|
41 | #define blake2s_final ossl_blake2s_final
|
---|
42 | #define blake2b_final ossl_blake2b_final
|
---|
43 |
|
---|
44 | IMPLEMENT_LEGACY_EVP_MD_METH_LC(blake2s_int, blake2s)
|
---|
45 | IMPLEMENT_LEGACY_EVP_MD_METH_LC(blake2b_int, blake2b)
|
---|
46 |
|
---|
47 | static const EVP_MD blake2b_md = {
|
---|
48 | NID_blake2b512,
|
---|
49 | 0,
|
---|
50 | BLAKE2B_DIGEST_LENGTH,
|
---|
51 | 0,
|
---|
52 | EVP_ORIG_GLOBAL,
|
---|
53 | LEGACY_EVP_MD_METH_TABLE(blake2b_int_init, blake2b_int_update,
|
---|
54 | blake2b_int_final, NULL, BLAKE2B_BLOCKBYTES),
|
---|
55 | };
|
---|
56 |
|
---|
57 | const EVP_MD *EVP_blake2b512(void)
|
---|
58 | {
|
---|
59 | return &blake2b_md;
|
---|
60 | }
|
---|
61 |
|
---|
62 | static const EVP_MD blake2s_md = {
|
---|
63 | NID_blake2s256,
|
---|
64 | 0,
|
---|
65 | BLAKE2S_DIGEST_LENGTH,
|
---|
66 | 0,
|
---|
67 | EVP_ORIG_GLOBAL,
|
---|
68 | LEGACY_EVP_MD_METH_TABLE(blake2s_int_init, blake2s_int_update,
|
---|
69 | blake2s_int_final, NULL, BLAKE2S_BLOCKBYTES),
|
---|
70 | };
|
---|
71 |
|
---|
72 | const EVP_MD *EVP_blake2s256(void)
|
---|
73 | {
|
---|
74 | return &blake2s_md;
|
---|
75 | }
|
---|