]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/blake2/m_blake2b.c
b74bdbdabb0eae0e1bf8525883f83dee08df3117
[thirdparty/openssl.git] / crypto / blake2 / m_blake2b.c
1 /*
2 * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>.
3 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 *
5 * Licensed under the OpenSSL licenses, (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * https://www.openssl.org/source/license.html
9 * or in the file LICENSE in the source distribution.
10 */
11
12 /*
13 * Derived from the BLAKE2 reference implementation written by Samuel Neves.
14 * More information about the BLAKE2 hash function and its implementations
15 * can be found at https://blake2.net.
16 */
17
18 #include "internal/cryptlib.h"
19
20 #ifndef OPENSSL_NO_BLAKE2
21
22 # include <openssl/evp.h>
23 # include <openssl/objects.h>
24 # include "internal/blake2_locl.h"
25 # include "internal/evp_int.h"
26
27 static int init(EVP_MD_CTX *ctx)
28 {
29 return BLAKE2b_Init(EVP_MD_CTX_md_data(ctx));
30 }
31
32 static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
33 {
34 return BLAKE2b_Update(EVP_MD_CTX_md_data(ctx), data, count);
35 }
36
37 static int final(EVP_MD_CTX *ctx, unsigned char *md)
38 {
39 return BLAKE2b_Final(md, EVP_MD_CTX_md_data(ctx));
40 }
41
42 static const EVP_MD blake2b_md = {
43 NID_blake2b512,
44 0,
45 BLAKE2B_DIGEST_LENGTH,
46 0,
47 init,
48 update,
49 final,
50 NULL,
51 NULL,
52 0,
53 sizeof(EVP_MD *) + sizeof(BLAKE2B_CTX),
54 };
55
56 const EVP_MD *EVP_blake2b512(void)
57 {
58 return (&blake2b_md);
59 }
60 #endif