11539Srgrimes/* crypto/evp/m_md2.c */ 21539Srgrimes/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 31539Srgrimes * All rights reserved. 41539Srgrimes * 51539Srgrimes * This package is an SSL implementation written 61539Srgrimes * by Eric Young (eay@cryptsoft.com). 71539Srgrimes * The implementation was written so as to conform with Netscapes SSL. 81539Srgrimes * 91539Srgrimes * This library is free for commercial and non-commercial use as long as 101539Srgrimes * the following conditions are aheared to. The following conditions 111539Srgrimes * apply to all code found in this distribution, be it the RC4, RSA, 121539Srgrimes * lhash, DES, etc., code; not just the SSL code. The SSL documentation 131539Srgrimes * included with this distribution is covered by the same copyright terms 141539Srgrimes * except that the holder is Tim Hudson (tjh@cryptsoft.com). 151539Srgrimes * 161539Srgrimes * Copyright remains Eric Young's, and as such any Copyright notices in 171539Srgrimes * the code are not to be removed. 181539Srgrimes * If this package is used in a product, Eric Young should be given attribution 191539Srgrimes * as the author of the parts of the library used. 201539Srgrimes * This can be in the form of a textual message at program startup or 211539Srgrimes * in documentation (online or textual) provided with the package. 221539Srgrimes * 231539Srgrimes * Redistribution and use in source and binary forms, with or without 241539Srgrimes * modification, are permitted provided that the following conditions 251539Srgrimes * are met: 261539Srgrimes * 1. Redistributions of source code must retain the copyright 271539Srgrimes * notice, this list of conditions and the following disclaimer. 281539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 291539Srgrimes * notice, this list of conditions and the following disclaimer in the 301539Srgrimes * documentation and/or other materials provided with the distribution. 311539Srgrimes * 3. All advertising materials mentioning features or use of this software 321539Srgrimes * must display the following acknowledgement: 331539Srgrimes * "This product includes cryptographic software written by 3469793Sobrien * Eric Young (eay@cryptsoft.com)" 351539Srgrimes * The word 'cryptographic' can be left out if the rouines from the library 361539Srgrimes * being used are not cryptographic related :-). 371539Srgrimes * 4. If you include any Windows specific code (or a derivative thereof) from 381539Srgrimes * the apps directory (application code) you must include an acknowledgement: 391539Srgrimes * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 403041Swollman * 413041Swollman * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 421539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 431539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 441539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 451539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 461570Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 471539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4887136Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 491539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5087135Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5187135Srwatson * SUCH DAMAGE. 521539Srgrimes * 531539Srgrimes * The licence and distribution terms for any publically available version or 5473986Sobrien * derivative of this code cannot be changed. i.e. this code cannot simply be 551539Srgrimes * copied and put under another distribution licence 561539Srgrimes * [including the GNU Public Licence.] 5769793Sobrien */ 581539Srgrimes 593189Spst#include <stdio.h> 601539Srgrimes#include "cryptlib.h" 611539Srgrimes 621539Srgrimes#ifndef OPENSSL_NO_MD2 631539Srgrimes 6442515Sasami# include <openssl/evp.h> 651539Srgrimes# include <openssl/objects.h> 661539Srgrimes# include <openssl/x509.h> 671539Srgrimes# include <openssl/md2.h> 683041Swollman# ifndef OPENSSL_NO_RSA 691539Srgrimes# include <openssl/rsa.h> 701539Srgrimes# endif 711539Srgrimes 721539Srgrimesstatic int init(EVP_MD_CTX *ctx) 731539Srgrimes{ 741539Srgrimes return MD2_Init(ctx->md_data); 751539Srgrimes} 761539Srgrimes 776083Swpaulstatic int update(EVP_MD_CTX *ctx, const void *data, size_t count) 7810975Sache{ 791539Srgrimes return MD2_Update(ctx->md_data, data, count); 803041Swollman} 813041Swollman 8293032Simpstatic int final(EVP_MD_CTX *ctx, unsigned char *md) 833041Swollman{ 843041Swollman return MD2_Final(md, ctx->md_data); 851539Srgrimes} 86 87static const EVP_MD md2_md = { 88 NID_md2, 89 NID_md2WithRSAEncryption, 90 MD2_DIGEST_LENGTH, 91 0, 92 init, 93 update, 94 final, 95 NULL, 96 NULL, 97 EVP_PKEY_RSA_method, 98 MD2_BLOCK, 99 sizeof(EVP_MD *) + sizeof(MD2_CTX), 100}; 101 102const EVP_MD *EVP_md2(void) 103{ 104 return (&md2_md); 105} 106#endif 107