diff options
author | Bill Cox <waywardgeek@google.com> | 2016-03-09 23:08:31 +0100 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-03-11 10:39:10 -0500 |
commit | 2d0b44126763f989a4cbffbffe9d0c7518158bb7 (patch) | |
tree | 241855d2b5a9b91688f969bf849037f6a0343594 /crypto/evp | |
parent | 40f43f8a2e7c75f032672d198604e4fbd6a60fd8 (diff) |
Add blake2 support.
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/Makefile.in | 4 | ||||
-rw-r--r-- | crypto/evp/build.info | 2 | ||||
-rw-r--r-- | crypto/evp/c_alld.c | 4 | ||||
-rw-r--r-- | crypto/evp/m_blake2b.c | 62 | ||||
-rw-r--r-- | crypto/evp/m_blake2s.c | 62 |
5 files changed, 131 insertions, 3 deletions
diff --git a/crypto/evp/Makefile.in b/crypto/evp/Makefile.in index 5b24ae5909..d7b12035a4 100644 --- a/crypto/evp/Makefile.in +++ b/crypto/evp/Makefile.in @@ -20,7 +20,7 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_cnf.c \ e_rc4.c e_aes.c names.c e_seed.c \ e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ m_null.c m_md2.c m_md4.c m_md5.c m_sha1.c m_wp.c \ - m_md5_sha1.c m_mdc2.c m_ripemd.c \ + m_md5_sha1.c m_mdc2.c m_ripemd.c m_blake2b.c m_blake2s.c \ p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ c_allc.c c_alld.c evp_lib.c bio_ok.c \ @@ -34,7 +34,7 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_cnf.o \ e_rc4.o e_aes.o names.o e_seed.o \ e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \ m_null.o m_md2.o m_md4.o m_md5.o m_sha1.o m_wp.o \ - m_md5_sha1.o m_mdc2.o m_ripemd.o \ + m_md5_sha1.o m_mdc2.o m_ripemd.o m_blake2b.o m_blake2s.o \ p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \ bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o \ c_allc.o c_alld.o evp_lib.o bio_ok.o \ diff --git a/crypto/evp/build.info b/crypto/evp/build.info index bf633dc713..8dc60f6414 100644 --- a/crypto/evp/build.info +++ b/crypto/evp/build.info @@ -5,7 +5,7 @@ SOURCE[../../libcrypto]=\ e_rc4.c e_aes.c names.c e_seed.c \ e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ m_null.c m_md2.c m_md4.c m_md5.c m_sha1.c m_wp.c \ - m_md5_sha1.c m_mdc2.c m_ripemd.c \ + m_md5_sha1.c m_mdc2.c m_ripemd.c m_blake2b.c m_blake2s.c \ p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ c_allc.c c_alld.c evp_lib.c bio_ok.c \ diff --git a/crypto/evp/c_alld.c b/crypto/evp/c_alld.c index e28ba3df12..78be9fbc6a 100644 --- a/crypto/evp/c_alld.c +++ b/crypto/evp/c_alld.c @@ -90,4 +90,8 @@ void openssl_add_all_digests_internal(void) #ifndef OPENSSL_NO_WHIRLPOOL EVP_add_digest(EVP_whirlpool()); #endif +#ifndef OPENSSL_NO_BLAKE2 + EVP_add_digest(EVP_blake2b()); + EVP_add_digest(EVP_blake2s()); +#endif } diff --git a/crypto/evp/m_blake2b.c b/crypto/evp/m_blake2b.c new file mode 100644 index 0000000000..e3cf6f30a5 --- /dev/null +++ b/crypto/evp/m_blake2b.c @@ -0,0 +1,62 @@ +/* + * BLAKE2 reference source code package - reference C implementations + * + * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. + * You may use this under the terms of the CC0, the OpenSSL Licence, or the + * Apache Public License 2.0, at your option. The terms of these licenses can + * be found at: + * + * - OpenSSL license : https://www.openssl.org/source/license.html + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * - CC0 1.0 Universal : http://www.apache.org/licenses/LICENSE-2.0 + * + * More information about the BLAKE2 hash function can be found at + * https://blake2.net. + */ + +/* crypto/evp/m_blake2b.c */ + +#include <stdio.h> +#include "internal/cryptlib.h" + +#ifndef OPENSSL_NO_BLAKE2 + +# include <openssl/evp.h> +# include <openssl/objects.h> +# include "internal/blake2_locl.h" +# include "internal/evp_int.h" + +static int init(EVP_MD_CTX *ctx) +{ + return BLAKE2b_Init(EVP_MD_CTX_md_data(ctx)); +} + +static int update(EVP_MD_CTX *ctx, const void *data, size_t count) +{ + return BLAKE2b_Update(EVP_MD_CTX_md_data(ctx), data, count); +} + +static int final(EVP_MD_CTX *ctx, unsigned char *md) +{ + return BLAKE2b_Final(md, EVP_MD_CTX_md_data(ctx)); +} + +static const EVP_MD blake2b_md = { + NID_blake2b, + 0, + BLAKE2B_DIGEST_LENGTH, + 0, + init, + update, + final, + NULL, + NULL, + 0, + sizeof(EVP_MD *) + sizeof(BLAKE2B_CTX), +}; + +const EVP_MD *EVP_blake2b(void) +{ + return (&blake2b_md); +} +#endif diff --git a/crypto/evp/m_blake2s.c b/crypto/evp/m_blake2s.c new file mode 100644 index 0000000000..511b192c1d --- /dev/null +++ b/crypto/evp/m_blake2s.c @@ -0,0 +1,62 @@ +/* + * BLAKE2 reference source code package - reference C implementations + * + * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. + * You may use this under the terms of the CC0, the OpenSSL Licence, or the + * Apache Public License 2.0, at your option. The terms of these licenses can + * be found at: + * + * - OpenSSL license : https://www.openssl.org/source/license.html + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * - CC0 1.0 Universal : http://www.apache.org/licenses/LICENSE-2.0 + * + * More information about the BLAKE2 hash function can be found at + * https://blake2.net. + */ + +/* crypto/evp/m_blake2s.c */ + +#include <stdio.h> +#include "internal/cryptlib.h" + +#ifndef OPENSSL_NO_BLAKE2 + +# include <openssl/evp.h> +# include <openssl/objects.h> +# include "internal/blake2_locl.h" +# include "internal/evp_int.h" + +static int init(EVP_MD_CTX *ctx) +{ + return BLAKE2s_Init(EVP_MD_CTX_md_data(ctx)); +} + +static int update(EVP_MD_CTX *ctx, const void *data, size_t count) +{ + return BLAKE2s_Update(EVP_MD_CTX_md_data(ctx), data, count); +} + +static int final(EVP_MD_CTX *ctx, unsigned char *md) +{ + return BLAKE2s_Final(md, EVP_MD_CTX_md_data(ctx)); +} + +static const EVP_MD blake2s_md = { + NID_blake2s, + 0, + BLAKE2S_DIGEST_LENGTH, + 0, + init, + update, + final, + NULL, + NULL, + 0, + sizeof(EVP_MD *) + sizeof(BLAKE2S_CTX), +}; + +const EVP_MD *EVP_blake2s(void) +{ + return (&blake2s_md); +} +#endif |