summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2022-07-30 16:12:40 +0000
committerjsing <>2022-07-30 16:12:40 +0000
commite641a432ba534698599287f0a7d174225f2e4b59 (patch)
tree871df9fce23ae34e086067a70038b7846d4ad1d3 /src
parent2e8121ec607a52280e34e73c46721a343b649ac4 (diff)
downloadopenbsd-e641a432ba534698599287f0a7d174225f2e4b59.tar.gz
openbsd-e641a432ba534698599287f0a7d174225f2e4b59.tar.bz2
openbsd-e641a432ba534698599287f0a7d174225f2e4b59.zip
Allow quoted ASCII strings as input for AEAD regress.
Currently, each line in the text file is expected to be string of hexadecimal digits. In addition to this, allow a line to be given as an quoted ASCII string.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/aead/aeadtest.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/regress/lib/libcrypto/aead/aeadtest.c b/src/regress/lib/libcrypto/aead/aeadtest.c
index a6a2673320..da2334329f 100644
--- a/src/regress/lib/libcrypto/aead/aeadtest.c
+++ b/src/regress/lib/libcrypto/aead/aeadtest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: aeadtest.c,v 1.17 2022/07/30 14:49:15 jsing Exp $ */ 1/* $OpenBSD: aeadtest.c,v 1.18 2022/07/30 16:12:40 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -306,31 +306,52 @@ main(int argc, char **argv)
306 continue; 306 continue;
307 } 307 }
308 308
309 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { 309 if (line[i] == '"') {
310 unsigned char v, v2; 310 i++;
311 v = hex_digit(line[i++]); 311 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) {
312 if (line[i] == 0 || line[i] == '\n') { 312 if (line[i] == '"')
313 fprintf(stderr, "Odd-length hex data on " 313 break;
314 "line %u\n", line_no); 314 if (j == BUF_MAX) {
315 return 3; 315 fprintf(stderr, "Too much data on "
316 "line %u (max is %u bytes)\n",
317 line_no, (unsigned) BUF_MAX);
318 return 3;
319 }
320 buf[j++] = line[i];
321 *buf_len = *buf_len + 1;
316 } 322 }
317 v2 = hex_digit(line[i]); 323 if (line[i + 1] != 0 && line[i + 1] != '\n') {
318 if (v > 15 || v2 > 15) { 324 fprintf(stderr, "Trailing data on line %u\n",
319 fprintf(stderr, "Invalid hex char on line %u\n",
320 line_no); 325 line_no);
321 return 3; 326 return 3;
322 } 327 }
323 v <<= 4; 328 } else {
324 v |= v2; 329 for (j = 0; line[i] != 0 && line[i] != '\n'; i++) {
325 330 unsigned char v, v2;
326 if (j == BUF_MAX) { 331 v = hex_digit(line[i++]);
327 fprintf(stderr, "Too much hex data on line %u " 332 if (line[i] == 0 || line[i] == '\n') {
328 "(max is %u bytes)\n", 333 fprintf(stderr, "Odd-length hex data "
329 line_no, (unsigned) BUF_MAX); 334 "on line %u\n", line_no);
330 return 3; 335 return 3;
336 }
337 v2 = hex_digit(line[i]);
338 if (v > 15 || v2 > 15) {
339 fprintf(stderr, "Invalid hex char on "
340 "line %u\n", line_no);
341 return 3;
342 }
343 v <<= 4;
344 v |= v2;
345
346 if (j == BUF_MAX) {
347 fprintf(stderr, "Too much hex data on "
348 "line %u (max is %u bytes)\n",
349 line_no, (unsigned) BUF_MAX);
350 return 3;
351 }
352 buf[j++] = v;
353 *buf_len = *buf_len + 1;
331 } 354 }
332 buf[j++] = v;
333 *buf_len = *buf_len + 1;
334 } 355 }
335 } 356 }
336 357