apr_md4.h revision 256281
138166Sache/* Licensed to the Apache Software Foundation (ASF) under one or more 238166Sache * contributor license agreements. See the NOTICE file distributed with 353943Sache * this work for additional information regarding copyright ownership. 438166Sache * The ASF licenses this file to You under the Apache License, Version 2.0 5174990Sache * (the "License"); you may not use this file except in compliance with 638166Sache * the License. You may obtain a copy of the License at 7179048Sgabor * 8179048Sgabor * http://www.apache.org/licenses/LICENSE-2.0 9179048Sgabor * 10179048Sgabor * Unless required by applicable law or agreed to in writing, software 11179048Sgabor * distributed under the License is distributed on an "AS IS" BASIS, 12179048Sgabor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13179048Sgabor * See the License for the specific language governing permissions and 14179048Sgabor * limitations under the License. 15179048Sgabor */ 16179048Sgabor/* This is derived from material copyright RSA Data Security, Inc. 17179048Sgabor * Their notice is reproduced below in its entirety. 18179048Sgabor * 1938166Sache * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 20174990Sache * rights reserved. 2138166Sache * 22179048Sgabor * License to copy and use this software is granted provided that it 23179048Sgabor * is identified as the "RSA Data Security, Inc. MD4 Message-Digest 24179048Sgabor * Algorithm" in all material mentioning or referencing this software 25179048Sgabor * or this function. 26179048Sgabor * 27179048Sgabor * License is also granted to make and use derivative works provided 28179048Sgabor * that such works are identified as "derived from the RSA Data 29179048Sgabor * Security, Inc. MD4 Message-Digest Algorithm" in all material 30179048Sgabor * mentioning or referencing the derived work. 31179048Sgabor * 32179048Sgabor * RSA Data Security, Inc. makes no representations concerning either 33179048Sgabor * the merchantability of this software or the suitability of this 3438166Sache * software for any particular purpose. It is provided "as is" 3538166Sache * without express or implied warranty of any kind. 3638166Sache * 37179048Sgabor * These notices must be retained in any copies of any part of this 38179048Sgabor * documentation and/or software. 39179048Sgabor */ 40179048Sgabor 41179048Sgabor#ifndef APR_MD4_H 42179048Sgabor#define APR_MD4_H 43179048Sgabor 4438166Sache#include "apu.h" 4538166Sache#include "apr_xlate.h" 4638166Sache/** 47179048Sgabor * @file apr_md4.h 48179048Sgabor * @brief APR-UTIL MD4 Library 49179048Sgabor */ 50179048Sgabor#ifdef __cplusplus 51179048Sgaborextern "C" { 52179048Sgabor#endif 53179048Sgabor 5438166Sache/** 5538166Sache * @defgroup APR_Util_MD4 MD4 Library 5638166Sache * @ingroup APR_Util 5738166Sache * @{ 5838166Sache */ 5938166Sache 6038166Sache/** The digestsize for MD4 */ 6138166Sache#define APR_MD4_DIGESTSIZE 16 6238166Sache 6338166Sache/** @see apr_md4_ctx_t */ 6438166Sachetypedef struct apr_md4_ctx_t apr_md4_ctx_t; 6554090Sache 6638166Sache/** MD4 context. */ 6738166Sachestruct apr_md4_ctx_t { 6838166Sache /** state (ABCD) */ 6938166Sache apr_uint32_t state[4]; 7038166Sache /** number of bits, modulo 2^64 (lsb first) */ 7138166Sache apr_uint32_t count[2]; 7238166Sache /** input buffer */ 7338166Sache unsigned char buffer[64]; 7438166Sache#if APR_HAS_XLATE 7538166Sache /** translation handle */ 7638166Sache apr_xlate_t *xlate; 7754090Sache#endif 7853943Sache}; 79174990Sache 8053943Sache/** 81179048Sgabor * MD4 Initialize. Begins an MD4 operation, writing a new context. 82179048Sgabor * @param context The MD4 context to initialize. 83179048Sgabor */ 84179048SgaborAPU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context); 85179048Sgabor 86179048Sgabor#if APR_HAS_XLATE 87179048Sgabor/** 88179048Sgabor * MDr4 translation setup. Provides the APR translation handle to be used 89179048Sgabor * for translating the content before calculating the digest. 90179048Sgabor * @param context The MD4 content to set the translation for. 91179048Sgabor * @param xlate The translation handle to use for this MD4 context 92179048Sgabor */ 9353943SacheAPU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context, 9474413Sache apr_xlate_t *xlate); 9553943Sache#else 9674413Sache#define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL 9753961Sache#endif 9874413Sache 9953961Sache/** 10074413Sache * MD4 block update operation. Continue an MD4 message-digest operation, 10174413Sache * processing another message block, and updating the context. 102 * @param context The MD4 content to update. 103 * @param input next message block to update 104 * @param inputLen The length of the next message block 105 */ 106APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context, 107 const unsigned char *input, 108 apr_size_t inputLen); 109 110/** 111 * MD4 finalization. Ends an MD4 message-digest operation, writing the 112 * message digest and zeroing the context 113 * @param digest The final MD4 digest 114 * @param context The MD4 content we are finalizing. 115 */ 116APU_DECLARE(apr_status_t) apr_md4_final( 117 unsigned char digest[APR_MD4_DIGESTSIZE], 118 apr_md4_ctx_t *context); 119 120/** 121 * MD4 digest computation 122 * @param digest The MD4 digest 123 * @param input message block to use 124 * @param inputLen The length of the message block 125 */ 126APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE], 127 const unsigned char *input, 128 apr_size_t inputLen); 129 130/** @} */ 131#ifdef __cplusplus 132} 133#endif 134 135#endif /* !APR_MD4_H */ 136