]>
Commit | Line | Data |
---|---|---|
ec89d437 MW |
1 | /** |
2 | * @file prf_plus_test.h | |
3 | * | |
ed37dee6 | 4 | * @brief Tests for the prf_plus_t class. |
ec89d437 MW |
5 | * |
6 | */ | |
7 | ||
8 | /* | |
9 | * Copyright (C) 2005 Jan Hutter, Martin Willi | |
10 | * Hochschule fuer Technik Rapperswil | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by the | |
14 | * Free Software Foundation; either version 2 of the License, or (at your | |
15 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
19 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | */ | |
22 | ||
23 | #include <string.h> | |
24 | ||
25 | #include "prf_plus_test.h" | |
26 | ||
68621281 | 27 | #include <crypto/prf_plus.h> |
ec89d437 MW |
28 | |
29 | ||
30 | /* | |
31 | * described in Header-File | |
32 | */ | |
51d56047 | 33 | void test_prf_plus(protected_tester_t *tester) |
ec89d437 MW |
34 | { |
35 | prf_plus_t *prf_plus; | |
36 | prf_t *prf; | |
37 | chunk_t key, seed; | |
38 | u_int8_t buffer[10000]; | |
39 | int i; | |
40 | ||
41 | u_int8_t key_bytes[] = { | |
42 | 0x01,0x02,0x03,0x04 | |
43 | }; | |
44 | u_int8_t seed_bytes[] = { | |
45 | 0x01,0x02,0x03,0x04 | |
46 | }; | |
47 | ||
48 | ||
49 | ||
50 | key.ptr = key_bytes; | |
51 | key.len = sizeof(key_bytes); | |
52 | seed.ptr = seed_bytes; | |
53 | seed.len = sizeof(seed_bytes); | |
54 | ||
55 | prf = prf_create(PRF_HMAC_SHA1); | |
56 | prf->set_key(prf, key); | |
57 | ||
58 | prf_plus = prf_plus_create(prf, seed); | |
59 | ||
60 | ||
61 | for (i=0; i<100; i++) | |
62 | { | |
63 | prf_plus->get_bytes(prf_plus, i*i, buffer); | |
64 | ||
65 | } | |
66 | ||
67 | //tester->assert_true(tester, digest[3].len == 20, "chunk len append mode"); | |
68 | //tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 20), "prf_plus value append mode"); | |
69 | ||
70 | prf_plus->destroy(prf_plus); | |
71 | prf->destroy(prf); | |
72 | } | |
73 | ||
51d56047 | 74 | void test_prf_plus_md5(protected_tester_t *tester) |
ec89d437 | 75 | { |
2018a40a | 76 | /* md5 test data |
ec89d437 MW |
77 | u_int8_t nonce[] = { |
78 | 0x58,0xCC,0x4C,0xA3,0x81,0x81,0xDA,0x7D, | |
79 | 0x19,0xA6,0x9F,0xB1,0xE8,0xD3,0xE7,0x96, | |
80 | 0xC2,0x2A,0x6E,0xCB,0x09,0x43,0xDC,0x6E, | |
81 | 0x75,0x22,0x34,0xAE,0xF8,0x53,0x7F,0xEC, | |
82 | 0x00,0xC9,0xF6,0x1C,0x4A,0x39,0xB4,0x29, | |
83 | 0x23,0xD8,0x24,0x22,0x95,0x52,0x77,0x29 | |
84 | }; | |
85 | ||
86 | u_int8_t shared_key[] = { | |
87 | 0xC0,0xDB,0x75,0x0A,0x40,0xBE,0xE2,0x8C,0x68,0x3C,0xB4,0xAA,0xE7,0xA7,0x6E,0xCC, | |
88 | 0x2A,0x4B,0x9C,0x8E,0xC6,0x71,0xAD,0xF4,0xB7,0xC4,0xD6,0x53,0x41,0xB3,0x4A,0xE4, | |
89 | 0x0D,0xC2,0x0C,0x60,0x9F,0x93,0x9E,0x87,0x30,0xCC,0xDC,0x51,0x9F,0x94,0x91,0x5D, | |
90 | 0x31,0xE0,0x6E,0x22,0x3A,0x66,0x53,0xA6,0xD4,0x54,0x5E,0x71,0x61,0xA6,0x64,0x3B, | |
91 | 0x19,0x40,0x6E,0x6F,0x3B,0xE3,0x64,0x3F,0x3B,0x68,0xEB,0x8E,0x4B,0x2A,0x53,0xEC, | |
92 | 0xB0,0xB6,0x8E,0x5C,0x42,0xA1,0xC2,0x7F,0x4F,0x0B,0x7D,0xFC,0xF6,0x7E,0xF5,0xC0, | |
93 | 0xBA,0xA8,0xFB,0x13,0xEF,0xA8,0xBD,0x90,0x95,0x08,0x2C,0x81,0xA9,0xDA,0x7D,0x45, | |
94 | 0xDC,0x35,0x33,0x75,0xA8,0x4D,0xE2,0x34,0xA9,0x66,0x7F,0xAD,0x04,0x3A,0xE5,0x21 | |
95 | }; | |
96 | ||
97 | u_int8_t skeyseed[] = { | |
98 | 0xCD,0xC6,0xC0,0x68, | |
99 | 0x60,0xDF,0x0C,0xC2, | |
100 | 0x10,0xDB,0x0E,0xF7, | |
101 | 0x20,0x6E,0x6C,0xB1 | |
102 | }; | |
103 | u_int8_t sk_d[] = { | |
104 | 0xE1,0x74,0xA8,0x50, | |
105 | 0x14,0xDB,0x79,0x64, | |
106 | 0x92,0x3E,0x82,0x28, | |
107 | 0x48,0x75,0x64,0xE7 | |
108 | }; | |
109 | u_int8_t sk_ai[] = { | |
110 | 0xCA,0x19,0x73,0x69, | |
111 | 0x38,0x35,0x40,0xA6, | |
112 | 0xB1,0x98,0x4F,0x63, | |
113 | 0xE6,0xF9,0x66,0xFF | |
114 | }; | |
115 | u_int8_t sk_ar[] = { | |
116 | 0x14,0x1D,0x0A,0xC2, | |
117 | 0x7B,0x1C,0x87,0xD2, | |
118 | 0x65,0xA5,0xEF,0x0C, | |
119 | 0x47,0xF4,0xCE,0xE2 | |
120 | }; | |
121 | u_int8_t sk_ei[] = { | |
122 | 0x52,0x50,0x7E,0xDA, | |
123 | 0x02,0x1D,0x8E,0xCF, | |
124 | 0x20,0xA3,0x67,0xA6, | |
125 | 0x4D,0xA0,0xAB,0x61 | |
126 | }; | |
127 | u_int8_t sk_er[] = { | |
128 | 0xB9,0x65,0x0A,0x3C, | |
129 | 0x30,0xA8,0x26,0x78, | |
130 | 0x60,0x5A,0x74,0xBB, | |
131 | 0x5C,0xC4,0xF8,0x71 | |
132 | }; | |
133 | u_int8_t sk_pi[] = { | |
134 | 0xDD,0x61,0xAB,0x53, | |
135 | 0xC8,0xDD,0x3A,0x44, | |
136 | 0xDA,0x47,0x09,0x9B, | |
137 | 0x3B,0xD2,0xBB,0xB6 | |
138 | }; | |
139 | u_int8_t sk_pr[] = { | |
140 | 0x18,0x75,0xE4,0xC6, | |
141 | 0x57,0xC4,0xDE,0x65, | |
142 | 0x10,0xEB,0xA7,0xB6, | |
143 | 0x24,0x0D,0xEC,0xB4 | |
2018a40a | 144 | };*/ |
ec89d437 | 145 | } |