apr_md4.h revision 302408
1219820Sjeff/* Licensed to the Apache Software Foundation (ASF) under one or more
2219820Sjeff * contributor license agreements.  See the NOTICE file distributed with
3219820Sjeff * this work for additional information regarding copyright ownership.
4219820Sjeff * The ASF licenses this file to You under the Apache License, Version 2.0
5219820Sjeff * (the "License"); you may not use this file except in compliance with
6219820Sjeff * the License.  You may obtain a copy of the License at
7219820Sjeff *
8219820Sjeff *     http://www.apache.org/licenses/LICENSE-2.0
9219820Sjeff *
10219820Sjeff * Unless required by applicable law or agreed to in writing, software
11219820Sjeff * distributed under the License is distributed on an "AS IS" BASIS,
12219820Sjeff * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13219820Sjeff * See the License for the specific language governing permissions and
14219820Sjeff * limitations under the License.
15219820Sjeff */
16219820Sjeff/* This is derived from material copyright RSA Data Security, Inc.
17219820Sjeff * Their notice is reproduced below in its entirety.
18219820Sjeff *
19219820Sjeff * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
20219820Sjeff * rights reserved.
21219820Sjeff *
22219820Sjeff * License to copy and use this software is granted provided that it
23219820Sjeff * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
24219820Sjeff * Algorithm" in all material mentioning or referencing this software
25219820Sjeff * or this function.
26219820Sjeff *
27219820Sjeff * License is also granted to make and use derivative works provided
28219820Sjeff * that such works are identified as "derived from the RSA Data
29219820Sjeff * Security, Inc. MD4 Message-Digest Algorithm" in all material
30219820Sjeff * mentioning or referencing the derived work.
31219820Sjeff *
32219820Sjeff * RSA Data Security, Inc. makes no representations concerning either
33219820Sjeff * the merchantability of this software or the suitability of this
34219820Sjeff * software for any particular purpose. It is provided "as is"
35219820Sjeff * without express or implied warranty of any kind.
36219820Sjeff *
37219820Sjeff * These notices must be retained in any copies of any part of this
38219820Sjeff * documentation and/or software.
39219820Sjeff */
40219820Sjeff
41273135Shselasky#ifndef APR_MD4_H
42219820Sjeff#define APR_MD4_H
43219820Sjeff
44219820Sjeff#include "apu.h"
45219820Sjeff#include "apr_xlate.h"
46219820Sjeff/**
47219820Sjeff * @file apr_md4.h
48219820Sjeff * @brief APR-UTIL MD4 Library
49219820Sjeff */
50219820Sjeff#ifdef __cplusplus
51219820Sjeffextern "C" {
52219820Sjeff#endif
53219820Sjeff
54219820Sjeff/**
55219820Sjeff * @defgroup APR_Util_MD4 MD4 Library
56219820Sjeff * @ingroup APR_Util
57219820Sjeff * @{
58219820Sjeff */
59219820Sjeff
60219820Sjeff/** The digestsize for MD4 */
61219820Sjeff#define APR_MD4_DIGESTSIZE 16
62219820Sjeff
63219820Sjeff/** @see apr_md4_ctx_t */
64219820Sjefftypedef struct apr_md4_ctx_t apr_md4_ctx_t;
65219820Sjeff
66219820Sjeff/** MD4 context. */
67219820Sjeffstruct apr_md4_ctx_t {
68219820Sjeff    /** state (ABCD) */
69219820Sjeff    apr_uint32_t state[4];
70219820Sjeff    /** number of bits, modulo 2^64 (lsb first) */
71219820Sjeff    apr_uint32_t count[2];
72219820Sjeff    /** input buffer */
73219820Sjeff    unsigned char buffer[64];
74219820Sjeff#if APR_HAS_XLATE
75219820Sjeff    /** translation handle */
76219820Sjeff    apr_xlate_t *xlate;
77219820Sjeff#endif
78219820Sjeff};
79219820Sjeff
80219820Sjeff/**
81219820Sjeff * MD4 Initialize.  Begins an MD4 operation, writing a new context.
82219820Sjeff * @param context The MD4 context to initialize.
83219820Sjeff */
84219820SjeffAPU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context);
85219820Sjeff
86219820Sjeff#if APR_HAS_XLATE
87219820Sjeff/**
88219820Sjeff * MDr4 translation setup.  Provides the APR translation handle to be used
89219820Sjeff * for translating the content before calculating the digest.
90219820Sjeff * @param context The MD4 content to set the translation for.
91219820Sjeff * @param xlate The translation handle to use for this MD4 context
92219820Sjeff */
93219820SjeffAPU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context,
94219820Sjeff                                            apr_xlate_t *xlate);
95219820Sjeff#else
96219820Sjeff#define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL
97219820Sjeff#endif
98219820Sjeff
99219820Sjeff/**
100219820Sjeff * MD4 block update operation.  Continue an MD4 message-digest operation,
101219820Sjeff * processing another message block, and updating the context.
102219820Sjeff * @param context The MD4 content to update.
103219820Sjeff * @param input next message block to update
104219820Sjeff * @param inputLen The length of the next message block
105219820Sjeff */
106219820SjeffAPU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context,
107219820Sjeff                                         const unsigned char *input,
108219820Sjeff                                         apr_size_t inputLen);
109219820Sjeff
110219820Sjeff/**
111219820Sjeff * MD4 finalization.  Ends an MD4 message-digest operation, writing the
112219820Sjeff * message digest and zeroing the context
113219820Sjeff * @param digest The final MD4 digest
114219820Sjeff * @param context The MD4 content we are finalizing.
115219820Sjeff */
116219820SjeffAPU_DECLARE(apr_status_t) apr_md4_final(
117219820Sjeff                                    unsigned char digest[APR_MD4_DIGESTSIZE],
118219820Sjeff                                    apr_md4_ctx_t *context);
119219820Sjeff
120219820Sjeff/**
121219820Sjeff * MD4 digest computation
122219820Sjeff * @param digest The MD4 digest
123219820Sjeff * @param input message block to use
124219820Sjeff * @param inputLen The length of the message block
125219820Sjeff */
126219820SjeffAPU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE],
127219820Sjeff                                  const unsigned char *input,
128219820Sjeff                                  apr_size_t inputLen);
129219820Sjeff
130/** @} */
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* !APR_MD4_H */
136