Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * generic message digest layer demonstration program |
| 3 | * |
Bence Szépkúti | a2947ac | 2020-08-19 16:37:36 +0200 | [diff] [blame] | 4 | * Copyright The Mbed TLS Contributors |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 6 | * |
| 7 | * This file is provided under the Apache License 2.0, or the |
| 8 | * GNU General Public License v2.0 or later. |
| 9 | * |
| 10 | * ********** |
| 11 | * Apache License 2.0: |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 12 | * |
| 13 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 14 | * not use this file except in compliance with the License. |
| 15 | * You may obtain a copy of the License at |
| 16 | * |
| 17 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | * |
| 19 | * Unless required by applicable law or agreed to in writing, software |
| 20 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 | * See the License for the specific language governing permissions and |
| 23 | * limitations under the License. |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 24 | * |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 25 | * ********** |
| 26 | * |
| 27 | * ********** |
| 28 | * GNU General Public License v2.0 or later: |
| 29 | * |
| 30 | * This program is free software; you can redistribute it and/or modify |
| 31 | * it under the terms of the GNU General Public License as published by |
| 32 | * the Free Software Foundation; either version 2 of the License, or |
| 33 | * (at your option) any later version. |
| 34 | * |
| 35 | * This program is distributed in the hope that it will be useful, |
| 36 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 37 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 38 | * GNU General Public License for more details. |
| 39 | * |
| 40 | * You should have received a copy of the GNU General Public License along |
| 41 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 42 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 43 | * |
| 44 | * ********** |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 45 | */ |
| 46 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 47 | #if !defined(MBEDTLS_CONFIG_FILE) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 48 | #include "mbedtls/config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 49 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 50 | #include MBEDTLS_CONFIG_FILE |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 51 | #endif |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 52 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 53 | #if defined(MBEDTLS_PLATFORM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 54 | #include "mbedtls/platform.h" |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 55 | #else |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 56 | #include <stdio.h> |
Andres Amaya Garcia | dabd78f | 2018-04-29 22:35:36 +0100 | [diff] [blame] | 57 | #include <stdlib.h> |
| 58 | #define mbedtls_fprintf fprintf |
| 59 | #define mbedtls_printf printf |
Manuel Pégourié-Gonnard | 3ef6a6d | 2018-12-10 14:31:45 +0100 | [diff] [blame] | 60 | #define mbedtls_exit exit |
Andres Amaya Garcia | 7d42965 | 2018-04-30 22:42:33 +0100 | [diff] [blame] | 61 | #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS |
Andres Amaya Garcia | dabd78f | 2018-04-29 22:35:36 +0100 | [diff] [blame] | 62 | #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE |
| 63 | #endif /* MBEDTLS_PLATFORM_C */ |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 64 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 65 | #if defined(MBEDTLS_MD_C) && defined(MBEDTLS_FS_IO) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 66 | #include "mbedtls/md.h" |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 67 | |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 68 | #include <stdio.h> |
| 69 | #include <string.h> |
| 70 | #endif |
| 71 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 72 | #if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_FS_IO) |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 73 | int main( void ) |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 74 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 75 | mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n"); |
Krzysztof Stachowiak | 3b0c430 | 2019-04-24 14:24:46 +0200 | [diff] [blame] | 76 | mbedtls_exit( 0 ); |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 77 | } |
| 78 | #else |
Manuel Pégourié-Gonnard | 3ef6a6d | 2018-12-10 14:31:45 +0100 | [diff] [blame] | 79 | |
Manuel Pégourié-Gonnard | 3ef6a6d | 2018-12-10 14:31:45 +0100 | [diff] [blame] | 80 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 81 | static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 82 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 83 | int ret = mbedtls_md_file( md_info, filename, sum ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 84 | |
| 85 | if( ret == 1 ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 86 | mbedtls_fprintf( stderr, "failed to open: %s\n", filename ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 87 | |
| 88 | if( ret == 2 ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 89 | mbedtls_fprintf( stderr, "failed to read: %s\n", filename ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 90 | |
| 91 | return( ret ); |
| 92 | } |
| 93 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 94 | static int generic_print( const mbedtls_md_info_t *md_info, char *filename ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 95 | { |
| 96 | int i; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 97 | unsigned char sum[MBEDTLS_MD_MAX_SIZE]; |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 98 | |
| 99 | if( generic_wrapper( md_info, filename, sum ) != 0 ) |
| 100 | return( 1 ); |
| 101 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 102 | for( i = 0; i < mbedtls_md_get_size( md_info ); i++ ) |
| 103 | mbedtls_printf( "%02x", sum[i] ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 104 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 105 | mbedtls_printf( " %s\n", filename ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 106 | return( 0 ); |
| 107 | } |
| 108 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 109 | static int generic_check( const mbedtls_md_info_t *md_info, char *filename ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 110 | { |
| 111 | int i; |
| 112 | size_t n; |
| 113 | FILE *f; |
| 114 | int nb_err1, nb_err2; |
| 115 | int nb_tot1, nb_tot2; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 116 | unsigned char sum[MBEDTLS_MD_MAX_SIZE]; |
Paul Bakker | d1fe7aa | 2016-05-12 12:46:02 +0100 | [diff] [blame] | 117 | char line[1024]; |
Manuel Pégourié-Gonnard | 291f9af | 2013-10-28 12:51:32 +0100 | [diff] [blame] | 118 | char diff; |
Paul Bakker | d1fe7aa | 2016-05-12 12:46:02 +0100 | [diff] [blame] | 119 | #if defined(__clang_analyzer__) |
| 120 | char buf[MBEDTLS_MD_MAX_SIZE * 2 + 1] = { }; |
| 121 | #else |
| 122 | char buf[MBEDTLS_MD_MAX_SIZE * 2 + 1]; |
| 123 | #endif |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 124 | |
| 125 | if( ( f = fopen( filename, "rb" ) ) == NULL ) |
| 126 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 127 | mbedtls_printf( "failed to open: %s\n", filename ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 128 | return( 1 ); |
| 129 | } |
| 130 | |
| 131 | nb_err1 = nb_err2 = 0; |
| 132 | nb_tot1 = nb_tot2 = 0; |
| 133 | |
| 134 | memset( line, 0, sizeof( line ) ); |
| 135 | |
| 136 | n = sizeof( line ); |
| 137 | |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 138 | while( fgets( line, (int) n - 1, f ) != NULL ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 139 | { |
| 140 | n = strlen( line ); |
| 141 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 142 | if( n < (size_t) 2 * mbedtls_md_get_size( md_info ) + 4 ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 143 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 144 | mbedtls_printf("No '%s' hash found on line.\n", mbedtls_md_get_name( md_info )); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 145 | continue; |
| 146 | } |
| 147 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 148 | if( line[2 * mbedtls_md_get_size( md_info )] != ' ' || line[2 * mbedtls_md_get_size( md_info ) + 1] != ' ' ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 149 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 150 | mbedtls_printf("No '%s' hash found on line.\n", mbedtls_md_get_name( md_info )); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 151 | continue; |
| 152 | } |
| 153 | |
| 154 | if( line[n - 1] == '\n' ) { n--; line[n] = '\0'; } |
| 155 | if( line[n - 1] == '\r' ) { n--; line[n] = '\0'; } |
| 156 | |
| 157 | nb_tot1++; |
| 158 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 159 | if( generic_wrapper( md_info, line + 2 + 2 * mbedtls_md_get_size( md_info ), sum ) != 0 ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 160 | { |
| 161 | nb_err1++; |
| 162 | continue; |
| 163 | } |
| 164 | |
| 165 | nb_tot2++; |
| 166 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 167 | for( i = 0; i < mbedtls_md_get_size( md_info ); i++ ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 168 | sprintf( buf + i * 2, "%02x", sum[i] ); |
| 169 | |
Manuel Pégourié-Gonnard | 291f9af | 2013-10-28 12:51:32 +0100 | [diff] [blame] | 170 | /* Use constant-time buffer comparison */ |
| 171 | diff = 0; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 172 | for( i = 0; i < 2 * mbedtls_md_get_size( md_info ); i++ ) |
Manuel Pégourié-Gonnard | 291f9af | 2013-10-28 12:51:32 +0100 | [diff] [blame] | 173 | diff |= line[i] ^ buf[i]; |
| 174 | |
| 175 | if( diff != 0 ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 176 | { |
| 177 | nb_err2++; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 178 | mbedtls_fprintf( stderr, "wrong checksum: %s\n", line + 66 ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | n = sizeof( line ); |
| 182 | } |
| 183 | |
| 184 | if( nb_err1 != 0 ) |
| 185 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 186 | mbedtls_printf( "WARNING: %d (out of %d) input files could " |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 187 | "not be read\n", nb_err1, nb_tot1 ); |
| 188 | } |
| 189 | |
| 190 | if( nb_err2 != 0 ) |
| 191 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 192 | mbedtls_printf( "WARNING: %d (out of %d) computed checksums did " |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 193 | "not match\n", nb_err2, nb_tot2 ); |
| 194 | } |
| 195 | |
Paul Bakker | 64abd83 | 2014-02-06 15:03:06 +0100 | [diff] [blame] | 196 | fclose( f ); |
| 197 | |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 198 | return( nb_err1 != 0 || nb_err2 != 0 ); |
| 199 | } |
| 200 | |
| 201 | int main( int argc, char *argv[] ) |
| 202 | { |
Andres Amaya Garcia | dabd78f | 2018-04-29 22:35:36 +0100 | [diff] [blame] | 203 | int ret = 1, i; |
| 204 | int exit_code = MBEDTLS_EXIT_FAILURE; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 205 | const mbedtls_md_info_t *md_info; |
| 206 | mbedtls_md_context_t md_ctx; |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 207 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 208 | mbedtls_md_init( &md_ctx ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 209 | |
| 210 | if( argc == 1 ) |
| 211 | { |
| 212 | const int *list; |
| 213 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 214 | mbedtls_printf( "print mode: generic_sum <mbedtls_md> <file> <file> ...\n" ); |
| 215 | mbedtls_printf( "check mode: generic_sum <mbedtls_md> -c <checksum file>\n" ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 216 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 217 | mbedtls_printf( "\nAvailable message digests:\n" ); |
| 218 | list = mbedtls_md_list(); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 219 | while( *list ) |
| 220 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 221 | md_info = mbedtls_md_info_from_type( *list ); |
| 222 | mbedtls_printf( " %s\n", mbedtls_md_get_name( md_info ) ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 223 | list++; |
| 224 | } |
| 225 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 226 | #if defined(_WIN32) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 227 | mbedtls_printf( "\n Press Enter to exit this program.\n" ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 228 | fflush( stdout ); getchar(); |
| 229 | #endif |
| 230 | |
Krzysztof Stachowiak | 3b0c430 | 2019-04-24 14:24:46 +0200 | [diff] [blame] | 231 | mbedtls_exit( exit_code ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /* |
| 235 | * Read the MD from the command line |
| 236 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 237 | md_info = mbedtls_md_info_from_string( argv[1] ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 238 | if( md_info == NULL ) |
| 239 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 240 | mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] ); |
Krzysztof Stachowiak | 3b0c430 | 2019-04-24 14:24:46 +0200 | [diff] [blame] | 241 | mbedtls_exit( exit_code ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 242 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 243 | if( mbedtls_md_setup( &md_ctx, md_info, 0 ) ) |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 244 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 245 | mbedtls_fprintf( stderr, "Failed to initialize context.\n" ); |
Krzysztof Stachowiak | 3b0c430 | 2019-04-24 14:24:46 +0200 | [diff] [blame] | 246 | mbedtls_exit( exit_code ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 247 | } |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 248 | |
| 249 | ret = 0; |
| 250 | if( argc == 4 && strcmp( "-c", argv[2] ) == 0 ) |
| 251 | { |
| 252 | ret |= generic_check( md_info, argv[3] ); |
| 253 | goto exit; |
| 254 | } |
| 255 | |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 256 | for( i = 2; i < argc; i++ ) |
| 257 | ret |= generic_print( md_info, argv[i] ); |
| 258 | |
Andres Amaya Garcia | dabd78f | 2018-04-29 22:35:36 +0100 | [diff] [blame] | 259 | if ( ret == 0 ) |
| 260 | exit_code = MBEDTLS_EXIT_SUCCESS; |
| 261 | |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 262 | exit: |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 263 | mbedtls_md_free( &md_ctx ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 264 | |
Krzysztof Stachowiak | 3b0c430 | 2019-04-24 14:24:46 +0200 | [diff] [blame] | 265 | mbedtls_exit( exit_code ); |
Paul Bakker | fb6c7e2 | 2011-01-21 10:21:11 +0000 | [diff] [blame] | 266 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 267 | #endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */ |