Configure: recognise -static even if given through variables
[openssl.git] / crypto / blake2 / m_blake2b.c
1 /*
2  * Copyright 2016-2018 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 /*
11  * Derived from the BLAKE2 reference implementation written by Samuel Neves.
12  * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>
13  * More information about the BLAKE2 hash function and its implementations
14  * can be found at https://blake2.net.
15  */
16
17 #include "internal/cryptlib.h"
18
19 #ifndef OPENSSL_NO_BLAKE2
20
21 # include <openssl/evp.h>
22 # include <openssl/objects.h>
23 # include "blake2_locl.h"
24 # include "internal/evp_int.h"
25
26 static int init(EVP_MD_CTX *ctx)
27 {
28     BLAKE2B_PARAM P;
29     blake2b_param_init(&P);
30     return BLAKE2b_Init(EVP_MD_CTX_md_data(ctx), &P);
31 }
32
33 static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
34 {
35     return BLAKE2b_Update(EVP_MD_CTX_md_data(ctx), data, count);
36 }
37
38 static int final(EVP_MD_CTX *ctx, unsigned char *md)
39 {
40     return BLAKE2b_Final(md, EVP_MD_CTX_md_data(ctx));
41 }
42
43 static const EVP_MD blake2b_md = {
44     NID_blake2b512,
45     0,
46     BLAKE2B_DIGEST_LENGTH,
47     0,
48     init,
49     update,
50     final,
51     NULL,
52     NULL,
53     BLAKE2B_BLOCKBYTES,
54     sizeof(BLAKE2B_CTX),
55 };
56
57 const EVP_MD *EVP_blake2b512(void)
58 {
59     return &blake2b_md;
60 }
61 #endif