Jan Korycan / WNCInterface

Dependencies:   WncControllerK64F

Fork of WNCInterface by Jan Korycan

Committer:
korycanjan
Date:
Thu Apr 05 03:17:03 2018 +0000
Revision:
33:f41d199375f0
Parent:
12:0071cb144c7a
Better stability

Who changed what in which revision?

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