1
/* test the multi helpers... */
6
unsigned char key[16], buf[2][MAXBLOCKSIZE];
7
unsigned long len, len2;
11
register_hash(&sha256_desc);
12
register_cipher(&aes_desc);
16
hash_memory(find_hash("sha256"), "hello", 5, buf[0], &len);
17
len2 = sizeof(buf[0]);
18
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "hello", 5, NULL);
19
if (len != len2 || memcmp(buf[0], buf[1], len)) {
20
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
23
len2 = sizeof(buf[0]);
24
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "he", 2, "llo", 3, NULL);
25
if (len != len2 || memcmp(buf[0], buf[1], len)) {
26
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
29
len2 = sizeof(buf[0]);
30
hash_memory_multi(find_hash("sha256"), buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
31
if (len != len2 || memcmp(buf[0], buf[1], len)) {
32
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
38
hmac_memory(find_hash("sha256"), key, 16, "hello", 5, buf[0], &len);
39
len2 = sizeof(buf[0]);
40
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "hello", 5, NULL);
41
if (len != len2 || memcmp(buf[0], buf[1], len)) {
42
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
45
len2 = sizeof(buf[0]);
46
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
47
if (len != len2 || memcmp(buf[0], buf[1], len)) {
48
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
51
len2 = sizeof(buf[0]);
52
hmac_memory_multi(find_hash("sha256"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
53
if (len != len2 || memcmp(buf[0], buf[1], len)) {
54
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
60
omac_memory(find_cipher("aes"), key, 16, "hello", 5, buf[0], &len);
61
len2 = sizeof(buf[0]);
62
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "hello", 5, NULL);
63
if (len != len2 || memcmp(buf[0], buf[1], len)) {
64
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
67
len2 = sizeof(buf[0]);
68
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
69
if (len != len2 || memcmp(buf[0], buf[1], len)) {
70
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
73
len2 = sizeof(buf[0]);
74
omac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
75
if (len != len2 || memcmp(buf[0], buf[1], len)) {
76
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
82
pmac_memory(find_cipher("aes"), key, 16, "hello", 5, buf[0], &len);
83
len2 = sizeof(buf[0]);
84
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "hello", 5, NULL);
85
if (len != len2 || memcmp(buf[0], buf[1], len)) {
86
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
89
len2 = sizeof(buf[0]);
90
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "he", 2, "llo", 3, NULL);
91
if (len != len2 || memcmp(buf[0], buf[1], len)) {
92
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
95
len2 = sizeof(buf[0]);
96
pmac_memory_multi(find_cipher("aes"), key, 16, buf[1], &len2, "h", 1, "e", 1, "l", 1, "l", 1, "o", 1, NULL);
97
if (len != len2 || memcmp(buf[0], buf[1], len)) {
98
printf("Failed: %d %lu %lu\n", __LINE__, len, len2);
103
printf("All passed\n");
108
/* $Source: /cvs/libtom/libtomcrypt/demos/multi.c,v $ */
109
/* $Revision: 1.2 $ */
110
/* $Date: 2005/05/05 14:35:56 $ */