diff options
Diffstat (limited to 'regress/unittests')
-rw-r--r-- | regress/unittests/Makefile.inc | 5 | ||||
-rw-r--r-- | regress/unittests/authopt/Makefile | 26 | ||||
-rw-r--r-- | regress/unittests/hostkeys/Makefile | 9 | ||||
-rw-r--r-- | regress/unittests/kex/Makefile | 9 | ||||
-rw-r--r-- | regress/unittests/misc/Makefile | 16 | ||||
-rw-r--r-- | regress/unittests/misc/tests.c | 79 | ||||
-rw-r--r-- | regress/unittests/sshbuf/Makefile | 6 | ||||
-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 |
11 files changed, 159 insertions, 34 deletions
diff --git a/regress/unittests/Makefile.inc b/regress/unittests/Makefile.inc index 428ef6836..370224aa5 100644 --- a/regress/unittests/Makefile.inc +++ b/regress/unittests/Makefile.inc | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.13 2018/10/17 23:28:05 djm Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.14 2019/11/25 10:32:35 djm Exp $ |
2 | 2 | ||
3 | REGRESS_FAIL_EARLY?= yes | 3 | REGRESS_FAIL_EARLY?= yes |
4 | 4 | ||
@@ -74,6 +74,9 @@ LDADD+= -lcrypto | |||
74 | DPADD+= ${LIBCRYPTO} | 74 | DPADD+= ${LIBCRYPTO} |
75 | .endif | 75 | .endif |
76 | 76 | ||
77 | LDADD+= -lfido2 -lcbor -lusbhid | ||
78 | DPADD+= ${LIBFIDO2} ${LIBCBOR} ${LIBUSBHID} | ||
79 | |||
77 | UNITTEST_ARGS?= | 80 | UNITTEST_ARGS?= |
78 | 81 | ||
79 | .if (${UNITTEST_VERBOSE:L} != "no") | 82 | .if (${UNITTEST_VERBOSE:L} != "no") |
diff --git a/regress/unittests/authopt/Makefile b/regress/unittests/authopt/Makefile new file mode 100644 index 000000000..492092fc6 --- /dev/null +++ b/regress/unittests/authopt/Makefile | |||
@@ -0,0 +1,26 @@ | |||
1 | # $OpenBSD: Makefile,v 1.4 2020/01/26 00:09:50 djm Exp $ | ||
2 | |||
3 | PROG=test_authopt | ||
4 | SRCS=tests.c | ||
5 | |||
6 | SRCS+=auth-options.c | ||
7 | |||
8 | # From usr.bin/ssh | ||
9 | SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c | ||
10 | SRCS+=sshbuf-io.c atomicio.c sshkey.c authfile.c cipher.c log.c ssh-rsa.c | ||
11 | SRCS+=ssh-dss.c ssh-ecdsa.c ssh-ed25519.c mac.c umac.c umac128.c hmac.c misc.c | ||
12 | SRCS+=ssherr.c uidswap.c cleanup.c xmalloc.c match.c krl.c fatal.c | ||
13 | SRCS+=addrmatch.c bitmap.c | ||
14 | SRCS+=ed25519.c hash.c ge25519.c fe25519.c sc25519.c verify.c | ||
15 | SRCS+=cipher-chachapoly.c chacha.c poly1305.c ssh-ecdsa-sk.c ssh-sk.c | ||
16 | SRCS+=ssh-ed25519-sk.c sk-usbhid.c | ||
17 | |||
18 | SRCS+=digest-openssl.c | ||
19 | #SRCS+=digest-libc.c | ||
20 | |||
21 | REGRESS_TARGETS=run-regress-${PROG} | ||
22 | |||
23 | run-regress-${PROG}: ${PROG} | ||
24 | env ${TEST_ENV} ./${PROG} -d ${.CURDIR}/testdata | ||
25 | |||
26 | .include <bsd.regress.mk> | ||
diff --git a/regress/unittests/hostkeys/Makefile b/regress/unittests/hostkeys/Makefile index 336885122..c0a893135 100644 --- a/regress/unittests/hostkeys/Makefile +++ b/regress/unittests/hostkeys/Makefile | |||
@@ -1,16 +1,17 @@ | |||
1 | # $OpenBSD: Makefile,v 1.4 2017/12/21 00:41:22 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.7 2020/01/26 00:09:50 djm Exp $ |
2 | 2 | ||
3 | PROG=test_hostkeys | 3 | PROG=test_hostkeys |
4 | SRCS=tests.c test_iterate.c | 4 | SRCS=tests.c test_iterate.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 hostfile.c | 11 | SRCS+=addrmatch.c bitmap.c hostfile.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/kex/Makefile b/regress/unittests/kex/Makefile index 7b4c644e5..648006c78 100644 --- a/regress/unittests/kex/Makefile +++ b/regress/unittests/kex/Makefile | |||
@@ -1,16 +1,17 @@ | |||
1 | # $OpenBSD: Makefile,v 1.6 2019/01/21 12:35:20 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.9 2020/01/26 00:09:50 djm Exp $ |
2 | 2 | ||
3 | PROG=test_kex | 3 | PROG=test_kex |
4 | SRCS=tests.c test_kex.c | 4 | SRCS=tests.c test_kex.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 packet.c dispatch.c canohost.c ssh_api.c | 11 | SRCS+=addrmatch.c bitmap.c packet.c dispatch.c canohost.c ssh_api.c |
12 | SRCS+=compat.c ed25519.c hash.c ge25519.c fe25519.c sc25519.c verify.c | 12 | SRCS+=compat.c 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+= kex.c | 16 | SRCS+= kex.c |
16 | SRCS+= dh.c | 17 | SRCS+= dh.c |
diff --git a/regress/unittests/misc/Makefile b/regress/unittests/misc/Makefile new file mode 100644 index 000000000..06e954cb8 --- /dev/null +++ b/regress/unittests/misc/Makefile | |||
@@ -0,0 +1,16 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2019/04/28 22:53:26 dtucker Exp $ | ||
2 | |||
3 | PROG=test_misc | ||
4 | SRCS=tests.c | ||
5 | |||
6 | # From usr.bin/ssh/Makefile.inc | ||
7 | SRCS+=sshbuf.c sshbuf-getput-basic.c ssherr.c log.c xmalloc.c misc.c | ||
8 | # From usr/bin/ssh/sshd/Makefile | ||
9 | SRCS+=atomicio.c cleanup.c fatal.c | ||
10 | |||
11 | REGRESS_TARGETS=run-regress-${PROG} | ||
12 | |||
13 | run-regress-${PROG}: ${PROG} | ||
14 | env ${TEST_ENV} ./${PROG} | ||
15 | |||
16 | .include <bsd.regress.mk> | ||
diff --git a/regress/unittests/misc/tests.c b/regress/unittests/misc/tests.c new file mode 100644 index 000000000..ed775ebbd --- /dev/null +++ b/regress/unittests/misc/tests.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* $OpenBSD: tests.c,v 1.1 2019/04/28 22:53:26 dtucker Exp $ */ | ||
2 | /* | ||
3 | * Regress test for misc helper functions. | ||
4 | * | ||
5 | * Placed in the public domain. | ||
6 | */ | ||
7 | |||
8 | #include <sys/types.h> | ||
9 | #include <sys/param.h> | ||
10 | #include <stdio.h> | ||
11 | #include <stdint.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <string.h> | ||
14 | |||
15 | #include "test_helper.h" | ||
16 | |||
17 | #include "misc.h" | ||
18 | |||
19 | void | ||
20 | tests(void) | ||
21 | { | ||
22 | int port; | ||
23 | char *user, *host, *path; | ||
24 | |||
25 | TEST_START("misc_parse_user_host_path"); | ||
26 | ASSERT_INT_EQ(parse_user_host_path("someuser@some.host:some/path", | ||
27 | &user, &host, &path), 0); | ||
28 | ASSERT_STRING_EQ(user, "someuser"); | ||
29 | ASSERT_STRING_EQ(host, "some.host"); | ||
30 | ASSERT_STRING_EQ(path, "some/path"); | ||
31 | free(user); free(host); free(path); | ||
32 | TEST_DONE(); | ||
33 | |||
34 | TEST_START("misc_parse_user_ipv4_path"); | ||
35 | ASSERT_INT_EQ(parse_user_host_path("someuser@1.22.33.144:some/path", | ||
36 | &user, &host, &path), 0); | ||
37 | ASSERT_STRING_EQ(user, "someuser"); | ||
38 | ASSERT_STRING_EQ(host, "1.22.33.144"); | ||
39 | ASSERT_STRING_EQ(path, "some/path"); | ||
40 | free(user); free(host); free(path); | ||
41 | TEST_DONE(); | ||
42 | |||
43 | TEST_START("misc_parse_user_[ipv4]_path"); | ||
44 | ASSERT_INT_EQ(parse_user_host_path("someuser@[1.22.33.144]:some/path", | ||
45 | &user, &host, &path), 0); | ||
46 | ASSERT_STRING_EQ(user, "someuser"); | ||
47 | ASSERT_STRING_EQ(host, "1.22.33.144"); | ||
48 | ASSERT_STRING_EQ(path, "some/path"); | ||
49 | free(user); free(host); free(path); | ||
50 | TEST_DONE(); | ||
51 | |||
52 | TEST_START("misc_parse_user_[ipv4]_nopath"); | ||
53 | ASSERT_INT_EQ(parse_user_host_path("someuser@[1.22.33.144]:", | ||
54 | &user, &host, &path), 0); | ||
55 | ASSERT_STRING_EQ(user, "someuser"); | ||
56 | ASSERT_STRING_EQ(host, "1.22.33.144"); | ||
57 | ASSERT_STRING_EQ(path, "."); | ||
58 | free(user); free(host); free(path); | ||
59 | TEST_DONE(); | ||
60 | |||
61 | TEST_START("misc_parse_user_ipv6_path"); | ||
62 | ASSERT_INT_EQ(parse_user_host_path("someuser@[::1]:some/path", | ||
63 | &user, &host, &path), 0); | ||
64 | ASSERT_STRING_EQ(user, "someuser"); | ||
65 | ASSERT_STRING_EQ(host, "::1"); | ||
66 | ASSERT_STRING_EQ(path, "some/path"); | ||
67 | free(user); free(host); free(path); | ||
68 | TEST_DONE(); | ||
69 | |||
70 | TEST_START("misc_parse_uri"); | ||
71 | ASSERT_INT_EQ(parse_uri("ssh", "ssh://someuser@some.host:22/some/path", | ||
72 | &user, &host, &port, &path), 0); | ||
73 | ASSERT_STRING_EQ(user, "someuser"); | ||
74 | ASSERT_STRING_EQ(host, "some.host"); | ||
75 | ASSERT_INT_EQ(port, 22); | ||
76 | ASSERT_STRING_EQ(path, "some/path"); | ||
77 | free(user); free(host); free(path); | ||
78 | TEST_DONE(); | ||
79 | } | ||
diff --git a/regress/unittests/sshbuf/Makefile b/regress/unittests/sshbuf/Makefile index 0e8e9fd10..5f6c4426a 100644 --- a/regress/unittests/sshbuf/Makefile +++ b/regress/unittests/sshbuf/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # $OpenBSD: Makefile,v 1.7 2018/10/17 23:28:05 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.8 2020/01/26 00:09:50 djm Exp $ |
2 | 2 | ||
3 | .include <bsd.regress.mk> | 3 | # $OpenBSD: Makefile,v 1.8 2020/01/26 00:09:50 djm Exp $ |
4 | 4 | ||
5 | PROG=test_sshbuf | 5 | PROG=test_sshbuf |
6 | SRCS=tests.c | 6 | SRCS=tests.c |
@@ -14,7 +14,7 @@ SRCS+=test_sshbuf_fixed.c | |||
14 | 14 | ||
15 | # From usr.bin/ssh | 15 | # From usr.bin/ssh |
16 | SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c | 16 | SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c |
17 | SRCS+=atomicio.c | 17 | SRCS+=sshbuf-io.c atomicio.c misc.c xmalloc.c log.c fatal.c ssherr.c cleanup.c |
18 | 18 | ||
19 | run-regress-${PROG}: ${PROG} | 19 | run-regress-${PROG}: ${PROG} |
20 | env ${TEST_ENV} ./${PROG} ${UNITTEST_ARGS} | 20 | env ${TEST_ENV} ./${PROG} ${UNITTEST_ARGS} |
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); |