1258945Sroberto/* 2258945Sroberto * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. 3258945Sroberto * 4258945Sroberto * Licensed under the OpenSSL license (the "License"). You may not use 5258945Sroberto * this file except in compliance with the License. You can obtain a copy 6258945Sroberto * in the file LICENSE in the source distribution or at 7258945Sroberto * https://www.openssl.org/source/license.html 8258945Sroberto */ 9258945Sroberto 10258945Sroberto/* 11258945Sroberto * Derived from the BLAKE2 reference implementation written by Samuel Neves. 12258945Sroberto * Copyright 2012, Samuel Neves <sneves@dei.uc.pt> 13258945Sroberto * More information about the BLAKE2 hash function and its implementations 14258945Sroberto * can be found at https://blake2.net. 15258945Sroberto */ 16258945Sroberto 17258945Sroberto#include "internal/cryptlib.h" 18258945Sroberto 19258945Sroberto#ifndef OPENSSL_NO_BLAKE2 20258945Sroberto 21258945Sroberto# include <openssl/evp.h> 22258945Sroberto# include <openssl/objects.h> 23258945Sroberto# include "blake2_local.h" 24258945Sroberto# include "crypto/evp.h" 25258945Sroberto 26258945Srobertostatic int init(EVP_MD_CTX *ctx) 27258945Sroberto{ 28258945Sroberto return BLAKE2s_Init(EVP_MD_CTX_md_data(ctx)); 29258945Sroberto} 30258945Sroberto 31258945Srobertostatic int update(EVP_MD_CTX *ctx, const void *data, size_t count) 32258945Sroberto{ 33258945Sroberto return BLAKE2s_Update(EVP_MD_CTX_md_data(ctx), data, count); 34258945Sroberto} 35258945Sroberto 36258945Srobertostatic int final(EVP_MD_CTX *ctx, unsigned char *md) 37258945Sroberto{ 38258945Sroberto return BLAKE2s_Final(md, EVP_MD_CTX_md_data(ctx)); 39258945Sroberto} 40258945Sroberto 41258945Srobertostatic const EVP_MD blake2s_md = { 42258945Sroberto NID_blake2s256, 43258945Sroberto 0, 44258945Sroberto BLAKE2S_DIGEST_LENGTH, 45258945Sroberto 0, 46258945Sroberto init, 47 update, 48 final, 49 NULL, 50 NULL, 51 BLAKE2S_BLOCKBYTES, 52 sizeof(EVP_MD *) + sizeof(BLAKE2S_CTX), 53}; 54 55const EVP_MD *EVP_blake2s256(void) 56{ 57 return &blake2s_md; 58} 59#endif 60