xref: /openbmc/linux/tools/build/feature/test-libcrypto.c (revision 0af5cb349a2c97fbabb3cede96efcde9d54b7940)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <openssl/sha.h>
3 #include <openssl/md5.h>
4 
5 /*
6  * The MD5_* API have been deprecated since OpenSSL 3.0, which causes the
7  * feature test to fail silently. This is a workaround.
8  */
9 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
10 
11 int main(void)
12 {
13 	MD5_CTX context;
14 	unsigned char md[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
15 	unsigned char dat[] = "12345";
16 
17 	MD5_Init(&context);
18 	MD5_Update(&context, &dat[0], sizeof(dat));
19 	MD5_Final(&md[0], &context);
20 
21 	SHA1(&dat[0], sizeof(dat), &md[0]);
22 
23 	return 0;
24 }
25