Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file md_wrap.h |
Paul Bakker | 9af723c | 2014-05-01 13:03:14 +0200 | [diff] [blame] | 3 | * |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 4 | * \brief Message digest wrappers. |
| 5 | * |
Manuel Pégourié-Gonnard | ca878db | 2015-03-24 12:13:30 +0100 | [diff] [blame^] | 6 | * \warning This in an internal header. Do not include directly. |
| 7 | * |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 8 | * \author Adriaan de Jong <dejong@fox-it.com> |
| 9 | * |
Manuel Pégourié-Gonnard | ca878db | 2015-03-24 12:13:30 +0100 | [diff] [blame^] | 10 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 11 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 12 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 13 | * |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License along |
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 26 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 27 | */ |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 28 | #ifndef POLARSSL_MD_WRAP_H |
| 29 | #define POLARSSL_MD_WRAP_H |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 30 | |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 31 | #if !defined(POLARSSL_CONFIG_FILE) |
Paul Bakker | 314052f | 2011-08-15 09:07:52 +0000 | [diff] [blame] | 32 | #include "config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 33 | #else |
| 34 | #include POLARSSL_CONFIG_FILE |
| 35 | #endif |
Manuel Pégourié-Gonnard | 6c5abfa | 2015-02-13 14:12:07 +0000 | [diff] [blame] | 36 | |
Paul Bakker | 314052f | 2011-08-15 09:07:52 +0000 | [diff] [blame] | 37 | #include "md.h" |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 38 | |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | |
Manuel Pégourié-Gonnard | ca878db | 2015-03-24 12:13:30 +0100 | [diff] [blame^] | 43 | /** |
| 44 | * Message digest information. |
| 45 | * Allows message digest functions to be called in a generic way. |
| 46 | */ |
| 47 | struct _md_info_t { |
| 48 | /** Digest identifier */ |
| 49 | md_type_t type; |
| 50 | |
| 51 | /** Name of the message digest */ |
| 52 | const char * name; |
| 53 | |
| 54 | /** Output length of the digest function */ |
| 55 | int size; |
| 56 | |
| 57 | /** Digest initialisation function */ |
| 58 | void (*starts_func)( void *ctx ); |
| 59 | |
| 60 | /** Digest update function */ |
| 61 | void (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); |
| 62 | |
| 63 | /** Digest finalisation function */ |
| 64 | void (*finish_func)( void *ctx, unsigned char *output ); |
| 65 | |
| 66 | /** Generic digest function */ |
| 67 | void (*digest_func)( const unsigned char *input, size_t ilen, |
| 68 | unsigned char *output ); |
| 69 | |
| 70 | /** Generic file digest function */ |
| 71 | int (*file_func)( const char *path, unsigned char *output ); |
| 72 | |
| 73 | /** HMAC Initialisation function */ |
| 74 | void (*hmac_starts_func)( void *ctx, const unsigned char *key, |
| 75 | size_t keylen ); |
| 76 | |
| 77 | /** HMAC update function */ |
| 78 | void (*hmac_update_func)( void *ctx, const unsigned char *input, |
| 79 | size_t ilen ); |
| 80 | |
| 81 | /** HMAC finalisation function */ |
| 82 | void (*hmac_finish_func)( void *ctx, unsigned char *output); |
| 83 | |
| 84 | /** HMAC context reset function */ |
| 85 | void (*hmac_reset_func)( void *ctx ); |
| 86 | |
| 87 | /** Generic HMAC function */ |
| 88 | void (*hmac_func)( const unsigned char *key, size_t keylen, |
| 89 | const unsigned char *input, size_t ilen, |
| 90 | unsigned char *output ); |
| 91 | |
| 92 | /** Allocate a new context */ |
| 93 | void * (*ctx_alloc_func)( void ); |
| 94 | |
| 95 | /** Free the given context */ |
| 96 | void (*ctx_free_func)( void *ctx ); |
| 97 | |
| 98 | /** Internal use only */ |
| 99 | void (*process_func)( void *ctx, const unsigned char *input ); |
| 100 | }; |
| 101 | |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 102 | #if defined(POLARSSL_MD2_C) |
| 103 | extern const md_info_t md2_info; |
| 104 | #endif |
| 105 | #if defined(POLARSSL_MD4_C) |
| 106 | extern const md_info_t md4_info; |
| 107 | #endif |
| 108 | #if defined(POLARSSL_MD5_C) |
| 109 | extern const md_info_t md5_info; |
| 110 | #endif |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 111 | #if defined(POLARSSL_RIPEMD160_C) |
| 112 | extern const md_info_t ripemd160_info; |
Manuel Pégourié-Gonnard | e4d47a6 | 2014-01-17 20:41:32 +0100 | [diff] [blame] | 113 | #endif |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 114 | #if defined(POLARSSL_SHA1_C) |
| 115 | extern const md_info_t sha1_info; |
| 116 | #endif |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 117 | #if defined(POLARSSL_SHA256_C) |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 118 | extern const md_info_t sha224_info; |
| 119 | extern const md_info_t sha256_info; |
| 120 | #endif |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 121 | #if defined(POLARSSL_SHA512_C) |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 122 | extern const md_info_t sha384_info; |
| 123 | extern const md_info_t sha512_info; |
| 124 | #endif |
| 125 | |
| 126 | #ifdef __cplusplus |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | #endif /* POLARSSL_MD_WRAP_H */ |