blob: 96dcc447f45b1e51d56eab069df7292a208d55a8 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002 * \file mbedtls_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é-Gonnarda658a402015-01-23 09:45:19 +00006 * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00008 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakkerb96f1542010-07-18 20:36:00 +00009 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000023 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020024#ifndef MBEDTLS_MD4_H
25#define MBEDTLS_MD4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000026
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020027#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker90995b52013-06-24 19:20:35 +020028#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020029#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020031#endif
Paul Bakker90995b52013-06-24 19:20:35 +020032
Rich Evans00ab4702015-02-06 13:43:58 +000033#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020034#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000035
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if !defined(MBEDTLS_MD4_ALT)
Paul Bakker90995b52013-06-24 19:20:35 +020037// Regular implementation
38//
39
Paul Bakker407a0da2013-06-27 14:29:21 +020040#ifdef __cplusplus
41extern "C" {
42#endif
43
Paul Bakker5121ce52009-01-03 21:22:43 +000044/**
45 * \brief MD4 context structure
46 */
47typedef struct
48{
Paul Bakker5c2364c2012-10-01 14:41:15 +000049 uint32_t total[2]; /*!< number of bytes processed */
50 uint32_t state[4]; /*!< intermediate digest state */
Paul Bakker5121ce52009-01-03 21:22:43 +000051 unsigned char buffer[64]; /*!< data block being processed */
Paul Bakker5121ce52009-01-03 21:22:43 +000052}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020053mbedtls_md4_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000054
Paul Bakker5121ce52009-01-03 21:22:43 +000055/**
Paul Bakker5b4af392014-06-26 12:09:34 +020056 * \brief Initialize MD4 context
57 *
58 * \param ctx MD4 context to be initialized
59 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060void mbedtls_md4_init( mbedtls_md4_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020061
62/**
63 * \brief Clear MD4 context
64 *
65 * \param ctx MD4 context to be cleared
66 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020067void mbedtls_md4_free( mbedtls_md4_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020068
69/**
Paul Bakker5121ce52009-01-03 21:22:43 +000070 * \brief MD4 context setup
71 *
72 * \param ctx context to be initialized
73 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074void mbedtls_md4_starts( mbedtls_md4_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +000075
76/**
77 * \brief MD4 process buffer
78 *
79 * \param ctx MD4 context
80 * \param input buffer holding the data
81 * \param ilen length of the input data
82 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020083void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen );
Paul Bakker5121ce52009-01-03 21:22:43 +000084
85/**
86 * \brief MD4 final digest
87 *
88 * \param ctx MD4 context
89 * \param output MD4 checksum result
90 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020091void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] );
Paul Bakker5121ce52009-01-03 21:22:43 +000092
Paul Bakker90995b52013-06-24 19:20:35 +020093#ifdef __cplusplus
94}
95#endif
96
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020097#else /* MBEDTLS_MD4_ALT */
Paul Bakker90995b52013-06-24 19:20:35 +020098#include "md4_alt.h"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020099#endif /* MBEDTLS_MD4_ALT */
Paul Bakker90995b52013-06-24 19:20:35 +0200100
101#ifdef __cplusplus
102extern "C" {
103#endif
104
Paul Bakker5121ce52009-01-03 21:22:43 +0000105/**
106 * \brief Output = MD4( input buffer )
107 *
108 * \param input buffer holding the data
109 * \param ilen length of the input data
110 * \param output MD4 checksum result
111 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200112void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] );
Paul Bakker5121ce52009-01-03 21:22:43 +0000113
114/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000115 * \brief Checkup routine
116 *
117 * \return 0 if successful, or 1 if the test failed
118 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200119int mbedtls_md4_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000120
Paul Bakker1bd3ae82013-03-13 10:26:44 +0100121/* Internal use */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200122void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] );
Paul Bakker1bd3ae82013-03-13 10:26:44 +0100123
Paul Bakker5121ce52009-01-03 21:22:43 +0000124#ifdef __cplusplus
125}
126#endif
127
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200128#endif /* mbedtls_md4.h */