Apache Portable Runtime
|
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 /* This is derived from material copyright RSA Data Security, Inc. 00017 * Their notice is reproduced below in its entirety. 00018 * 00019 * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 00020 * rights reserved. 00021 * 00022 * License to copy and use this software is granted provided that it 00023 * is identified as the "RSA Data Security, Inc. MD4 Message-Digest 00024 * Algorithm" in all material mentioning or referencing this software 00025 * or this function. 00026 * 00027 * License is also granted to make and use derivative works provided 00028 * that such works are identified as "derived from the RSA Data 00029 * Security, Inc. MD4 Message-Digest Algorithm" in all material 00030 * mentioning or referencing the derived work. 00031 * 00032 * RSA Data Security, Inc. makes no representations concerning either 00033 * the merchantability of this software or the suitability of this 00034 * software for any particular purpose. It is provided "as is" 00035 * without express or implied warranty of any kind. 00036 * 00037 * These notices must be retained in any copies of any part of this 00038 * documentation and/or software. 00039 */ 00040 00041 #ifndef APR_MD4_H 00042 #define APR_MD4_H 00043 00044 #include "apu.h" 00045 #include "apr_xlate.h" 00046 /** 00047 * @file apr_md4.h 00048 * @brief APR-UTIL MD4 Library 00049 */ 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 /** 00055 * @defgroup APR_Util_MD4 MD4 Library 00056 * @ingroup APR_Util 00057 * @{ 00058 */ 00059 00060 /** The digestsize for MD4 */ 00061 #define APR_MD4_DIGESTSIZE 16 00062 00063 /** @see apr_md4_ctx_t */ 00064 typedef struct apr_md4_ctx_t apr_md4_ctx_t; 00065 00066 /** MD4 context. */ 00067 struct apr_md4_ctx_t { 00068 /** state (ABCD) */ 00069 apr_uint32_t state[4]; 00070 /** number of bits, modulo 2^64 (lsb first) */ 00071 apr_uint32_t count[2]; 00072 /** input buffer */ 00073 unsigned char buffer[64]; 00074 #if APR_HAS_XLATE 00075 /** translation handle */ 00076 apr_xlate_t *xlate; 00077 #endif 00078 }; 00079 00080 /** 00081 * MD4 Initialize. Begins an MD4 operation, writing a new context. 00082 * @param context The MD4 context to initialize. 00083 */ 00084 APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context); 00085 00086 #if APR_HAS_XLATE 00087 /** 00088 * MDr4 translation setup. Provides the APR translation handle to be used 00089 * for translating the content before calculating the digest. 00090 * @param context The MD4 content to set the translation for. 00091 * @param xlate The translation handle to use for this MD4 context 00092 */ 00093 APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context, 00094 apr_xlate_t *xlate); 00095 #else 00096 #define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL 00097 #endif 00098 00099 /** 00100 * MD4 block update operation. Continue an MD4 message-digest operation, 00101 * processing another message block, and updating the context. 00102 * @param context The MD4 content to update. 00103 * @param input next message block to update 00104 * @param inputLen The length of the next message block 00105 */ 00106 APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context, 00107 const unsigned char *input, 00108 apr_size_t inputLen); 00109 00110 /** 00111 * MD4 finalization. Ends an MD4 message-digest operation, writing the 00112 * message digest and zeroing the context 00113 * @param digest The final MD4 digest 00114 * @param context The MD4 content we are finalizing. 00115 */ 00116 APU_DECLARE(apr_status_t) apr_md4_final( 00117 unsigned char digest[APR_MD4_DIGESTSIZE], 00118 apr_md4_ctx_t *context); 00119 00120 /** 00121 * MD4 digest computation 00122 * @param digest The MD4 digest 00123 * @param input message block to use 00124 * @param inputLen The length of the message block 00125 */ 00126 APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE], 00127 const unsigned char *input, 00128 apr_size_t inputLen); 00129 00130 /** @} */ 00131 #ifdef __cplusplus 00132 } 00133 #endif 00134 00135 #endif /* !APR_MD4_H */