summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-04-22 21:27:11 +0000
committermiod <miod@openbsd.org>2014-04-22 21:27:11 +0000
commit31a285ee9c85784ffefe282f3aa54f416527576e (patch)
treee1134643d9b535fddf7d8689a6da6f3fccb78119
parentuse reallocarray (diff)
downloadwireguard-openbsd-31a285ee9c85784ffefe282f3aa54f416527576e.tar.xz
wireguard-openbsd-31a285ee9c85784ffefe282f3aa54f416527576e.zip
When compiling with AES_WRAP_TEST, make main() return a meaningful value
instead of garbage, and add this to the libcrypto regress. Note these tests are incomplete, as they always use the default IV.
-rw-r--r--lib/libcrypto/aes/aes_wrap.c16
-rw-r--r--lib/libssl/src/crypto/aes/aes_wrap.c16
-rw-r--r--regress/lib/libcrypto/Makefile3
-rw-r--r--regress/lib/libcrypto/aeswrap/Makefile12
4 files changed, 44 insertions, 3 deletions
diff --git a/lib/libcrypto/aes/aes_wrap.c b/lib/libcrypto/aes/aes_wrap.c
index 668978425ad..40533440bf3 100644
--- a/lib/libcrypto/aes/aes_wrap.c
+++ b/lib/libcrypto/aes/aes_wrap.c
@@ -231,19 +231,33 @@ main(int argc, char **argv)
};
AES_KEY wctx, xctx;
- int ret;
+ int ret, nfailures = 0;
ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
+
+ return nfailures;
}
#endif
diff --git a/lib/libssl/src/crypto/aes/aes_wrap.c b/lib/libssl/src/crypto/aes/aes_wrap.c
index 668978425ad..40533440bf3 100644
--- a/lib/libssl/src/crypto/aes/aes_wrap.c
+++ b/lib/libssl/src/crypto/aes/aes_wrap.c
@@ -231,19 +231,33 @@ main(int argc, char **argv)
};
AES_KEY wctx, xctx;
- int ret;
+ int ret, nfailures = 0;
ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
+ if (ret == 0)
+ nfailures++;
fprintf(stderr, "Key test result %d\n", ret);
+
+ return nfailures;
}
#endif
diff --git a/regress/lib/libcrypto/Makefile b/regress/lib/libcrypto/Makefile
index 46e867b81da..df9e45f96a8 100644
--- a/regress/lib/libcrypto/Makefile
+++ b/regress/lib/libcrypto/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.3 2014/04/17 18:33:21 miod Exp $
+# $OpenBSD: Makefile,v 1.4 2014/04/22 21:27:13 miod Exp $
SUBDIR= \
+ aeswrap \
bf \
bn \
cast \
diff --git a/regress/lib/libcrypto/aeswrap/Makefile b/regress/lib/libcrypto/aeswrap/Makefile
new file mode 100644
index 00000000000..63770a5c7de
--- /dev/null
+++ b/regress/lib/libcrypto/aeswrap/Makefile
@@ -0,0 +1,12 @@
+# $OpenBSD: Makefile,v 1.1 2014/04/22 21:27:15 miod Exp $
+
+PROG= aes_wrap
+CRYPTO= ${.CURDIR}/../../../../lib/libssl/src/crypto
+CFLAGS+= -DAES_WRAP_TEST
+CFLAGS+= -I${CRYPTO} -I${CRYPTO}/aes
+.PATH: ${CRYPTO}/aes
+
+LDADD= -lcrypto
+DPADD= ${LIBCRYPTO}
+
+.include <bsd.regress.mk>