OLD | NEW |
1 /* | 1 /* |
2 * auth_driver.c | 2 * auth_driver.c |
3 * | 3 * |
4 * a driver for auth functions | 4 * a driver for auth functions |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 | 9 |
10 /* | 10 /* |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 #include <stdio.h> /* for printf() */ | 47 #include <stdio.h> /* for printf() */ |
48 #include <stdlib.h> /* for xalloc() */ | 48 #include <stdlib.h> /* for xalloc() */ |
49 #include <unistd.h> /* for getopt() */ | 49 #include <unistd.h> /* for getopt() */ |
50 | 50 |
51 #include "auth.h" | 51 #include "auth.h" |
52 #include "null_auth.h" | 52 #include "null_auth.h" |
53 | 53 |
54 #define PRINT_DEBUG_DATA 0 | 54 #define PRINT_DEBUG_DATA 0 |
55 | 55 |
56 extern auth_type_t tmmhv2; | 56 extern srtp_auth_type_t tmmhv2; |
57 | 57 |
58 const uint16_t msg0[9] = { | 58 const uint16_t msg0[9] = { |
59 0x6015, 0xf141, 0x5ba1, 0x29a0, 0xf604, 0xd1c, 0x2d9, 0xaa8a, 0x7931 | 59 0x6015, 0xf141, 0x5ba1, 0x29a0, 0xf604, 0xd1c, 0x2d9, 0xaa8a, 0x7931 |
60 }; | 60 }; |
61 | 61 |
62 /* key1 is for TAG_WORDS = 2 */ | 62 /* key1 is for TAG_WORDS = 2 */ |
63 | 63 |
64 const uint16_t key1[47] = { | 64 const uint16_t key1[47] = { |
65 0xe627, 0x6a01, 0x5ea7, 0xf27a, 0xc536, 0x2192, 0x11be, 0xea35, | 65 0xe627, 0x6a01, 0x5ea7, 0xf27a, 0xc536, 0x2192, 0x11be, 0xea35, |
66 0xdb9d, 0x63d6, 0xfa8a, 0xfc45, 0xe08b, 0xd216, 0xced2, 0x7853, | 66 0xdb9d, 0x63d6, 0xfa8a, 0xfc45, 0xe08b, 0xd216, 0xced2, 0x7853, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 } | 157 } |
158 | 158 |
159 return 0; | 159 return 0; |
160 } | 160 } |
161 | 161 |
162 #define NUM_TRIALS 100000 | 162 #define NUM_TRIALS 100000 |
163 | 163 |
164 #include <time.h> | 164 #include <time.h> |
165 | 165 |
166 double | 166 double auth_bits_per_second(auth_t *a, int msg_len_octets) { |
167 auth_bits_per_second(auth_t *a, int msg_len_octets) { | |
168 int i; | 167 int i; |
169 clock_t timer; | 168 clock_t timer; |
170 uint8_t *result; | 169 uint8_t *result; |
171 int msg_len = (msg_len_octets + 1)/2; | 170 int msg_len = (msg_len_octets + 1)/2; |
172 uint16_t *msg_string; | 171 uint16_t *msg_string; |
173 | 172 |
174 /* create random message */ | 173 /* create random message */ |
175 msg_string = (uint16_t *) crypto_alloc(msg_len_octets); | 174 msg_string = (uint16_t *) srtp_crypto_alloc(msg_len_octets); |
176 if (msg_string == NULL) | 175 if (msg_string == NULL) |
177 return 0.0; /* indicate failure */ | 176 return 0.0; /* indicate failure */ |
178 for (i=0; i < msg_len; i++) | 177 for (i=0; i < msg_len; i++) |
179 msg_string[i] = (uint16_t) random(); | 178 msg_string[i] = (uint16_t) random(); |
180 | 179 |
181 /* allocate temporary storage for authentication tag */ | 180 /* allocate temporary storage for authentication tag */ |
182 result = crypto_alloc(auth_get_tag_length(a)); | 181 result = srtp_crypto_alloc(auth_get_tag_length(a)); |
183 if (result == NULL) { | 182 if (result == NULL) { |
184 free(msg_string); | 183 srtp_crypto_free(msg_string); |
185 return 0.0; /* indicate failure */ | 184 return 0.0; /* indicate failure */ |
186 } | 185 } |
187 | 186 |
188 timer = clock(); | 187 timer = clock(); |
189 for (i=0; i < NUM_TRIALS; i++) { | 188 for (i=0; i < NUM_TRIALS; i++) { |
190 auth_compute(a, (uint8_t *)msg_string, msg_len_octets, (uint8_t *)result); | 189 auth_compute(a, (uint8_t *)msg_string, msg_len_octets, (uint8_t *)result); |
191 } | 190 } |
192 timer = clock() - timer; | 191 timer = clock() - timer; |
193 | 192 |
194 free(msg_string); | 193 srtp_crypto_free(msg_string); |
195 free(result); | 194 srtp_crypto_free(result); |
196 | 195 |
197 return (double) NUM_TRIALS * 8 * msg_len_octets * CLOCKS_PER_SEC / timer; | 196 return (double) NUM_TRIALS * 8 * msg_len_octets * CLOCKS_PER_SEC / timer; |
198 } | 197 } |
199 | 198 |
200 | 199 |
OLD | NEW |