m_md4.c revision 280304
1215116Sdes/* crypto/evp/m_md4.c */ 276259Sgreen/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 376259Sgreen * All rights reserved. 476259Sgreen * 576259Sgreen * This package is an SSL implementation written 676259Sgreen * by Eric Young (eay@cryptsoft.com). 792555Sdes * The implementation was written so as to conform with Netscapes SSL. 876259Sgreen * 976259Sgreen * This library is free for commercial and non-commercial use as long as 1076259Sgreen * the following conditions are aheared to. The following conditions 11162856Sdes * apply to all code found in this distribution, be it the RC4, RSA, 12106130Sdes * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13162856Sdes * included with this distribution is covered by the same copyright terms 14162856Sdes * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15162856Sdes * 16162856Sdes * Copyright remains Eric Young's, and as such any Copyright notices in 1776259Sgreen * the code are not to be removed. 18162856Sdes * If this package is used in a product, Eric Young should be given attribution 19162856Sdes * as the author of the parts of the library used. 20162856Sdes * This can be in the form of a textual message at program startup or 2176259Sgreen * in documentation (online or textual) provided with the package. 2276259Sgreen * 23162856Sdes * Redistribution and use in source and binary forms, with or without 24162856Sdes * modification, are permitted provided that the following conditions 2592555Sdes * are met: 26162856Sdes * 1. Redistributions of source code must retain the copyright 27162856Sdes * notice, this list of conditions and the following disclaimer. 28162856Sdes * 2. Redistributions in binary form must reproduce the above copyright 29162856Sdes * notice, this list of conditions and the following disclaimer in the 30162856Sdes * documentation and/or other materials provided with the distribution. 31162856Sdes * 3. All advertising materials mentioning features or use of this software 32162856Sdes * must display the following acknowledgement: 3376259Sgreen * "This product includes cryptographic software written by 3476259Sgreen * Eric Young (eay@cryptsoft.com)" 3576259Sgreen * The word 'cryptographic' can be left out if the rouines from the library 36162856Sdes * being used are not cryptographic related :-). 3776259Sgreen * 4. If you include any Windows specific code (or a derivative thereof) from 38162856Sdes * the apps directory (application code) you must include an acknowledgement: 3992555Sdes * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 4092555Sdes * 4192555Sdes * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4292555Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4392555Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4476259Sgreen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4576259Sgreen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4692555Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47147005Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4876259Sgreen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4998941Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5098941Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5198941Sdes * SUCH DAMAGE. 5276259Sgreen * 5392555Sdes * The licence and distribution terms for any publically available version or 5476259Sgreen * derivative of this code cannot be changed. i.e. this code cannot simply be 5592555Sdes * copied and put under another distribution licence 5692555Sdes * [including the GNU Public Licence.] 5792555Sdes */ 5892555Sdes 59181111Sdes#include <stdio.h> 6092555Sdes#include "cryptlib.h" 61147005Sdes 62147005Sdes#ifndef OPENSSL_NO_MD4 6376259Sgreen 6476259Sgreen# include <openssl/evp.h> 6576259Sgreen# include <openssl/objects.h> 6676259Sgreen# include <openssl/x509.h> 6776259Sgreen# include <openssl/md4.h> 6876259Sgreen# ifndef OPENSSL_NO_RSA 6976259Sgreen# include <openssl/rsa.h> 7076259Sgreen# endif 7176259Sgreen 7276259Sgreen# include "evp_locl.h" 73162856Sdes 7476259Sgreenstatic int init(EVP_MD_CTX *ctx) 7592555Sdes{ 7692555Sdes return MD4_Init(ctx->md_data); 7792555Sdes} 7876259Sgreen 7976259Sgreenstatic int update(EVP_MD_CTX *ctx, const void *data, size_t count) 8076259Sgreen{ 8176259Sgreen return MD4_Update(ctx->md_data, data, count); 8276259Sgreen} 8376259Sgreen 8476259Sgreenstatic int final(EVP_MD_CTX *ctx, unsigned char *md) 8576259Sgreen{ 8676259Sgreen return MD4_Final(md, ctx->md_data); 8776259Sgreen} 8876259Sgreen 8976259Sgreenstatic const EVP_MD md4_md = { 9076259Sgreen NID_md4, 9176259Sgreen NID_md4WithRSAEncryption, 9276259Sgreen MD4_DIGEST_LENGTH, 9392555Sdes 0, 9476259Sgreen init, 9576259Sgreen update, 9676259Sgreen final, 9776259Sgreen NULL, 9876259Sgreen NULL, 9992555Sdes EVP_PKEY_RSA_method, 10076259Sgreen MD4_CBLOCK, 10176259Sgreen sizeof(EVP_MD *) + sizeof(MD4_CTX), 10276259Sgreen}; 10376259Sgreen 10476259Sgreenconst EVP_MD *EVP_md4(void) 10576259Sgreen{ 10676259Sgreen return (&md4_md); 10792555Sdes} 10876259Sgreen#endif 10976259Sgreen