Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /**
nexpaq 0:6c56fb4bc5f0 2 * \file md5.h
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * \brief MD5 message digest algorithm (hash function)
nexpaq 0:6c56fb4bc5f0 5 *
nexpaq 0:6c56fb4bc5f0 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
nexpaq 0:6c56fb4bc5f0 7 * SPDX-License-Identifier: Apache-2.0
nexpaq 0:6c56fb4bc5f0 8 *
nexpaq 0:6c56fb4bc5f0 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
nexpaq 0:6c56fb4bc5f0 10 * not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 11 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 12 *
nexpaq 0:6c56fb4bc5f0 13 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 14 *
nexpaq 0:6c56fb4bc5f0 15 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
nexpaq 0:6c56fb4bc5f0 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 18 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 19 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 20 *
nexpaq 0:6c56fb4bc5f0 21 * This file is part of mbed TLS (https://tls.mbed.org)
nexpaq 0:6c56fb4bc5f0 22 */
nexpaq 0:6c56fb4bc5f0 23 #ifndef MBEDTLS_MD5_H
nexpaq 0:6c56fb4bc5f0 24 #define MBEDTLS_MD5_H
nexpaq 0:6c56fb4bc5f0 25
nexpaq 0:6c56fb4bc5f0 26 #if !defined(MBEDTLS_CONFIG_FILE)
nexpaq 0:6c56fb4bc5f0 27 #include "config.h"
nexpaq 0:6c56fb4bc5f0 28 #else
nexpaq 0:6c56fb4bc5f0 29 #include MBEDTLS_CONFIG_FILE
nexpaq 0:6c56fb4bc5f0 30 #endif
nexpaq 0:6c56fb4bc5f0 31
nexpaq 0:6c56fb4bc5f0 32 #include <stddef.h>
nexpaq 0:6c56fb4bc5f0 33 #include <stdint.h>
nexpaq 0:6c56fb4bc5f0 34
nexpaq 0:6c56fb4bc5f0 35 #if !defined(MBEDTLS_MD5_ALT)
nexpaq 0:6c56fb4bc5f0 36 // Regular implementation
nexpaq 0:6c56fb4bc5f0 37 //
nexpaq 0:6c56fb4bc5f0 38
nexpaq 0:6c56fb4bc5f0 39 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 40 extern "C" {
nexpaq 0:6c56fb4bc5f0 41 #endif
nexpaq 0:6c56fb4bc5f0 42
nexpaq 0:6c56fb4bc5f0 43 /**
nexpaq 0:6c56fb4bc5f0 44 * \brief MD5 context structure
nexpaq 0:6c56fb4bc5f0 45 */
nexpaq 0:6c56fb4bc5f0 46 typedef struct
nexpaq 0:6c56fb4bc5f0 47 {
nexpaq 0:6c56fb4bc5f0 48 uint32_t total[2]; /*!< number of bytes processed */
nexpaq 0:6c56fb4bc5f0 49 uint32_t state[4]; /*!< intermediate digest state */
nexpaq 0:6c56fb4bc5f0 50 unsigned char buffer[64]; /*!< data block being processed */
nexpaq 0:6c56fb4bc5f0 51 }
nexpaq 0:6c56fb4bc5f0 52 mbedtls_md5_context;
nexpaq 0:6c56fb4bc5f0 53
nexpaq 0:6c56fb4bc5f0 54 /**
nexpaq 0:6c56fb4bc5f0 55 * \brief Initialize MD5 context
nexpaq 0:6c56fb4bc5f0 56 *
nexpaq 0:6c56fb4bc5f0 57 * \param ctx MD5 context to be initialized
nexpaq 0:6c56fb4bc5f0 58 */
nexpaq 0:6c56fb4bc5f0 59 void mbedtls_md5_init( mbedtls_md5_context *ctx );
nexpaq 0:6c56fb4bc5f0 60
nexpaq 0:6c56fb4bc5f0 61 /**
nexpaq 0:6c56fb4bc5f0 62 * \brief Clear MD5 context
nexpaq 0:6c56fb4bc5f0 63 *
nexpaq 0:6c56fb4bc5f0 64 * \param ctx MD5 context to be cleared
nexpaq 0:6c56fb4bc5f0 65 */
nexpaq 0:6c56fb4bc5f0 66 void mbedtls_md5_free( mbedtls_md5_context *ctx );
nexpaq 0:6c56fb4bc5f0 67
nexpaq 0:6c56fb4bc5f0 68 /**
nexpaq 0:6c56fb4bc5f0 69 * \brief Clone (the state of) an MD5 context
nexpaq 0:6c56fb4bc5f0 70 *
nexpaq 0:6c56fb4bc5f0 71 * \param dst The destination context
nexpaq 0:6c56fb4bc5f0 72 * \param src The context to be cloned
nexpaq 0:6c56fb4bc5f0 73 */
nexpaq 0:6c56fb4bc5f0 74 void mbedtls_md5_clone( mbedtls_md5_context *dst,
nexpaq 0:6c56fb4bc5f0 75 const mbedtls_md5_context *src );
nexpaq 0:6c56fb4bc5f0 76
nexpaq 0:6c56fb4bc5f0 77 /**
nexpaq 0:6c56fb4bc5f0 78 * \brief MD5 context setup
nexpaq 0:6c56fb4bc5f0 79 *
nexpaq 0:6c56fb4bc5f0 80 * \param ctx context to be initialized
nexpaq 0:6c56fb4bc5f0 81 */
nexpaq 0:6c56fb4bc5f0 82 void mbedtls_md5_starts( mbedtls_md5_context *ctx );
nexpaq 0:6c56fb4bc5f0 83
nexpaq 0:6c56fb4bc5f0 84 /**
nexpaq 0:6c56fb4bc5f0 85 * \brief MD5 process buffer
nexpaq 0:6c56fb4bc5f0 86 *
nexpaq 0:6c56fb4bc5f0 87 * \param ctx MD5 context
nexpaq 0:6c56fb4bc5f0 88 * \param input buffer holding the data
nexpaq 0:6c56fb4bc5f0 89 * \param ilen length of the input data
nexpaq 0:6c56fb4bc5f0 90 */
nexpaq 0:6c56fb4bc5f0 91 void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen );
nexpaq 0:6c56fb4bc5f0 92
nexpaq 0:6c56fb4bc5f0 93 /**
nexpaq 0:6c56fb4bc5f0 94 * \brief MD5 final digest
nexpaq 0:6c56fb4bc5f0 95 *
nexpaq 0:6c56fb4bc5f0 96 * \param ctx MD5 context
nexpaq 0:6c56fb4bc5f0 97 * \param output MD5 checksum result
nexpaq 0:6c56fb4bc5f0 98 */
nexpaq 0:6c56fb4bc5f0 99 void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] );
nexpaq 0:6c56fb4bc5f0 100
nexpaq 0:6c56fb4bc5f0 101 /* Internal use */
nexpaq 0:6c56fb4bc5f0 102 void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] );
nexpaq 0:6c56fb4bc5f0 103
nexpaq 0:6c56fb4bc5f0 104 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 105 }
nexpaq 0:6c56fb4bc5f0 106 #endif
nexpaq 0:6c56fb4bc5f0 107
nexpaq 0:6c56fb4bc5f0 108 #else /* MBEDTLS_MD5_ALT */
nexpaq 0:6c56fb4bc5f0 109 #include "md5_alt.h"
nexpaq 0:6c56fb4bc5f0 110 #endif /* MBEDTLS_MD5_ALT */
nexpaq 0:6c56fb4bc5f0 111
nexpaq 0:6c56fb4bc5f0 112 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 113 extern "C" {
nexpaq 0:6c56fb4bc5f0 114 #endif
nexpaq 0:6c56fb4bc5f0 115
nexpaq 0:6c56fb4bc5f0 116 /**
nexpaq 0:6c56fb4bc5f0 117 * \brief Output = MD5( input buffer )
nexpaq 0:6c56fb4bc5f0 118 *
nexpaq 0:6c56fb4bc5f0 119 * \param input buffer holding the data
nexpaq 0:6c56fb4bc5f0 120 * \param ilen length of the input data
nexpaq 0:6c56fb4bc5f0 121 * \param output MD5 checksum result
nexpaq 0:6c56fb4bc5f0 122 */
nexpaq 0:6c56fb4bc5f0 123 void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] );
nexpaq 0:6c56fb4bc5f0 124
nexpaq 0:6c56fb4bc5f0 125 /**
nexpaq 0:6c56fb4bc5f0 126 * \brief Checkup routine
nexpaq 0:6c56fb4bc5f0 127 *
nexpaq 0:6c56fb4bc5f0 128 * \return 0 if successful, or 1 if the test failed
nexpaq 0:6c56fb4bc5f0 129 */
nexpaq 0:6c56fb4bc5f0 130 int mbedtls_md5_self_test( int verbose );
nexpaq 0:6c56fb4bc5f0 131
nexpaq 0:6c56fb4bc5f0 132 #ifdef __cplusplus
nexpaq 0:6c56fb4bc5f0 133 }
nexpaq 0:6c56fb4bc5f0 134 #endif
nexpaq 0:6c56fb4bc5f0 135
nexpaq 0:6c56fb4bc5f0 136 #endif /* mbedtls_md5.h */