1 /** 2 * \file md_internal.h 3 * 4 * \brief Message digest wrappers. 5 * 6 * \warning This in an internal header. Do not include directly. 7 * 8 * \author Adriaan de Jong <dejong@fox-it.com> 9 */ 10 /* 11 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 12 * SPDX-License-Identifier: Apache-2.0 13 * 14 * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 * not use this file except in compliance with the License. 16 * You may obtain a copy of the License at 17 * 18 * http://www.apache.org/licenses/LICENSE-2.0 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 * 26 * This file is part of mbed TLS (https://tls.mbed.org) 27 */ 28 #ifndef MBEDTLS_MD_WRAP_H 29 #define MBEDTLS_MD_WRAP_H 30 31 #if !defined(MBEDTLS_CONFIG_FILE) 32 #include "config.h" 33 #else 34 #include MBEDTLS_CONFIG_FILE 35 #endif 36 37 #include "md.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 /** 44 * Message digest information. 45 * Allows message digest functions to be called in a generic way. 46 */ 47 struct mbedtls_md_info_t 48 { 49 /** Digest identifier */ 50 mbedtls_md_type_t type; 51 52 /** Name of the message digest */ 53 const char * name; 54 55 /** Output length of the digest function in bytes */ 56 int size; 57 58 /** Block length of the digest function in bytes */ 59 int block_size; 60 61 /** Digest initialisation function */ 62 int (*starts_func)( void *ctx ); 63 64 /** Digest update function */ 65 int (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); 66 67 /** Digest finalisation function */ 68 int (*finish_func)( void *ctx, unsigned char *output ); 69 70 /** Generic digest function */ 71 int (*digest_func)( const unsigned char *input, size_t ilen, 72 unsigned char *output ); 73 74 /** Allocate a new context */ 75 void * (*ctx_alloc_func)( void ); 76 77 /** Free the given context */ 78 void (*ctx_free_func)( void *ctx ); 79 80 /** Clone state from a context */ 81 void (*clone_func)( void *dst, const void *src ); 82 83 /** Internal use only */ 84 int (*process_func)( void *ctx, const unsigned char *input ); 85 }; 86 87 #if defined(MBEDTLS_MD2_C) 88 extern const mbedtls_md_info_t mbedtls_md2_info; 89 #endif 90 #if defined(MBEDTLS_MD4_C) 91 extern const mbedtls_md_info_t mbedtls_md4_info; 92 #endif 93 #if defined(MBEDTLS_MD5_C) 94 extern const mbedtls_md_info_t mbedtls_md5_info; 95 #endif 96 #if defined(MBEDTLS_RIPEMD160_C) 97 extern const mbedtls_md_info_t mbedtls_ripemd160_info; 98 #endif 99 #if defined(MBEDTLS_SHA1_C) 100 extern const mbedtls_md_info_t mbedtls_sha1_info; 101 #endif 102 #if defined(MBEDTLS_SHA256_C) 103 extern const mbedtls_md_info_t mbedtls_sha224_info; 104 extern const mbedtls_md_info_t mbedtls_sha256_info; 105 #endif 106 #if defined(MBEDTLS_SHA512_C) 107 extern const mbedtls_md_info_t mbedtls_sha384_info; 108 extern const mbedtls_md_info_t mbedtls_sha512_info; 109 #endif 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* MBEDTLS_MD_WRAP_H */ 116