From e641a432ba534698599287f0a7d174225f2e4b59 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sat, 30 Jul 2022 16:12:40 +0000 Subject: 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. --- src/regress/lib/libcrypto/aead/aeadtest.c | 63 ++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 21 deletions(-) (limited to 'src') 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 @@ -/* $OpenBSD: aeadtest.c,v 1.17 2022/07/30 14:49:15 jsing Exp $ */ +/* $OpenBSD: aeadtest.c,v 1.18 2022/07/30 16:12:40 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -306,31 +306,52 @@ main(int argc, char **argv) continue; } - for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { - unsigned char v, v2; - v = hex_digit(line[i++]); - if (line[i] == 0 || line[i] == '\n') { - fprintf(stderr, "Odd-length hex data on " - "line %u\n", line_no); - return 3; + if (line[i] == '"') { + i++; + for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { + if (line[i] == '"') + break; + if (j == BUF_MAX) { + fprintf(stderr, "Too much data on " + "line %u (max is %u bytes)\n", + line_no, (unsigned) BUF_MAX); + return 3; + } + buf[j++] = line[i]; + *buf_len = *buf_len + 1; } - v2 = hex_digit(line[i]); - if (v > 15 || v2 > 15) { - fprintf(stderr, "Invalid hex char on line %u\n", + if (line[i + 1] != 0 && line[i + 1] != '\n') { + fprintf(stderr, "Trailing data on line %u\n", line_no); return 3; } - v <<= 4; - v |= v2; - - if (j == BUF_MAX) { - fprintf(stderr, "Too much hex data on line %u " - "(max is %u bytes)\n", - line_no, (unsigned) BUF_MAX); - return 3; + } else { + for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { + unsigned char v, v2; + v = hex_digit(line[i++]); + if (line[i] == 0 || line[i] == '\n') { + fprintf(stderr, "Odd-length hex data " + "on line %u\n", line_no); + return 3; + } + v2 = hex_digit(line[i]); + if (v > 15 || v2 > 15) { + fprintf(stderr, "Invalid hex char on " + "line %u\n", line_no); + return 3; + } + v <<= 4; + v |= v2; + + if (j == BUF_MAX) { + fprintf(stderr, "Too much hex data on " + "line %u (max is %u bytes)\n", + line_no, (unsigned) BUF_MAX); + return 3; + } + buf[j++] = v; + *buf_len = *buf_len + 1; } - buf[j++] = v; - *buf_len = *buf_len + 1; } } -- cgit v1.2.3-55-g6feb