blob: be81d567825a18056706f466bdcb7dc6647daded [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é-Gonnardcef4ad22014-04-29 12:39:06 +020023#if !defined(POLARSSL_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
26#include POLARSSL_CONFIG_FILE
27#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000028
Rich Evansf90016a2015-01-19 14:26:37 +000029#if defined(POLARSSL_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>
Rich Evansf90016a2015-01-19 14:26:37 +000033#define polarssl_printf printf
Rich Evansf90016a2015-01-19 14:26:37 +000034#endif
35
Rich Evans18b78c72015-02-11 14:06:19 +000036#if defined(POLARSSL_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
Paul Bakker5690efc2011-05-26 13:16:06 +000040#if !defined(POLARSSL_MD5_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000041int main( void )
Paul Bakker5690efc2011-05-26 13:16:06 +000042{
Rich Evansf90016a2015-01-19 14:26:37 +000043 polarssl_printf("POLARSSL_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
Rich Evansf90016a2015-01-19 14:26:37 +000053 polarssl_printf( "\n MD5('%s') = ", str );
Paul Bakker5121ce52009-01-03 21:22:43 +000054
55 md5( (unsigned char *) str, 13, digest );
56
57 for( i = 0; i < 16; i++ )
Rich Evansf90016a2015-01-19 14:26:37 +000058 polarssl_printf( "%02x", digest[i] );
Paul Bakker5121ce52009-01-03 21:22:43 +000059
Rich Evansf90016a2015-01-19 14:26:37 +000060 polarssl_printf( "\n\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000061
Paul Bakkercce9d772011-11-18 14:26:47 +000062#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +000063 polarssl_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}
Paul Bakker5690efc2011-05-26 13:16:06 +000069#endif /* POLARSSL_MD5_C */