File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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}
You can’t perform that action at this time.
0 commit comments