summaryrefslogtreecommitdiff
path: root/regress/unittests/sshkey/common.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-09-13 09:03:20 +0000
committerDamien Miller <djm@mindrot.org>2018-09-13 19:04:10 +1000
commita3fd8074e2e2f06602e25618721f9556c731312c (patch)
tree133f60fc47fe37700c5fd6fbdfbfaf6fbe6a4715 /regress/unittests/sshkey/common.c
parent86e0a9f3d249d5580390daf58e015e68b01cef10 (diff)
upstream: missed a bit of openssl-1.0.x API in this unittest
OpenBSD-Regress-ID: a73a54d7f7381856a3f3a2d25947bee7a9a5dbc9
Diffstat (limited to 'regress/unittests/sshkey/common.c')
-rw-r--r--regress/unittests/sshkey/common.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c
index b598f05cb..548da6849 100644
--- a/regress/unittests/sshkey/common.c
+++ b/regress/unittests/sshkey/common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: common.c,v 1.2 2015/01/08 13:10:58 djm Exp $ */ 1/* $OpenBSD: common.c,v 1.3 2018/09/13 09:03:20 djm Exp $ */
2/* 2/*
3 * Helpers for key API tests 3 * Helpers for key API tests
4 * 4 *
@@ -82,3 +82,80 @@ load_bignum(const char *name)
82 return ret; 82 return ret;
83} 83}
84 84
85const BIGNUM *
86rsa_n(struct sshkey *k)
87{
88 const BIGNUM *n = NULL;
89
90 ASSERT_PTR_NE(k, NULL);
91 ASSERT_PTR_NE(k->rsa, NULL);
92 RSA_get0_key(k->rsa, &n, NULL, NULL);
93 return n;
94}
95
96const BIGNUM *
97rsa_e(struct sshkey *k)
98{
99 const BIGNUM *e = NULL;
100
101 ASSERT_PTR_NE(k, NULL);
102 ASSERT_PTR_NE(k->rsa, NULL);
103 RSA_get0_key(k->rsa, NULL, &e, NULL);
104 return e;
105}
106
107const BIGNUM *
108rsa_p(struct sshkey *k)
109{
110 const BIGNUM *p = NULL;
111
112 ASSERT_PTR_NE(k, NULL);
113 ASSERT_PTR_NE(k->rsa, NULL);
114 RSA_get0_factors(k->rsa, &p, NULL);
115 return p;
116}
117
118const BIGNUM *
119rsa_q(struct sshkey *k)
120{
121 const BIGNUM *q = NULL;
122
123 ASSERT_PTR_NE(k, NULL);
124 ASSERT_PTR_NE(k->rsa, NULL);
125 RSA_get0_factors(k->rsa, NULL, &q);
126 return q;
127}
128
129const BIGNUM *
130dsa_g(struct sshkey *k)
131{
132 const BIGNUM *g = NULL;
133
134 ASSERT_PTR_NE(k, NULL);
135 ASSERT_PTR_NE(k->dsa, NULL);
136 DSA_get0_pqg(k->dsa, NULL, NULL, &g);
137 return g;
138}
139
140const BIGNUM *
141dsa_pub_key(struct sshkey *k)
142{
143 const BIGNUM *pub_key = NULL;
144
145 ASSERT_PTR_NE(k, NULL);
146 ASSERT_PTR_NE(k->dsa, NULL);
147 DSA_get0_key(k->dsa, &pub_key, NULL);
148 return pub_key;
149}
150
151const BIGNUM *
152dsa_priv_key(struct sshkey *k)
153{
154 const BIGNUM *priv_key = NULL;
155
156 ASSERT_PTR_NE(k, NULL);
157 ASSERT_PTR_NE(k->dsa, NULL);
158 DSA_get0_key(k->dsa, NULL, &priv_key);
159 return priv_key;
160}
161