xref: /openbmc/linux/tools/build/feature/test-libcrypto.c (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2*5b245985SRoberto Sassu #include <openssl/evp.h>
38ee46460SStephane Eranian #include <openssl/sha.h>
48ee46460SStephane Eranian #include <openssl/md5.h>
58ee46460SStephane Eranian 
main(void)68ee46460SStephane Eranian int main(void)
78ee46460SStephane Eranian {
8*5b245985SRoberto Sassu 	EVP_MD_CTX *mdctx;
98ee46460SStephane Eranian 	unsigned char md[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
108ee46460SStephane Eranian 	unsigned char dat[] = "12345";
11*5b245985SRoberto Sassu 	unsigned int digest_len;
128ee46460SStephane Eranian 
13*5b245985SRoberto Sassu 	mdctx = EVP_MD_CTX_new();
14*5b245985SRoberto Sassu 	if (!mdctx)
15*5b245985SRoberto Sassu 		return 0;
16*5b245985SRoberto Sassu 
17*5b245985SRoberto Sassu 	EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
18*5b245985SRoberto Sassu 	EVP_DigestUpdate(mdctx, &dat[0], sizeof(dat));
19*5b245985SRoberto Sassu 	EVP_DigestFinal_ex(mdctx, &md[0], &digest_len);
20*5b245985SRoberto Sassu 	EVP_MD_CTX_free(mdctx);
218ee46460SStephane Eranian 
228ee46460SStephane Eranian 	SHA1(&dat[0], sizeof(dat), &md[0]);
238ee46460SStephane Eranian 
248ee46460SStephane Eranian 	return 0;
258ee46460SStephane Eranian }
26