2009-01-03 22:22:43 +01:00
|
|
|
/*
|
|
|
|
* Classic "Hello, world" demonstration program
|
|
|
|
*
|
2020-08-07 13:07:28 +02:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2015-09-04 14:21:07 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
|
|
|
|
2021-05-27 11:25:03 +02:00
|
|
|
#include "mbedtls/build_info.h"
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/platform.h"
|
2015-01-19 15:26:37 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_MD5_C)
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/md5.h"
|
2015-02-11 15:06:19 +01:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_MD5_C)
|
2015-02-12 12:37:29 +01:00
|
|
|
int main( void )
|
2011-05-26 15:16:06 +02:00
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
|
2019-04-24 14:24:46 +02:00
|
|
|
mbedtls_exit( 0 );
|
2011-05-26 15:16:06 +02:00
|
|
|
}
|
|
|
|
#else
|
2018-12-10 14:31:45 +01:00
|
|
|
|
|
|
|
|
2015-02-12 12:37:29 +01:00
|
|
|
int main( void )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2017-06-28 14:26:36 +02:00
|
|
|
int i, ret;
|
2009-01-03 22:22:43 +01:00
|
|
|
unsigned char digest[16];
|
|
|
|
char str[] = "Hello, world!";
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_printf( "\n MD5('%s') = ", str );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2021-06-08 16:45:41 +02:00
|
|
|
if( ( ret = mbedtls_md5( (unsigned char *) str, 13, digest ) ) != 0 )
|
2019-04-24 14:24:46 +02:00
|
|
|
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
for( i = 0; i < 16; i++ )
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_printf( "%02x", digest[i] );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_printf( "\n\n" );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2019-04-24 14:24:46 +02:00
|
|
|
mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_MD5_C */
|