apr_md4.h revision 251876
1169691Skan/* Licensed to the Apache Software Foundation (ASF) under one or more
2132720Skan * contributor license agreements.  See the NOTICE file distributed with
397403Sobrien * this work for additional information regarding copyright ownership.
4169691Skan * The ASF licenses this file to You under the Apache License, Version 2.0
5169691Skan * (the "License"); you may not use this file except in compliance with
697403Sobrien * the License.  You may obtain a copy of the License at
797403Sobrien *
897403Sobrien *     http://www.apache.org/licenses/LICENSE-2.0
997403Sobrien *
1097403Sobrien * Unless required by applicable law or agreed to in writing, software
1197403Sobrien * distributed under the License is distributed on an "AS IS" BASIS,
1297403Sobrien * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1397403Sobrien * See the License for the specific language governing permissions and
1497403Sobrien * limitations under the License.
15132720Skan */
1697403Sobrien/* This is derived from material copyright RSA Data Security, Inc.
1797403Sobrien * Their notice is reproduced below in its entirety.
1897403Sobrien *
1997403Sobrien * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
2097403Sobrien * rights reserved.
2197403Sobrien *
2297403Sobrien * License to copy and use this software is granted provided that it
23132720Skan * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
2497403Sobrien * Algorithm" in all material mentioning or referencing this software
25132720Skan * or this function.
26132720Skan *
27132720Skan * License is also granted to make and use derivative works provided
28132720Skan * that such works are identified as "derived from the RSA Data
29132720Skan * Security, Inc. MD4 Message-Digest Algorithm" in all material
3097403Sobrien * mentioning or referencing the derived work.
3197403Sobrien *
3297403Sobrien * RSA Data Security, Inc. makes no representations concerning either
3397403Sobrien * the merchantability of this software or the suitability of this
3497403Sobrien * software for any particular purpose. It is provided "as is"
3597403Sobrien * without express or implied warranty of any kind.
3697403Sobrien *
3797403Sobrien * These notices must be retained in any copies of any part of this
3897403Sobrien * documentation and/or software.
39169691Skan */
40169691Skan
41169691Skan#ifndef APR_MD4_H
42169691Skan#define APR_MD4_H
43169691Skan
44169691Skan#include "apu.h"
45169691Skan#include "apr_xlate.h"
46169691Skan/**
47169691Skan * @file apr_md4.h
48169691Skan * @brief APR-UTIL MD4 Library
49169691Skan */
50169691Skan#ifdef __cplusplus
51169691Skanextern "C" {
52169691Skan#endif
53169691Skan
54169691Skan/**
55169691Skan * @defgroup APR_Util_MD4 MD4 Library
56169691Skan * @ingroup APR_Util
57169691Skan * @{
58169691Skan */
59169691Skan
60169691Skan/** The digestsize for MD4 */
61169691Skan#define APR_MD4_DIGESTSIZE 16
62169691Skan
63169691Skan/** @see apr_md4_ctx_t */
64169691Skantypedef struct apr_md4_ctx_t apr_md4_ctx_t;
65169691Skan
66169691Skan/** MD4 context. */
67169691Skanstruct apr_md4_ctx_t {
68169691Skan    /** state (ABCD) */
69169691Skan    apr_uint32_t state[4];
70169691Skan    /** number of bits, modulo 2^64 (lsb first) */
71169691Skan    apr_uint32_t count[2];
72169691Skan    /** input buffer */
73169691Skan    unsigned char buffer[64];
74169691Skan#if APR_HAS_XLATE
75169691Skan    /** translation handle */
76169691Skan    apr_xlate_t *xlate;
77169691Skan#endif
78169691Skan};
79169691Skan
80169691Skan/**
81169691Skan * MD4 Initialize.  Begins an MD4 operation, writing a new context.
82169691Skan * @param context The MD4 context to initialize.
83169691Skan */
84169691SkanAPU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context);
85169691Skan
86169691Skan#if APR_HAS_XLATE
87169691Skan/**
88169691Skan * MDr4 translation setup.  Provides the APR translation handle to be used
89169691Skan * for translating the content before calculating the digest.
90169691Skan * @param context The MD4 content to set the translation for.
91169691Skan * @param xlate The translation handle to use for this MD4 context
92169691Skan */
93169691SkanAPU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context,
94169691Skan                                            apr_xlate_t *xlate);
95169691Skan#else
96169691Skan#define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL
97169691Skan#endif
98169691Skan
99169691Skan/**
100169691Skan * MD4 block update operation.  Continue an MD4 message-digest operation,
101169691Skan * processing another message block, and updating the context.
102169691Skan * @param context The MD4 content to update.
103169691Skan * @param input next message block to update
104169691Skan * @param inputLen The length of the next message block
105169691Skan */
106169691SkanAPU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context,
107169691Skan                                         const unsigned char *input,
108169691Skan                                         apr_size_t inputLen);
109132720Skan
110169691Skan/**
111132720Skan * MD4 finalization.  Ends an MD4 message-digest operation, writing the
112132720Skan * message digest and zeroing the context
113132720Skan * @param digest The final MD4 digest
114132720Skan * @param context The MD4 content we are finalizing.
11597403Sobrien */
11697403SobrienAPU_DECLARE(apr_status_t) apr_md4_final(
117132720Skan                                    unsigned char digest[APR_MD4_DIGESTSIZE],
118132720Skan                                    apr_md4_ctx_t *context);
119132720Skan
120132720Skan/**
121132720Skan * MD4 digest computation
12297403Sobrien * @param digest The MD4 digest
123117397Skan * @param input message block to use
12497403Sobrien * @param inputLen The length of the message block
12597403Sobrien */
126117397SkanAPU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE],
127117397Skan                                  const unsigned char *input,
128117397Skan                                  apr_size_t inputLen);
129132720Skan
130117397Skan/** @} */
13197403Sobrien#ifdef __cplusplus
132117397Skan}
133117397Skan#endif
13497403Sobrien
135117397Skan#endif /* !APR_MD4_H */
136117397Skan