blob: 083dc9d95fcd2b5f23c38c1e3f6532e8cc066389 [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é-Gonnard085ab042015-01-23 11:06:27 +00006 * This file is part of mbed TLS (https://www.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
32#define polarssl_printf printf
33#define polarssl_fprintf fprintf
34#define polarssl_malloc malloc
35#define polarssl_free free
36#endif
37
Paul Bakker5121ce52009-01-03 21:22:43 +000038#include <stdio.h>
39
Paul Bakker40e46942009-01-03 21:51:57 +000040#include "polarssl/md5.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000041
Paul Bakker5690efc2011-05-26 13:16:06 +000042#if !defined(POLARSSL_MD5_C)
Paul Bakkercce9d772011-11-18 14:26:47 +000043int main( int argc, char *argv[] )
Paul Bakker5690efc2011-05-26 13:16:06 +000044{
Paul Bakkercce9d772011-11-18 14:26:47 +000045 ((void) argc);
46 ((void) argv);
47
Rich Evansf90016a2015-01-19 14:26:37 +000048 polarssl_printf("POLARSSL_MD5_C not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +000049 return( 0 );
50}
51#else
Paul Bakkercce9d772011-11-18 14:26:47 +000052int main( int argc, char *argv[] )
Paul Bakker5121ce52009-01-03 21:22:43 +000053{
54 int i;
55 unsigned char digest[16];
56 char str[] = "Hello, world!";
57
Paul Bakkercce9d772011-11-18 14:26:47 +000058 ((void) argc);
59 ((void) argv);
60
Rich Evansf90016a2015-01-19 14:26:37 +000061 polarssl_printf( "\n MD5('%s') = ", str );
Paul Bakker5121ce52009-01-03 21:22:43 +000062
63 md5( (unsigned char *) str, 13, digest );
64
65 for( i = 0; i < 16; i++ )
Rich Evansf90016a2015-01-19 14:26:37 +000066 polarssl_printf( "%02x", digest[i] );
Paul Bakker5121ce52009-01-03 21:22:43 +000067
Rich Evansf90016a2015-01-19 14:26:37 +000068 polarssl_printf( "\n\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000069
Paul Bakkercce9d772011-11-18 14:26:47 +000070#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +000071 polarssl_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +000072 fflush( stdout ); getchar();
73#endif
74
75 return( 0 );
76}
Paul Bakker5690efc2011-05-26 13:16:06 +000077#endif /* POLARSSL_MD5_C */