summaryrefslogtreecommitdiff
path: root/regress/unittests/sshkey/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/unittests/sshkey/common.c')
-rw-r--r--regress/unittests/sshkey/common.c81
1 files changed, 80 insertions, 1 deletions
diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c
index b598f05cb..e63465c47 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 *
@@ -27,6 +27,8 @@
27# include <openssl/ec.h> 27# include <openssl/ec.h>
28#endif 28#endif
29 29
30#include "openbsd-compat/openssl-compat.h"
31
30#include "../test_helper/test_helper.h" 32#include "../test_helper/test_helper.h"
31 33
32#include "ssherr.h" 34#include "ssherr.h"
@@ -82,3 +84,80 @@ load_bignum(const char *name)
82 return ret; 84 return ret;
83} 85}
84 86
87const BIGNUM *
88rsa_n(struct sshkey *k)
89{
90 const BIGNUM *n = NULL;
91
92 ASSERT_PTR_NE(k, NULL);
93 ASSERT_PTR_NE(k->rsa, NULL);
94 RSA_get0_key(k->rsa, &n, NULL, NULL);
95 return n;
96}
97
98const BIGNUM *
99rsa_e(struct sshkey *k)
100{
101 const BIGNUM *e = NULL;
102
103 ASSERT_PTR_NE(k, NULL);
104 ASSERT_PTR_NE(k->rsa, NULL);
105 RSA_get0_key(k->rsa, NULL, &e, NULL);
106 return e;
107}
108
109const BIGNUM *
110rsa_p(struct sshkey *k)
111{
112 const BIGNUM *p = NULL;
113
114 ASSERT_PTR_NE(k, NULL);
115 ASSERT_PTR_NE(k->rsa, NULL);
116 RSA_get0_factors(k->rsa, &p, NULL);
117 return p;
118}
119
120const BIGNUM *
121rsa_q(struct sshkey *k)
122{
123 const BIGNUM *q = NULL;
124
125 ASSERT_PTR_NE(k, NULL);
126 ASSERT_PTR_NE(k->rsa, NULL);
127 RSA_get0_factors(k->rsa, NULL, &q);
128 return q;
129}
130
131const BIGNUM *
132dsa_g(struct sshkey *k)
133{
134 const BIGNUM *g = NULL;
135
136 ASSERT_PTR_NE(k, NULL);
137 ASSERT_PTR_NE(k->dsa, NULL);
138 DSA_get0_pqg(k->dsa, NULL, NULL, &g);
139 return g;
140}
141
142const BIGNUM *
143dsa_pub_key(struct sshkey *k)
144{
145 const BIGNUM *pub_key = NULL;
146
147 ASSERT_PTR_NE(k, NULL);
148 ASSERT_PTR_NE(k->dsa, NULL);
149 DSA_get0_key(k->dsa, &pub_key, NULL);
150 return pub_key;
151}
152
153const BIGNUM *
154dsa_priv_key(struct sshkey *k)
155{
156 const BIGNUM *priv_key = NULL;
157
158 ASSERT_PTR_NE(k, NULL);
159 ASSERT_PTR_NE(k->dsa, NULL);
160 DSA_get0_key(k->dsa, NULL, &priv_key);
161 return priv_key;
162}
163