blob: 384ade1c4d51b997e9d81502f14be1eaa3604207 [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é-Gonnard860b5162015-01-28 17:12:07 +00006 * This file is part of mbed TLS (https://polarssl.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é-Gonnardabd6e022013-09-20 13:30:43 +020024#include "polarssl/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)
30#include "polarssl/platform.h"
31#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)
Paul Bakker40e46942009-01-03 21:51:57 +000037#include "polarssl/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)
Paul Bakkercce9d772011-11-18 14:26:47 +000041int main( int argc, char *argv[] )
Paul Bakker5690efc2011-05-26 13:16:06 +000042{
Paul Bakkercce9d772011-11-18 14:26:47 +000043 ((void) argc);
44 ((void) argv);
45
Rich Evansf90016a2015-01-19 14:26:37 +000046 polarssl_printf("POLARSSL_MD5_C not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +000047 return( 0 );
48}
49#else
Paul Bakkercce9d772011-11-18 14:26:47 +000050int main( int argc, char *argv[] )
Paul Bakker5121ce52009-01-03 21:22:43 +000051{
52 int i;
53 unsigned char digest[16];
54 char str[] = "Hello, world!";
55
Paul Bakkercce9d772011-11-18 14:26:47 +000056 ((void) argc);
57 ((void) argv);
58
Rich Evansf90016a2015-01-19 14:26:37 +000059 polarssl_printf( "\n MD5('%s') = ", str );
Paul Bakker5121ce52009-01-03 21:22:43 +000060
61 md5( (unsigned char *) str, 13, digest );
62
63 for( i = 0; i < 16; i++ )
Rich Evansf90016a2015-01-19 14:26:37 +000064 polarssl_printf( "%02x", digest[i] );
Paul Bakker5121ce52009-01-03 21:22:43 +000065
Rich Evansf90016a2015-01-19 14:26:37 +000066 polarssl_printf( "\n\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000067
Paul Bakkercce9d772011-11-18 14:26:47 +000068#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +000069 polarssl_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000070 fflush( stdout ); getchar();
71#endif
72
73 return( 0 );
74}
Paul Bakker5690efc2011-05-26 13:16:06 +000075#endif /* POLARSSL_MD5_C */