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 The Mbed TLS Contributors 12 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 13 * 14 * This file is provided under the Apache License 2.0, or the 15 * GNU General Public License v2.0 or later. 16 * 17 * ********** 18 * Apache License 2.0: 19 * 20 * Licensed under the Apache License, Version 2.0 (the "License"); you may 21 * not use this file except in compliance with the License. 22 * You may obtain a copy of the License at 23 * 24 * http://www.apache.org/licenses/LICENSE-2.0 25 * 26 * Unless required by applicable law or agreed to in writing, software 27 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 28 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 * 32 * ********** 33 * 34 * ********** 35 * GNU General Public License v2.0 or later: 36 * 37 * This program is free software; you can redistribute it and/or modify 38 * it under the terms of the GNU General Public License as published by 39 * the Free Software Foundation; either version 2 of the License, or 40 * (at your option) any later version. 41 * 42 * This program is distributed in the hope that it will be useful, 43 * but WITHOUT ANY WARRANTY; without even the implied warranty of 44 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 * GNU General Public License for more details. 46 * 47 * You should have received a copy of the GNU General Public License along 48 * with this program; if not, write to the Free Software Foundation, Inc., 49 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 50 * 51 * ********** 52 */ 53 #ifndef MBEDTLS_MD_WRAP_H 54 #define MBEDTLS_MD_WRAP_H 55 56 #if !defined(MBEDTLS_CONFIG_FILE) 57 #include "config.h" 58 #else 59 #include MBEDTLS_CONFIG_FILE 60 #endif 61 62 #include "md.h" 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 /** 69 * Message digest information. 70 * Allows message digest functions to be called in a generic way. 71 */ 72 struct mbedtls_md_info_t 73 { 74 /** Digest identifier */ 75 mbedtls_md_type_t type; 76 77 /** Name of the message digest */ 78 const char * name; 79 80 /** Output length of the digest function in bytes */ 81 int size; 82 83 /** Block length of the digest function in bytes */ 84 int block_size; 85 86 /** Digest initialisation function */ 87 int (*starts_func)( void *ctx ); 88 89 /** Digest update function */ 90 int (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); 91 92 /** Digest finalisation function */ 93 int (*finish_func)( void *ctx, unsigned char *output ); 94 95 /** Generic digest function */ 96 int (*digest_func)( const unsigned char *input, size_t ilen, 97 unsigned char *output ); 98 99 /** Allocate a new context */ 100 void * (*ctx_alloc_func)( void ); 101 102 /** Free the given context */ 103 void (*ctx_free_func)( void *ctx ); 104 105 /** Clone state from a context */ 106 void (*clone_func)( void *dst, const void *src ); 107 108 /** Internal use only */ 109 int (*process_func)( void *ctx, const unsigned char *input ); 110 }; 111 112 #if defined(MBEDTLS_MD2_C) 113 extern const mbedtls_md_info_t mbedtls_md2_info; 114 #endif 115 #if defined(MBEDTLS_MD4_C) 116 extern const mbedtls_md_info_t mbedtls_md4_info; 117 #endif 118 #if defined(MBEDTLS_MD5_C) 119 extern const mbedtls_md_info_t mbedtls_md5_info; 120 #endif 121 #if defined(MBEDTLS_RIPEMD160_C) 122 extern const mbedtls_md_info_t mbedtls_ripemd160_info; 123 #endif 124 #if defined(MBEDTLS_SHA1_C) 125 extern const mbedtls_md_info_t mbedtls_sha1_info; 126 #endif 127 #if defined(MBEDTLS_SHA256_C) 128 extern const mbedtls_md_info_t mbedtls_sha224_info; 129 extern const mbedtls_md_info_t mbedtls_sha256_info; 130 #endif 131 #if defined(MBEDTLS_SHA512_C) 132 extern const mbedtls_md_info_t mbedtls_sha384_info; 133 extern const mbedtls_md_info_t mbedtls_sha512_info; 134 #endif 135 136 #ifdef __cplusplus 137 } 138 #endif 139 140 #endif /* MBEDTLS_MD_WRAP_H */ 141