summaryrefslogtreecommitdiff
path: root/regress/unittests/sshkey/test_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/unittests/sshkey/test_file.c')
-rw-r--r--regress/unittests/sshkey/test_file.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/regress/unittests/sshkey/test_file.c b/regress/unittests/sshkey/test_file.c
index 99b7e21c0..65610dacc 100644
--- a/regress/unittests/sshkey/test_file.c
+++ b/regress/unittests/sshkey/test_file.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: test_file.c,v 1.6 2017/04/30 23:33:48 djm Exp $ */ 1/* $OpenBSD: test_file.c,v 1.8 2018/09/13 09:03:20 djm Exp $ */
2/* 2/*
3 * Regress test for sshkey.h key management API 3 * Regress test for sshkey.h key management API
4 * 4 *
@@ -60,9 +60,9 @@ sshkey_file_tests(void)
60 a = load_bignum("rsa_1.param.n"); 60 a = load_bignum("rsa_1.param.n");
61 b = load_bignum("rsa_1.param.p"); 61 b = load_bignum("rsa_1.param.p");
62 c = load_bignum("rsa_1.param.q"); 62 c = load_bignum("rsa_1.param.q");
63 ASSERT_BIGNUM_EQ(k1->rsa->n, a); 63 ASSERT_BIGNUM_EQ(rsa_n(k1), a);
64 ASSERT_BIGNUM_EQ(k1->rsa->p, b); 64 ASSERT_BIGNUM_EQ(rsa_p(k1), b);
65 ASSERT_BIGNUM_EQ(k1->rsa->q, c); 65 ASSERT_BIGNUM_EQ(rsa_q(k1), c);
66 BN_free(a); 66 BN_free(a);
67 BN_free(b); 67 BN_free(b);
68 BN_free(c); 68 BN_free(c);
@@ -105,6 +105,24 @@ sshkey_file_tests(void)
105 sshkey_free(k2); 105 sshkey_free(k2);
106 TEST_DONE(); 106 TEST_DONE();
107 107
108 TEST_START("load RSA cert with SHA1 signature");
109 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha1"), &k2), 0);
110 ASSERT_PTR_NE(k2, NULL);
111 ASSERT_INT_EQ(k2->type, KEY_RSA_CERT);
112 ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
113 ASSERT_STRING_EQ(k2->cert->signature_type, "ssh-rsa");
114 sshkey_free(k2);
115 TEST_DONE();
116
117 TEST_START("load RSA cert with SHA512 signature");
118 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1_sha512"), &k2), 0);
119 ASSERT_PTR_NE(k2, NULL);
120 ASSERT_INT_EQ(k2->type, KEY_RSA_CERT);
121 ASSERT_INT_EQ(sshkey_equal_public(k1, k2), 1);
122 ASSERT_STRING_EQ(k2->cert->signature_type, "rsa-sha2-512");
123 sshkey_free(k2);
124 TEST_DONE();
125
108 TEST_START("load RSA cert"); 126 TEST_START("load RSA cert");
109 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k2), 0); 127 ASSERT_INT_EQ(sshkey_load_cert(test_data_file("rsa_1"), &k2), 0);
110 ASSERT_PTR_NE(k2, NULL); 128 ASSERT_PTR_NE(k2, NULL);
@@ -151,9 +169,9 @@ sshkey_file_tests(void)
151 a = load_bignum("dsa_1.param.g"); 169 a = load_bignum("dsa_1.param.g");
152 b = load_bignum("dsa_1.param.priv"); 170 b = load_bignum("dsa_1.param.priv");
153 c = load_bignum("dsa_1.param.pub"); 171 c = load_bignum("dsa_1.param.pub");
154 ASSERT_BIGNUM_EQ(k1->dsa->g, a); 172 ASSERT_BIGNUM_EQ(dsa_g(k1), a);
155 ASSERT_BIGNUM_EQ(k1->dsa->priv_key, b); 173 ASSERT_BIGNUM_EQ(dsa_priv_key(k1), b);
156 ASSERT_BIGNUM_EQ(k1->dsa->pub_key, c); 174 ASSERT_BIGNUM_EQ(dsa_pub_key(k1), c);
157 BN_free(a); 175 BN_free(a);
158 BN_free(b); 176 BN_free(b);
159 BN_free(c); 177 BN_free(c);