summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2014-04-22 21:27:15 +0000
committermiod <>2014-04-22 21:27:15 +0000
commit71b791a2ff679463d6ef915490232cfa037f02b2 (patch)
tree7f01145a77987f3aea2deaa91990a805eb4bb794 /src
parent996a57299e8b8467ff12bc7b90151e61248338ef (diff)
downloadopenbsd-71b791a2ff679463d6ef915490232cfa037f02b2.tar.gz
openbsd-71b791a2ff679463d6ef915490232cfa037f02b2.tar.bz2
openbsd-71b791a2ff679463d6ef915490232cfa037f02b2.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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/aes/aes_wrap.c16
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_wrap.c16
-rw-r--r--src/regress/lib/libcrypto/Makefile3
-rw-r--r--src/regress/lib/libcrypto/aeswrap/Makefile12
4 files changed, 44 insertions, 3 deletions
diff --git a/src/lib/libcrypto/aes/aes_wrap.c b/src/lib/libcrypto/aes/aes_wrap.c
index 668978425a..40533440bf 100644
--- a/src/lib/libcrypto/aes/aes_wrap.c
+++ b/src/lib/libcrypto/aes/aes_wrap.c
@@ -231,19 +231,33 @@ main(int argc, char **argv)
231 }; 231 };
232 232
233 AES_KEY wctx, xctx; 233 AES_KEY wctx, xctx;
234 int ret; 234 int ret, nfailures = 0;
235 ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16); 235 ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
236 if (ret == 0)
237 nfailures++;
236 fprintf(stderr, "Key test result %d\n", ret); 238 fprintf(stderr, "Key test result %d\n", ret);
237 ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16); 239 ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
240 if (ret == 0)
241 nfailures++;
238 fprintf(stderr, "Key test result %d\n", ret); 242 fprintf(stderr, "Key test result %d\n", ret);
239 ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16); 243 ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
244 if (ret == 0)
245 nfailures++;
240 fprintf(stderr, "Key test result %d\n", ret); 246 fprintf(stderr, "Key test result %d\n", ret);
241 ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24); 247 ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
248 if (ret == 0)
249 nfailures++;
242 fprintf(stderr, "Key test result %d\n", ret); 250 fprintf(stderr, "Key test result %d\n", ret);
243 ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24); 251 ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
252 if (ret == 0)
253 nfailures++;
244 fprintf(stderr, "Key test result %d\n", ret); 254 fprintf(stderr, "Key test result %d\n", ret);
245 ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32); 255 ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
256 if (ret == 0)
257 nfailures++;
246 fprintf(stderr, "Key test result %d\n", ret); 258 fprintf(stderr, "Key test result %d\n", ret);
259
260 return nfailures;
247} 261}
248 262
249#endif 263#endif
diff --git a/src/lib/libssl/src/crypto/aes/aes_wrap.c b/src/lib/libssl/src/crypto/aes/aes_wrap.c
index 668978425a..40533440bf 100644
--- a/src/lib/libssl/src/crypto/aes/aes_wrap.c
+++ b/src/lib/libssl/src/crypto/aes/aes_wrap.c
@@ -231,19 +231,33 @@ main(int argc, char **argv)
231 }; 231 };
232 232
233 AES_KEY wctx, xctx; 233 AES_KEY wctx, xctx;
234 int ret; 234 int ret, nfailures = 0;
235 ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16); 235 ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16);
236 if (ret == 0)
237 nfailures++;
236 fprintf(stderr, "Key test result %d\n", ret); 238 fprintf(stderr, "Key test result %d\n", ret);
237 ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16); 239 ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16);
240 if (ret == 0)
241 nfailures++;
238 fprintf(stderr, "Key test result %d\n", ret); 242 fprintf(stderr, "Key test result %d\n", ret);
239 ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16); 243 ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16);
244 if (ret == 0)
245 nfailures++;
240 fprintf(stderr, "Key test result %d\n", ret); 246 fprintf(stderr, "Key test result %d\n", ret);
241 ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24); 247 ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24);
248 if (ret == 0)
249 nfailures++;
242 fprintf(stderr, "Key test result %d\n", ret); 250 fprintf(stderr, "Key test result %d\n", ret);
243 ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24); 251 ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24);
252 if (ret == 0)
253 nfailures++;
244 fprintf(stderr, "Key test result %d\n", ret); 254 fprintf(stderr, "Key test result %d\n", ret);
245 ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32); 255 ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32);
256 if (ret == 0)
257 nfailures++;
246 fprintf(stderr, "Key test result %d\n", ret); 258 fprintf(stderr, "Key test result %d\n", ret);
259
260 return nfailures;
247} 261}
248 262
249#endif 263#endif
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile
index 46e867b81d..df9e45f96a 100644
--- a/src/regress/lib/libcrypto/Makefile
+++ b/src/regress/lib/libcrypto/Makefile
@@ -1,6 +1,7 @@
1# $OpenBSD: Makefile,v 1.3 2014/04/17 18:33:21 miod Exp $ 1# $OpenBSD: Makefile,v 1.4 2014/04/22 21:27:13 miod Exp $
2 2
3SUBDIR= \ 3SUBDIR= \
4 aeswrap \
4 bf \ 5 bf \
5 bn \ 6 bn \
6 cast \ 7 cast \
diff --git a/src/regress/lib/libcrypto/aeswrap/Makefile b/src/regress/lib/libcrypto/aeswrap/Makefile
new file mode 100644
index 0000000000..63770a5c7d
--- /dev/null
+++ b/src/regress/lib/libcrypto/aeswrap/Makefile
@@ -0,0 +1,12 @@
1# $OpenBSD: Makefile,v 1.1 2014/04/22 21:27:15 miod Exp $
2
3PROG= aes_wrap
4CRYPTO= ${.CURDIR}/../../../../lib/libssl/src/crypto
5CFLAGS+= -DAES_WRAP_TEST
6CFLAGS+= -I${CRYPTO} -I${CRYPTO}/aes
7.PATH: ${CRYPTO}/aes
8
9LDADD= -lcrypto
10DPADD= ${LIBCRYPTO}
11
12.include <bsd.regress.mk>