diff options
author | Colin Watson <cjwatson@debian.org> | 2020-02-21 11:57:14 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2020-02-21 11:57:14 +0000 |
commit | f0de78bd4f29fa688c5df116f3f9cd43543a76d0 (patch) | |
tree | 856b0dee3f2764c13a32dad5ffe2424fab7fef41 /regress/unittests/sshkey | |
parent | 4213eec74e74de6310c27a40c3e9759a08a73996 (diff) | |
parent | 8aa3455b16fddea4c0144a7c4a1edb10ec67dcc8 (diff) |
Import openssh_8.2p1.orig.tar.gz
Diffstat (limited to 'regress/unittests/sshkey')
-rw-r--r-- | regress/unittests/sshkey/Makefile | 9 | ||||
-rw-r--r-- | regress/unittests/sshkey/common.c | 11 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_fuzz.c | 9 | ||||
-rw-r--r-- | regress/unittests/sshkey/test_sshkey.c | 14 |
4 files changed, 21 insertions, 22 deletions
diff --git a/regress/unittests/sshkey/Makefile b/regress/unittests/sshkey/Makefile index aa731df1c..78b2cf0ce 100644 --- a/regress/unittests/sshkey/Makefile +++ b/regress/unittests/sshkey/Makefile | |||
@@ -1,16 +1,17 @@ | |||
1 | # $OpenBSD: Makefile,v 1.6 2018/10/17 23:28:05 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.9 2020/01/26 00:09:50 djm Exp $ |
2 | 2 | ||
3 | PROG=test_sshkey | 3 | PROG=test_sshkey |
4 | SRCS=tests.c test_sshkey.c test_file.c test_fuzz.c common.c | 4 | SRCS=tests.c test_sshkey.c test_file.c test_fuzz.c common.c |
5 | 5 | ||
6 | # From usr.bin/ssh | 6 | # From usr.bin/ssh |
7 | SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c | 7 | SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c |
8 | SRCS+=atomicio.c sshkey.c authfile.c cipher.c log.c ssh-rsa.c ssh-dss.c | 8 | SRCS+=sshbuf-io.c atomicio.c sshkey.c authfile.c cipher.c log.c ssh-rsa.c |
9 | SRCS+=ssh-ecdsa.c ssh-ed25519.c mac.c umac.c umac128.c hmac.c misc.c | 9 | SRCS+=ssh-dss.c ssh-ecdsa.c ssh-ed25519.c mac.c umac.c umac128.c hmac.c misc.c |
10 | SRCS+=ssherr.c uidswap.c cleanup.c xmalloc.c match.c krl.c fatal.c | 10 | SRCS+=ssherr.c uidswap.c cleanup.c xmalloc.c match.c krl.c fatal.c |
11 | SRCS+=addrmatch.c bitmap.c | 11 | SRCS+=addrmatch.c bitmap.c |
12 | SRCS+=ed25519.c hash.c ge25519.c fe25519.c sc25519.c verify.c | 12 | SRCS+=ed25519.c hash.c ge25519.c fe25519.c sc25519.c verify.c |
13 | SRCS+=cipher-chachapoly.c chacha.c poly1305.c | 13 | SRCS+=cipher-chachapoly.c chacha.c poly1305.c ssh-ecdsa-sk.c ssh-sk.c |
14 | SRCS+=ssh-ed25519-sk.c sk-usbhid.c | ||
14 | 15 | ||
15 | SRCS+=digest-openssl.c | 16 | SRCS+=digest-openssl.c |
16 | #SRCS+=digest-libc.c | 17 | #SRCS+=digest-libc.c |
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c index e21638093..effea578c 100644 --- a/regress/unittests/sshkey/common.c +++ b/regress/unittests/sshkey/common.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: common.c,v 1.3 2018/09/13 09:03:20 djm Exp $ */ | 1 | /* $OpenBSD: common.c,v 1.4 2020/01/26 00:09:50 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Helpers for key API tests | 3 | * Helpers for key API tests |
4 | * | 4 | * |
@@ -43,13 +43,10 @@ | |||
43 | struct sshbuf * | 43 | struct sshbuf * |
44 | load_file(const char *name) | 44 | load_file(const char *name) |
45 | { | 45 | { |
46 | int fd; | 46 | struct sshbuf *ret = NULL; |
47 | struct sshbuf *ret; | ||
48 | 47 | ||
49 | ASSERT_PTR_NE(ret = sshbuf_new(), NULL); | 48 | ASSERT_INT_EQ(sshbuf_load_file(test_data_file(name), &ret), 0); |
50 | ASSERT_INT_NE(fd = open(test_data_file(name), O_RDONLY), -1); | 49 | ASSERT_PTR_NE(ret, NULL); |
51 | ASSERT_INT_EQ(sshkey_load_file(fd, ret), 0); | ||
52 | close(fd); | ||
53 | return ret; | 50 | return ret; |
54 | } | 51 | } |
55 | 52 | ||
diff --git a/regress/unittests/sshkey/test_fuzz.c b/regress/unittests/sshkey/test_fuzz.c index 1323f8997..359811893 100644 --- a/regress/unittests/sshkey/test_fuzz.c +++ b/regress/unittests/sshkey/test_fuzz.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: test_fuzz.c,v 1.9 2018/10/17 23:28:05 djm Exp $ */ | 1 | /* $OpenBSD: test_fuzz.c,v 1.11 2019/11/25 10:32:35 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Fuzz tests for key parsing | 3 | * Fuzz tests for key parsing |
4 | * | 4 | * |
@@ -87,10 +87,11 @@ sig_fuzz(struct sshkey *k, const char *sig_alg) | |||
87 | if (test_is_slow()) | 87 | if (test_is_slow()) |
88 | fuzzers |= FUZZ_2_BIT_FLIP; | 88 | fuzzers |= FUZZ_2_BIT_FLIP; |
89 | 89 | ||
90 | ASSERT_INT_EQ(sshkey_sign(k, &sig, &l, c, sizeof(c), sig_alg, 0), 0); | 90 | ASSERT_INT_EQ(sshkey_sign(k, &sig, &l, c, sizeof(c), |
91 | sig_alg, NULL, 0), 0); | ||
91 | ASSERT_SIZE_T_GT(l, 0); | 92 | ASSERT_SIZE_T_GT(l, 0); |
92 | fuzz = fuzz_begin(fuzzers, sig, l); | 93 | fuzz = fuzz_begin(fuzzers, sig, l); |
93 | ASSERT_INT_EQ(sshkey_verify(k, sig, l, c, sizeof(c), NULL, 0), 0); | 94 | ASSERT_INT_EQ(sshkey_verify(k, sig, l, c, sizeof(c), NULL, 0, NULL), 0); |
94 | free(sig); | 95 | free(sig); |
95 | TEST_ONERROR(onerror, fuzz); | 96 | TEST_ONERROR(onerror, fuzz); |
96 | for(; !fuzz_done(fuzz); fuzz_next(fuzz)) { | 97 | for(; !fuzz_done(fuzz); fuzz_next(fuzz)) { |
@@ -98,7 +99,7 @@ sig_fuzz(struct sshkey *k, const char *sig_alg) | |||
98 | if (fuzz_matches_original(fuzz)) | 99 | if (fuzz_matches_original(fuzz)) |
99 | continue; | 100 | continue; |
100 | ASSERT_INT_NE(sshkey_verify(k, fuzz_ptr(fuzz), fuzz_len(fuzz), | 101 | ASSERT_INT_NE(sshkey_verify(k, fuzz_ptr(fuzz), fuzz_len(fuzz), |
101 | c, sizeof(c), NULL, 0), 0); | 102 | c, sizeof(c), NULL, 0, NULL), 0); |
102 | } | 103 | } |
103 | fuzz_cleanup(fuzz); | 104 | fuzz_cleanup(fuzz); |
104 | } | 105 | } |
diff --git a/regress/unittests/sshkey/test_sshkey.c b/regress/unittests/sshkey/test_sshkey.c index 42395b8db..025bb9815 100644 --- a/regress/unittests/sshkey/test_sshkey.c +++ b/regress/unittests/sshkey/test_sshkey.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: test_sshkey.c,v 1.18 2019/06/21 04:21:45 djm Exp $ */ | 1 | /* $OpenBSD: test_sshkey.c,v 1.20 2019/11/25 10:32:35 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for sshkey.h key management API | 3 | * Regress test for sshkey.h key management API |
4 | * | 4 | * |
@@ -101,7 +101,7 @@ build_cert(struct sshbuf *b, struct sshkey *k, const char *type, | |||
101 | ASSERT_INT_EQ(sshbuf_put_string(b, NULL, 0), 0); /* reserved */ | 101 | ASSERT_INT_EQ(sshbuf_put_string(b, NULL, 0), 0); /* reserved */ |
102 | ASSERT_INT_EQ(sshbuf_put_stringb(b, ca_buf), 0); /* signature key */ | 102 | ASSERT_INT_EQ(sshbuf_put_stringb(b, ca_buf), 0); /* signature key */ |
103 | ASSERT_INT_EQ(sshkey_sign(sign_key, &sigblob, &siglen, | 103 | ASSERT_INT_EQ(sshkey_sign(sign_key, &sigblob, &siglen, |
104 | sshbuf_ptr(b), sshbuf_len(b), sig_alg, 0), 0); | 104 | sshbuf_ptr(b), sshbuf_len(b), sig_alg, NULL, 0), 0); |
105 | ASSERT_INT_EQ(sshbuf_put_string(b, sigblob, siglen), 0); /* signature */ | 105 | ASSERT_INT_EQ(sshbuf_put_string(b, sigblob, siglen), 0); /* signature */ |
106 | 106 | ||
107 | free(sigblob); | 107 | free(sigblob); |
@@ -120,14 +120,14 @@ signature_test(struct sshkey *k, struct sshkey *bad, const char *sig_alg, | |||
120 | size_t len; | 120 | size_t len; |
121 | u_char *sig; | 121 | u_char *sig; |
122 | 122 | ||
123 | ASSERT_INT_EQ(sshkey_sign(k, &sig, &len, d, l, sig_alg, 0), 0); | 123 | ASSERT_INT_EQ(sshkey_sign(k, &sig, &len, d, l, sig_alg, NULL, 0), 0); |
124 | ASSERT_SIZE_T_GT(len, 8); | 124 | ASSERT_SIZE_T_GT(len, 8); |
125 | ASSERT_PTR_NE(sig, NULL); | 125 | ASSERT_PTR_NE(sig, NULL); |
126 | ASSERT_INT_EQ(sshkey_verify(k, sig, len, d, l, NULL, 0), 0); | 126 | ASSERT_INT_EQ(sshkey_verify(k, sig, len, d, l, NULL, 0, NULL), 0); |
127 | ASSERT_INT_NE(sshkey_verify(bad, sig, len, d, l, NULL, 0), 0); | 127 | ASSERT_INT_NE(sshkey_verify(bad, sig, len, d, l, NULL, 0, NULL), 0); |
128 | /* Fuzz test is more comprehensive, this is just a smoke test */ | 128 | /* Fuzz test is more comprehensive, this is just a smoke test */ |
129 | sig[len - 5] ^= 0x10; | 129 | sig[len - 5] ^= 0x10; |
130 | ASSERT_INT_NE(sshkey_verify(k, sig, len, d, l, NULL, 0), 0); | 130 | ASSERT_INT_NE(sshkey_verify(k, sig, len, d, l, NULL, 0, NULL), 0); |
131 | free(sig); | 131 | free(sig); |
132 | } | 132 | } |
133 | 133 | ||
@@ -437,7 +437,7 @@ sshkey_tests(void) | |||
437 | put_opt(k1->cert->extensions, "permit-X11-forwarding", NULL); | 437 | put_opt(k1->cert->extensions, "permit-X11-forwarding", NULL); |
438 | put_opt(k1->cert->extensions, "permit-agent-forwarding", NULL); | 438 | put_opt(k1->cert->extensions, "permit-agent-forwarding", NULL); |
439 | ASSERT_INT_EQ(sshkey_from_private(k2, &k1->cert->signature_key), 0); | 439 | ASSERT_INT_EQ(sshkey_from_private(k2, &k1->cert->signature_key), 0); |
440 | ASSERT_INT_EQ(sshkey_certify(k1, k2, NULL), 0); | 440 | ASSERT_INT_EQ(sshkey_certify(k1, k2, NULL, NULL), 0); |
441 | b = sshbuf_new(); | 441 | b = sshbuf_new(); |
442 | ASSERT_PTR_NE(b, NULL); | 442 | ASSERT_PTR_NE(b, NULL); |
443 | ASSERT_INT_EQ(sshkey_putb(k1, b), 0); | 443 | ASSERT_INT_EQ(sshkey_putb(k1, b), 0); |