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
|
2023-11-02 20:47:20 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
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)
|
2023-01-11 14:50:10 +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");
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_exit(0);
|
2011-05-26 15:16:06 +02:00
|
|
|
}
|
|
|
|
#else
|
2018-12-10 14:31:45 +01:00
|
|
|
|
|
|
|
|
2023-01-11 14:50:10 +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!";
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_printf("\n MD5('%s') = ", str);
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if ((ret = mbedtls_md5((unsigned char *) str, 13, digest)) != 0) {
|
|
|
|
mbedtls_exit(MBEDTLS_EXIT_FAILURE);
|
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
mbedtls_printf("%02x", digest[i]);
|
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_printf("\n\n");
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2023-01-11 14:50:10 +01: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 */
|