Allow the AEAD to be specified for a test file.
authorjsing <jsing@openbsd.org>
Sat, 30 Jul 2022 16:30:42 +0000 (16:30 +0000)
committerjsing <jsing@openbsd.org>
Sat, 30 Jul 2022 16:30:42 +0000 (16:30 +0000)
Currently, this must be specified per test - allow it to be given as a
command line argument that applies to the entire test file.

regress/lib/libcrypto/aead/Makefile
regress/lib/libcrypto/aead/aeadtest.c

index c7ee88b..cc58fc1 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.5 2022/01/14 09:38:50 tb Exp $
+#      $OpenBSD: Makefile,v 1.6 2022/07/30 16:30:42 jsing Exp $
 
 PROG=  aeadtest
 LDADD= -lcrypto
@@ -9,6 +9,6 @@ CFLAGS+=        -DLIBRESSL_INTERNAL -Werror
 REGRESS_TARGETS=regress-aeadtest
 
 regress-aeadtest: ${PROG}
-       ./${PROG} ${.CURDIR}/aeadtests.txt
+       ./${PROG} aead ${.CURDIR}/aeadtests.txt
 
 .include <bsd.regress.mk>
index bd61923..189cece 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: aeadtest.c,v 1.19 2022/07/30 16:17:22 jsing Exp $     */
+/*     $OpenBSD: aeadtest.c,v 1.20 2022/07/30 16:30:42 jsing Exp $     */
 /*
  * Copyright (c) 2014, Google Inc.
  *
@@ -392,14 +392,14 @@ main(int argc, char **argv)
        unsigned int line_no = 0, num_tests = 0, j;
        unsigned char bufs[NUM_TYPES][BUF_MAX];
        unsigned int lengths[NUM_TYPES];
+       const char *aeadname;
 
-       if (argc != 2) {
-               fprintf(stderr, "%s <test file.txt>\n", argv[0]);
+       if (argc != 3) {
+               fprintf(stderr, "%s <aead> <test file.txt>\n", argv[0]);
                return 1;
        }
 
-       f = fopen(argv[1], "r");
-       if (f == NULL) {
+       if ((f = fopen(argv[2], "r")) == NULL) {
                perror("failed to open input");
                return 1;
        }
@@ -434,7 +434,11 @@ main(int argc, char **argv)
                        if (!any_values_set)
                                continue;
 
-                       if (!aead_from_name(&aead, &cipher, bufs[AEAD])) {
+                       aeadname = argv[1];
+                       if (lengths[AEAD] != 0)
+                               aeadname = bufs[AEAD];
+
+                       if (!aead_from_name(&aead, &cipher, aeadname)) {
                                fprintf(stderr, "Aborting...\n");
                                return 4;
                        }