blob: 45214d41d9f9c1d8f18f9dda265a28d37dac6381 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
Simon Butcher5b331b92016-01-03 16:14:14 +00002 * \file md4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief MD4 message digest algorithm (hash function)
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000020 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000021 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#ifndef MBEDTLS_MD4_H
24#define MBEDTLS_MD4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000025
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker90995b52013-06-24 19:20:35 +020027#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020028#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020030#endif
Paul Bakker90995b52013-06-24 19:20:35 +020031
Rich Evans00ab4702015-02-06 13:43:58 +000032#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020033#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000034
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020035#if !defined(MBEDTLS_MD4_ALT)
Paul Bakker90995b52013-06-24 19:20:35 +020036// Regular implementation
37//
38
Paul Bakker407a0da2013-06-27 14:29:21 +020039#ifdef __cplusplus
40extern "C" {
41#endif
42
Paul Bakker5121ce52009-01-03 21:22:43 +000043/**
44 * \brief MD4 context structure
45 */
46typedef struct
47{
Paul Bakker5c2364c2012-10-01 14:41:15 +000048 uint32_t total[2]; /*!< number of bytes processed */
49 uint32_t state[4]; /*!< intermediate digest state */
Paul Bakker5121ce52009-01-03 21:22:43 +000050 unsigned char buffer[64]; /*!< data block being processed */
Paul Bakker5121ce52009-01-03 21:22:43 +000051}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020052mbedtls_md4_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000053
Paul Bakker5121ce52009-01-03 21:22:43 +000054/**
Paul Bakker5b4af392014-06-26 12:09:34 +020055 * \brief Initialize MD4 context
56 *
57 * \param ctx MD4 context to be initialized
58 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020059void mbedtls_md4_init( mbedtls_md4_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020060
61/**
62 * \brief Clear MD4 context
63 *
64 * \param ctx MD4 context to be cleared
65 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020066void mbedtls_md4_free( mbedtls_md4_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020067
68/**
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +020069 * \brief Clone (the state of) an MD4 context
70 *
71 * \param dst The destination context
72 * \param src The context to be cloned
73 */
74void mbedtls_md4_clone( mbedtls_md4_context *dst,
75 const mbedtls_md4_context *src );
76
77/**
Paul Bakker5121ce52009-01-03 21:22:43 +000078 * \brief MD4 context setup
79 *
80 * \param ctx context to be initialized
81 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020082void mbedtls_md4_starts( mbedtls_md4_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +000083
84/**
85 * \brief MD4 process buffer
86 *
87 * \param ctx MD4 context
88 * \param input buffer holding the data
89 * \param ilen length of the input data
90 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020091void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen );
Paul Bakker5121ce52009-01-03 21:22:43 +000092
93/**
94 * \brief MD4 final digest
95 *
96 * \param ctx MD4 context
97 * \param output MD4 checksum result
98 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020099void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] );
Paul Bakker5121ce52009-01-03 21:22:43 +0000100
Paul Bakker90995b52013-06-24 19:20:35 +0200101#ifdef __cplusplus
102}
103#endif
104
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200105#else /* MBEDTLS_MD4_ALT */
Paul Bakker90995b52013-06-24 19:20:35 +0200106#include "md4_alt.h"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200107#endif /* MBEDTLS_MD4_ALT */
Paul Bakker90995b52013-06-24 19:20:35 +0200108
109#ifdef __cplusplus
110extern "C" {
111#endif
112
Paul Bakker5121ce52009-01-03 21:22:43 +0000113/**
114 * \brief Output = MD4( input buffer )
115 *
116 * \param input buffer holding the data
117 * \param ilen length of the input data
118 * \param output MD4 checksum result
119 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200120void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] );
Paul Bakker5121ce52009-01-03 21:22:43 +0000121
122/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000123 * \brief Checkup routine
124 *
125 * \return 0 if successful, or 1 if the test failed
126 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200127int mbedtls_md4_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000128
Paul Bakker1bd3ae82013-03-13 10:26:44 +0100129/* Internal use */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200130void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] );
Paul Bakker1bd3ae82013-03-13 10:26:44 +0100131
Paul Bakker5121ce52009-01-03 21:22:43 +0000132#ifdef __cplusplus
133}
134#endif
135
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200136#endif /* mbedtls_md4.h */