195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * All rights reserved. 395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This package is an SSL implementation written 595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * by Eric Young (eay@cryptsoft.com). 695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The implementation was written so as to conform with Netscapes SSL. 795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This library is free for commercial and non-commercial use as long as 995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the following conditions are aheared to. The following conditions 1095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * apply to all code found in this distribution, be it the RC4, RSA, 1195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * included with this distribution is covered by the same copyright terms 1395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * except that the holder is Tim Hudson (tjh@cryptsoft.com). 1495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 1595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Copyright remains Eric Young's, and as such any Copyright notices in 1695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the code are not to be removed. 1795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * If this package is used in a product, Eric Young should be given attribution 1895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * as the author of the parts of the library used. 1995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This can be in the form of a textual message at program startup or 2095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * in documentation (online or textual) provided with the package. 2195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 2295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Redistribution and use in source and binary forms, with or without 2395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * modification, are permitted provided that the following conditions 2495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * are met: 2595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 1. Redistributions of source code must retain the copyright 2695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * notice, this list of conditions and the following disclaimer. 2795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 2. Redistributions in binary form must reproduce the above copyright 2895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * notice, this list of conditions and the following disclaimer in the 2995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * documentation and/or other materials provided with the distribution. 3095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 3. All advertising materials mentioning features or use of this software 3195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * must display the following acknowledgement: 3295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * "This product includes cryptographic software written by 3395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Eric Young (eay@cryptsoft.com)" 3495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The word 'cryptographic' can be left out if the rouines from the library 3595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * being used are not cryptographic related :-). 3695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 4. If you include any Windows specific code (or a derivative thereof) from 3795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the apps directory (application code) you must include an acknowledgement: 3895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 3995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 4095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 4995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * SUCH DAMAGE. 5195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 5295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The licence and distribution terms for any publically available version or 5395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * derivative of this code cannot be changed. i.e. this code cannot simply be 5495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * copied and put under another distribution licence 5595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * [including the GNU Public Licence.] */ 5695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 5795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include <openssl/digest.h> 5895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 59c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley#include <openssl/md4.h> 6095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include <openssl/md5.h> 6195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include <openssl/obj.h> 6295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include <openssl/sha.h> 6395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include "internal.h" 6595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 67c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langleystatic int md4_init(EVP_MD_CTX *ctx) { return MD4_Init(ctx->md_data); } 68c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 69c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langleystatic int md4_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 70c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley return MD4_Update(ctx->md_data, data, count); 71c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley} 72c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 73c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langleystatic int md4_final(EVP_MD_CTX *ctx, unsigned char *out) { 74c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley return MD4_Final(out, ctx->md_data); 75c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley} 76c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 77c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langleystatic const EVP_MD md4_md = { 78c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley NID_md4, MD4_DIGEST_LENGTH, 0 /* flags */, md4_init, 79c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley md4_update, md4_final, 64 /* block size */, sizeof(MD4_CTX), 80c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley}; 81c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 82c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langleyconst EVP_MD *EVP_md4(void) { return &md4_md; } 83c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 84c9eb7eac86a3f07bf23b35b7ce24382e158056fcAdam Langley 8595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int md5_init(EVP_MD_CTX *ctx) { return MD5_Init(ctx->md_data); } 8695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 8795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int md5_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 8895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return MD5_Update(ctx->md_data, data, count); 8995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 9095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 9195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int md5_final(EVP_MD_CTX *ctx, unsigned char *out) { 9295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return MD5_Final(out, ctx->md_data); 9395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 9495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 9595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD md5_md = { 9695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_md5, MD5_DIGEST_LENGTH, 0 /* flags */, md5_init, 9795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley md5_update, md5_final, 64 /* block size */, sizeof(MD5_CTX), 9895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 9995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_md5(void) { return &md5_md; } 10195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha1_init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } 10495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha1_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 10695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA1_Update(ctx->md_data, data, count); 10795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 10895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha1_final(EVP_MD_CTX *ctx, unsigned char *md) { 11095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA1_Final(md, ctx->md_data); 11195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 11295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 11395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD sha1_md = { 11495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_sha1, SHA_DIGEST_LENGTH, 0 /* flags */, sha1_init, 11595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley sha1_update, sha1_final, 64 /* block size */, sizeof(SHA_CTX), 11695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 11795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 11895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_sha1(void) { return &sha1_md; } 11995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha224_init(EVP_MD_CTX *ctx) { return SHA224_Init(ctx->md_data); } 12295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha224_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 12495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA224_Update(ctx->md_data, data, count); 12595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 12695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha224_final(EVP_MD_CTX *ctx, unsigned char *md) { 12895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA224_Final(md, ctx->md_data); 12995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 13095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 13195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD sha224_md = { 13295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_sha224, SHA224_DIGEST_LENGTH, 0 /* flags */, 13395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley sha224_init, sha224_update, sha224_final, 13495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 64 /* block size */, sizeof(SHA256_CTX), 13595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 13695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 13795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_sha224(void) { return &sha224_md; } 13895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 13995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 14095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha256_init(EVP_MD_CTX *ctx) { return SHA256_Init(ctx->md_data); } 14195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 14295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha256_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 14395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA256_Update(ctx->md_data, data, count); 14495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 14595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 14695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha256_final(EVP_MD_CTX *ctx, unsigned char *md) { 14795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA256_Final(md, ctx->md_data); 14895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 14995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 15095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD sha256_md = { 15195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_sha256, SHA256_DIGEST_LENGTH, 0 /* flags */, 15295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley sha256_init, sha256_update, sha256_final, 15395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 64 /* block size */, sizeof(SHA256_CTX), 15495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 15595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 15695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_sha256(void) { return &sha256_md; } 15795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 15895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 15995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha384_init(EVP_MD_CTX *ctx) { return SHA384_Init(ctx->md_data); } 16095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 16195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha384_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 16295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA384_Update(ctx->md_data, data, count); 16395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 16495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 16595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha384_final(EVP_MD_CTX *ctx, unsigned char *md) { 16695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA384_Final(md, ctx->md_data); 16795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 16895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 16995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD sha384_md = { 17095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_sha384, SHA384_DIGEST_LENGTH, 0 /* flags */, 17195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley sha384_init, sha384_update, sha384_final, 17295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 128 /* block size */, sizeof(SHA512_CTX), 17395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 17495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 17595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_sha384(void) { return &sha384_md; } 17695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 17795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 17895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha512_init(EVP_MD_CTX *ctx) { return SHA512_Init(ctx->md_data); } 17995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 18095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha512_update(EVP_MD_CTX *ctx, const void *data, size_t count) { 18195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA512_Update(ctx->md_data, data, count); 18295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 18395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 18495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic int sha512_final(EVP_MD_CTX *ctx, unsigned char *md) { 18595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return SHA512_Final(md, ctx->md_data); 18695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 18795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 18895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const EVP_MD sha512_md = { 18995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley NID_sha512, SHA512_DIGEST_LENGTH, 0 /* flags */, 19095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley sha512_init, sha512_update, sha512_final, 19195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 128 /* block size */, sizeof(SHA512_CTX), 19295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 19395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 19495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD *EVP_sha512(void) { return &sha512_md; } 19595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 19695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystruct nid_to_digest { 19795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley int nid; 19895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley const EVP_MD *(*md_func)(); 19995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 20095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 20195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleystatic const struct nid_to_digest nid_to_digest_mapping[] = { 20295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_md5, EVP_md5 }, 20395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha1, EVP_sha1 }, 20495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha224, EVP_sha224 }, 20595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha256, EVP_sha256 }, 20695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha384, EVP_sha384 }, 20795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha512, EVP_sha512 }, 20895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_dsaWithSHA, EVP_sha1 }, 20995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_dsaWithSHA1, EVP_sha1 }, 21095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_ecdsa_with_SHA1, EVP_sha1 }, 21195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_md5WithRSAEncryption, EVP_md5 }, 21295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha1WithRSAEncryption, EVP_sha1 }, 21395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha224WithRSAEncryption, EVP_sha224 }, 21495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha256WithRSAEncryption, EVP_sha256 }, 21595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha384WithRSAEncryption, EVP_sha384 }, 21695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { NID_sha512WithRSAEncryption, EVP_sha512 }, 21795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley}; 21895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 21995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD* EVP_get_digestbynid(int nid) { 22095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley unsigned i; 22195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley for (i = 0; i < sizeof(nid_to_digest_mapping) / sizeof(struct nid_to_digest); 22395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley i++) { 22495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley if (nid_to_digest_mapping[i].nid == nid) { 22595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return nid_to_digest_mapping[i].md_func(); 22695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 22795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 22895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return NULL; 23095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 23195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 23295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyconst EVP_MD* EVP_get_digestbyobj(const ASN1_OBJECT *obj) { 23395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley return EVP_get_digestbynid(OBJ_obj2nid(obj)); 23495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} 235