m_md2.c revision 225736
12061Sjkh/* crypto/evp/m_md2.c */ 22883Sphk/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 32061Sjkh * All rights reserved. 42061Sjkh * 52061Sjkh * This package is an SSL implementation written 62061Sjkh * by Eric Young (eay@cryptsoft.com). 72061Sjkh * The implementation was written so as to conform with Netscapes SSL. 82061Sjkh * 92160Scsgr * This library is free for commercial and non-commercial use as long as 102160Scsgr * the following conditions are aheared to. The following conditions 112834Swollman * apply to all code found in this distribution, be it the RC4, RSA, 122061Sjkh * lhash, DES, etc., code; not just the SSL code. The SSL documentation 132061Sjkh * included with this distribution is covered by the same copyright terms 142160Scsgr * except that the holder is Tim Hudson (tjh@cryptsoft.com). 152626Scsgr * 162061Sjkh * Copyright remains Eric Young's, and as such any Copyright notices in 172160Scsgr * the code are not to be removed. 181594Srgrimes * If this package is used in a product, Eric Young should be given attribution 192061Sjkh * as the author of the parts of the library used. 202160Scsgr * This can be in the form of a textual message at program startup or 212061Sjkh * in documentation (online or textual) provided with the package. 221594Srgrimes * 232061Sjkh * Redistribution and use in source and binary forms, with or without 242061Sjkh * modification, are permitted provided that the following conditions 252061Sjkh * are met: 262061Sjkh * 1. Redistributions of source code must retain the copyright 272061Sjkh * notice, this list of conditions and the following disclaimer. 282061Sjkh * 2. Redistributions in binary form must reproduce the above copyright 292061Sjkh * notice, this list of conditions and the following disclaimer in the 302061Sjkh * documentation and/or other materials provided with the distribution. 312061Sjkh * 3. All advertising materials mentioning features or use of this software 322061Sjkh * must display the following acknowledgement: 332061Sjkh * "This product includes cryptographic software written by 342061Sjkh * Eric Young (eay@cryptsoft.com)" 352061Sjkh * The word 'cryptographic' can be left out if the rouines from the library 362061Sjkh * being used are not cryptographic related :-). 372061Sjkh * 4. If you include any Windows specific code (or a derivative thereof) from 382061Sjkh * the apps directory (application code) you must include an acknowledgement: 392061Sjkh * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 402061Sjkh * 412061Sjkh * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 422061Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 432061Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 442160Scsgr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 452061Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 462061Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 472626Scsgr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 482626Scsgr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 492626Scsgr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 502626Scsgr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 512061Sjkh * SUCH DAMAGE. 522061Sjkh * 532061Sjkh * The licence and distribution terms for any publically available version or 542061Sjkh * derivative of this code cannot be changed. i.e. this code cannot simply be 552061Sjkh * copied and put under another distribution licence 562061Sjkh * [including the GNU Public Licence.] 572061Sjkh */ 582061Sjkh 592061Sjkh#include <stdio.h> 602061Sjkh#include "cryptlib.h" 612061Sjkh#include "evp_locl.h" 622061Sjkh 632061Sjkh#ifndef OPENSSL_NO_MD2 642061Sjkh 652061Sjkh#include <openssl/evp.h> 662061Sjkh#include <openssl/objects.h> 672061Sjkh#include <openssl/x509.h> 682061Sjkh#include <openssl/md2.h> 692834Swollman#ifndef OPENSSL_NO_RSA 702834Swollman#include <openssl/rsa.h> 712834Swollman#endif 722834Swollman 732834Swollmanstatic int init(EVP_MD_CTX *ctx) 742834Swollman { return MD2_Init(ctx->md_data); } 751594Srgrimes 762061Sjkhstatic int update(EVP_MD_CTX *ctx,const void *data,size_t count) 772061Sjkh { return MD2_Update(ctx->md_data,data,count); } 782061Sjkh 792061Sjkhstatic int final(EVP_MD_CTX *ctx,unsigned char *md) 802061Sjkh { return MD2_Final(md,ctx->md_data); } 812061Sjkh 822061Sjkhstatic const EVP_MD md2_md= 832061Sjkh { 842061Sjkh NID_md2, 852061Sjkh NID_md2WithRSAEncryption, 862061Sjkh MD2_DIGEST_LENGTH, 872061Sjkh 0, 882061Sjkh init, 892061Sjkh update, 902061Sjkh final, 912061Sjkh NULL, 922061Sjkh NULL, 932061Sjkh EVP_PKEY_RSA_method, 942061Sjkh MD2_BLOCK, 952061Sjkh sizeof(EVP_MD *)+sizeof(MD2_CTX), 962061Sjkh }; 972468Spaul 982061Sjkhconst EVP_MD *EVP_md2(void) 992061Sjkh { 1002061Sjkh return(&md2_md); 1012061Sjkh } 1022061Sjkh#endif 1032061Sjkh