]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/blake2/m_blake2s.c
Copyright consolidation: perl files
[thirdparty/openssl.git] / crypto / blake2 / m_blake2s.c
CommitLineData
2d0b4412 1/*
2d0b4412 2 * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>.
208527a7 3 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
2d0b4412 4 *
e0a65194 5 * Licensed under the OpenSSL licenses (the "License");
208527a7
KR
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.
2d0b4412
BC
10 */
11
208527a7
KR
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 */
2d0b4412 17
2d0b4412
BC
18#include "internal/cryptlib.h"
19
20#ifndef OPENSSL_NO_BLAKE2
21
22# include <openssl/evp.h>
23# include <openssl/objects.h>
01ce6f74 24# include "blake2_locl.h"
2d0b4412
BC
25# include "internal/evp_int.h"
26
27static int init(EVP_MD_CTX *ctx)
28{
29 return BLAKE2s_Init(EVP_MD_CTX_md_data(ctx));
30}
31
32static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
33{
34 return BLAKE2s_Update(EVP_MD_CTX_md_data(ctx), data, count);
35}
36
37static int final(EVP_MD_CTX *ctx, unsigned char *md)
38{
39 return BLAKE2s_Final(md, EVP_MD_CTX_md_data(ctx));
40}
41
42static const EVP_MD blake2s_md = {
208527a7 43 NID_blake2s256,
2d0b4412
BC
44 0,
45 BLAKE2S_DIGEST_LENGTH,
46 0,
47 init,
48 update,
49 final,
50 NULL,
51 NULL,
52 0,
53 sizeof(EVP_MD *) + sizeof(BLAKE2S_CTX),
54};
55
208527a7 56const EVP_MD *EVP_blake2s256(void)
2d0b4412
BC
57{
58 return (&blake2s_md);
59}
60#endif