blob: a567233c94539f17bb5044044ae66652b3b28d8a [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * Classic "Hello, world" demonstration program
3 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00004 * Copyright (C) 2006-2011, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00005 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00006 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
Paul Bakker5121ce52009-01-03 21:22:43 +00008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000024#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020025#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020027#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000028
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030#include "mbedtls/platform.h"
Rich Evansf90016a2015-01-19 14:26:37 +000031#else
Rich Evans18b78c72015-02-11 14:06:19 +000032#include <stdio.h>
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#define mbedtls_printf printf
Rich Evansf90016a2015-01-19 14:26:37 +000034#endif
35
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if defined(MBEDTLS_MD5_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000037#include "mbedtls/md5.h"
Rich Evans18b78c72015-02-11 14:06:19 +000038#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000039
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020040#if !defined(MBEDTLS_MD5_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000041int main( void )
Paul Bakker5690efc2011-05-26 13:16:06 +000042{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043 mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +000044 return( 0 );
45}
46#else
Rich Evans85b05ec2015-02-12 11:37:29 +000047int main( void )
Paul Bakker5121ce52009-01-03 21:22:43 +000048{
49 int i;
50 unsigned char digest[16];
51 char str[] = "Hello, world!";
52
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020053 mbedtls_printf( "\n MD5('%s') = ", str );
Paul Bakker5121ce52009-01-03 21:22:43 +000054
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020055 mbedtls_md5( (unsigned char *) str, 13, digest );
Paul Bakker5121ce52009-01-03 21:22:43 +000056
57 for( i = 0; i < 16; i++ )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058 mbedtls_printf( "%02x", digest[i] );
Paul Bakker5121ce52009-01-03 21:22:43 +000059
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060 mbedtls_printf( "\n\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000061
Paul Bakkercce9d772011-11-18 14:26:47 +000062#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063 mbedtls_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000064 fflush( stdout ); getchar();
65#endif
66
67 return( 0 );
68}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020069#endif /* MBEDTLS_MD5_C */