1 /* $OpenBSD: m_wp.c,v 1.7 2014/07/11 08:44:48 jsing Exp $ */ 2 3 #include <stdio.h> 4 5 #include <openssl/opensslconf.h> 6 7 #ifndef OPENSSL_NO_WHIRLPOOL 8 9 #include <openssl/evp.h> 10 #include <openssl/objects.h> 11 #include <openssl/x509.h> 12 #include <openssl/whrlpool.h> 13 14 static int 15 init(EVP_MD_CTX *ctx) 16 { 17 return WHIRLPOOL_Init(ctx->md_data); 18 } 19 20 static int 21 update(EVP_MD_CTX *ctx, const void *data, size_t count) 22 { 23 return WHIRLPOOL_Update(ctx->md_data, data, count); 24 } 25 26 static int 27 final(EVP_MD_CTX *ctx, unsigned char *md) 28 { 29 return WHIRLPOOL_Final(md, ctx->md_data); 30 } 31 32 static const EVP_MD whirlpool_md = { 33 .type = NID_whirlpool, 34 .pkey_type = 0, 35 .md_size = WHIRLPOOL_DIGEST_LENGTH, 36 .flags = 0, 37 .init = init, 38 .update = update, 39 .final = final, 40 .copy = NULL, 41 .cleanup = NULL, 42 .sign = NULL, 43 .verify = NULL, 44 .required_pkey_type = { 45 0, 0, 0, 0, 46 }, 47 .block_size = WHIRLPOOL_BBLOCK / 8, 48 .ctx_size = sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX), 49 }; 50 51 const EVP_MD * 52 EVP_whirlpool(void) 53 { 54 return (&whirlpool_md); 55 } 56 #endif 57