summaryrefslogtreecommitdiff
path: root/regress/lib
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-07-30 16:12:41 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-07-30 16:12:41 +0000
commit32135c8e58c60b77c98133ee10fd5275c6718911 (patch)
treebfdc5ca98c947f5a0e41f9241fb0d128ce94966c /regress/lib
parentb0d78e2b57056a7ad299ee09e8bebab5cdd6d749 (diff)
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 'regress/lib')
-rw-r--r--regress/lib/libcrypto/aead/aeadtest.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/regress/lib/libcrypto/aead/aeadtest.c b/regress/lib/libcrypto/aead/aeadtest.c
index a6a2673320c..da2334329f5 100644
--- a/regress/lib/libcrypto/aead/aeadtest.c
+++ b/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;
}
}