Skip to content

Commit 3283cf3

Browse files
Add init/cleanup and cast arg input
1 parent 82e1108 commit 3283cf3

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

cmake/myApp.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <wolfssl/wolfcrypt/settings.h> /* using user_settings.h for example */
2323
#include <wolfssl/wolfcrypt/sha256.h>
24+
#include <wolfssl/wolfcrypt/wc_port.h>
2425
#include <stdio.h>
2526

2627

@@ -35,14 +36,21 @@ int main(int argc, char** argv)
3536
return -1;
3637
}
3738

38-
ret = wc_InitSha256(&sha);
39-
if (ret == 0)
40-
ret = wc_Sha256Update(&sha, argv[1], (word32)XSTRLEN(argv[1]));
41-
if (ret == 0)
39+
ret = wolfCrypt_Init();
40+
if (ret == 0) {
41+
ret = wc_InitSha256(&sha);
42+
}
43+
if (ret == 0) {
44+
ret = wc_Sha256Update(&sha, (const byte*)argv[1],
45+
(word32)XSTRLEN(argv[1]));
46+
}
47+
if (ret == 0) {
4248
ret = wc_Sha256Final(&sha, digest);
49+
}
4350

44-
if (ret != 0)
51+
if (ret != 0) {
4552
printf("Error %d\n", ret);
53+
}
4654

4755
if (ret == 0) {
4856
printf("Hash in hex : ");
@@ -52,5 +60,6 @@ int main(int argc, char** argv)
5260
printf("\n");
5361
}
5462

63+
wolfCrypt_Cleanup();
5564
return 0;
5665
}

0 commit comments

Comments
 (0)