summaryrefslogtreecommitdiffstats
path: root/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2015-12-07 02:20:46 +0000
committerdjm <djm@openbsd.org>2015-12-07 02:20:46 +0000
commit3382e0804030f878d5a73758457b7e06c0506b3c (patch)
tree799a502acd38876d37cde70f045fed99824a4eac /regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c
parentNFS can pass a buffer cache buffer straight to VOP_STRATEGY here, so dma_flip is (diff)
downloadwireguard-openbsd-3382e0804030f878d5a73758457b7e06c0506b3c.tar.xz
wireguard-openbsd-3382e0804030f878d5a73758457b7e06c0506b3c.zip
basic unit tests for rsa-sha2-* signature types
Diffstat (limited to 'regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c')
-rw-r--r--regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c b/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c
index 74920374d57..c86b7cc9935 100644
--- a/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c
+++ b/regress/usr.bin/ssh/unittests/sshkey/test_fuzz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: test_fuzz.c,v 1.5 2015/10/06 01:20:59 djm Exp $ */
+/* $OpenBSD: test_fuzz.c,v 1.6 2015/12/07 02:20:46 djm Exp $ */
/*
* Fuzz tests for key parsing
*
@@ -66,13 +66,13 @@ public_fuzz(struct sshkey *k)
}
static void
-sig_fuzz(struct sshkey *k)
+sig_fuzz(struct sshkey *k, const char *sig_alg)
{
struct fuzz *fuzz;
u_char *sig, c[] = "some junk to be signed";
size_t l;
- ASSERT_INT_EQ(sshkey_sign(k, &sig, &l, c, sizeof(c), 0), 0);
+ ASSERT_INT_EQ(sshkey_sign(k, &sig, &l, c, sizeof(c), sig_alg, 0), 0);
ASSERT_SIZE_T_GT(l, 0);
fuzz = fuzz_begin(FUZZ_1_BIT_FLIP | /* too slow FUZZ_2_BIT_FLIP | */
FUZZ_1_BYTE_FLIP | FUZZ_2_BYTE_FLIP |
@@ -342,7 +342,23 @@ sshkey_fuzz_tests(void)
buf = load_file("rsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
sshbuf_free(buf);
- sig_fuzz(k1);
+ sig_fuzz(k1, "ssh-rsa");
+ sshkey_free(k1);
+ TEST_DONE();
+
+ TEST_START("fuzz RSA SHA256 sig");
+ buf = load_file("rsa_1");
+ ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
+ sshbuf_free(buf);
+ sig_fuzz(k1, "rsa-sha2-256");
+ sshkey_free(k1);
+ TEST_DONE();
+
+ TEST_START("fuzz RSA SHA512 sig");
+ buf = load_file("rsa_1");
+ ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
+ sshbuf_free(buf);
+ sig_fuzz(k1, "rsa-sha2-512");
sshkey_free(k1);
TEST_DONE();
@@ -350,7 +366,7 @@ sshkey_fuzz_tests(void)
buf = load_file("dsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
sshbuf_free(buf);
- sig_fuzz(k1);
+ sig_fuzz(k1, NULL);
sshkey_free(k1);
TEST_DONE();
@@ -358,7 +374,7 @@ sshkey_fuzz_tests(void)
buf = load_file("ecdsa_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
sshbuf_free(buf);
- sig_fuzz(k1);
+ sig_fuzz(k1, NULL);
sshkey_free(k1);
TEST_DONE();
@@ -366,7 +382,7 @@ sshkey_fuzz_tests(void)
buf = load_file("ed25519_1");
ASSERT_INT_EQ(sshkey_parse_private_fileblob(buf, "", &k1, NULL), 0);
sshbuf_free(buf);
- sig_fuzz(k1);
+ sig_fuzz(k1, NULL);
sshkey_free(k1);
TEST_DONE();