2 #define TEST_NAME "hash"
5 static unsigned char x
[] = "testing\n";
6 static unsigned char x2
[] = "The Conscience of a Hacker is a small essay written January 8, 1986 by a computer security hacker who went by the handle of The Mentor, who belonged to the 2nd generation of Legion of Doom.";
7 static unsigned char h
[crypto_hash_BYTES
];
13 crypto_hash(h
, x
, sizeof x
- 1U);
14 for (i
= 0; i
< crypto_hash_BYTES
; ++i
) {
15 printf("%02x", (unsigned int)h
[i
]);
18 crypto_hash(h
, x2
, sizeof x2
- 1U);
19 for (i
= 0; i
< crypto_hash_BYTES
; ++i
) {
20 printf("%02x", (unsigned int)h
[i
]);
23 crypto_hash_sha256(h
, x
, sizeof x
- 1U);
24 for (i
= 0; i
< crypto_hash_sha256_BYTES
; ++i
) {
25 printf("%02x", (unsigned int)h
[i
]);
28 crypto_hash_sha256(h
, x2
, sizeof x2
- 1U);
29 for (i
= 0; i
< crypto_hash_sha256_BYTES
; ++i
) {
30 printf("%02x", (unsigned int)h
[i
]);
34 assert(crypto_hash_bytes() > 0U);
35 assert(strcmp(crypto_hash_primitive(), "sha512") == 0);
36 assert(crypto_hash_sha256_bytes() > 0U);
37 assert(crypto_hash_sha512_bytes() >= crypto_hash_sha256_bytes());
38 assert(crypto_hash_sha512_bytes() == crypto_hash_bytes());
39 assert(crypto_hash_sha256_statebytes() == sizeof(crypto_hash_sha256_state
));
40 assert(crypto_hash_sha512_statebytes() == sizeof(crypto_hash_sha512_state
));