Branch data Line data Source code
1 : : #include "sute.h"
2 : : #include "sha512.h"
3 : :
4 : : /**
5 : : *
6 : : * libsha512 hash check with the sha512 built-in library
7 : : *
8 : : */
9 : 1 : Return test0001(void)
10 : : {
11 : 1 : INITTEST;
12 : :
13 : : unsigned char hash[SHA512_DIGEST_LENGTH];
14 : :
15 : 1 : const unsigned char array[] = "Hello World";
16 : :
17 : 1 : const unsigned char result[] = {
18 : : 0x2c,0x74,0xfd,0x17,0xed,0xaf,0xd8,0x0e,
19 : : 0x84,0x47,0xb0,0xd4,0x67,0x41,0xee,0x24,
20 : : 0x3b,0x7e,0xb7,0x4d,0xd2,0x14,0x9a,0x0a,
21 : : 0xb1,0xb9,0x24,0x6f,0xb3,0x03,0x82,0xf2,
22 : : 0x7e,0x85,0x3d,0x85,0x85,0x71,0x9e,0x0e,
23 : : 0x67,0xcb,0xda,0x0d,0xaa,0x8f,0x51,0x67,
24 : : 0x10,0x64,0x61,0x5d,0x64,0x5a,0xe2,0x7a,
25 : : 0xcb,0x15,0xbf,0xb1,0x44,0x7f,0x45,0x9b
26 : : };
27 : :
28 : : SHA512_Context ctx;
29 : 1 : sha512_init(&ctx);
30 : 1 : sha512_update(&ctx,array,sizeof(array) - 1);
31 : 1 : sha512_final(&ctx,hash);
32 : :
33 [ + - + - ]: 1 : ASSERT(0 == memcmp(hash,result,(size_t)SHA512_DIGEST_LENGTH));
34 : :
35 [ + - - + : 1 : RETURN_STATUS;
- - - + +
- ]
36 : : }
|