upstream: missed a bit of openssl-1.0.x API in this unittest
OpenBSD-Regress-ID: a73a54d7f7381856a3f3a2d25947bee7a9a5dbc9
This commit is contained in:
parent
86e0a9f3d2
commit
a3fd8074e2
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: common.c,v 1.2 2015/01/08 13:10:58 djm Exp $ */
|
/* $OpenBSD: common.c,v 1.3 2018/09/13 09:03:20 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Helpers for key API tests
|
* Helpers for key API tests
|
||||||
*
|
*
|
||||||
|
@ -82,3 +82,80 @@ load_bignum(const char *name)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
rsa_n(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *n = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->rsa, NULL);
|
||||||
|
RSA_get0_key(k->rsa, &n, NULL, NULL);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
rsa_e(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *e = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->rsa, NULL);
|
||||||
|
RSA_get0_key(k->rsa, NULL, &e, NULL);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
rsa_p(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *p = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->rsa, NULL);
|
||||||
|
RSA_get0_factors(k->rsa, &p, NULL);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
rsa_q(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *q = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->rsa, NULL);
|
||||||
|
RSA_get0_factors(k->rsa, NULL, &q);
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
dsa_g(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *g = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->dsa, NULL);
|
||||||
|
DSA_get0_pqg(k->dsa, NULL, NULL, &g);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
dsa_pub_key(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *pub_key = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->dsa, NULL);
|
||||||
|
DSA_get0_key(k->dsa, &pub_key, NULL);
|
||||||
|
return pub_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BIGNUM *
|
||||||
|
dsa_priv_key(struct sshkey *k)
|
||||||
|
{
|
||||||
|
const BIGNUM *priv_key = NULL;
|
||||||
|
|
||||||
|
ASSERT_PTR_NE(k, NULL);
|
||||||
|
ASSERT_PTR_NE(k->dsa, NULL);
|
||||||
|
DSA_get0_key(k->dsa, NULL, &priv_key);
|
||||||
|
return priv_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: common.h,v 1.1 2014/06/24 01:14:18 djm Exp $ */
|
/* $OpenBSD: common.h,v 1.2 2018/09/13 09:03:20 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Helpers for key API tests
|
* Helpers for key API tests
|
||||||
*
|
*
|
||||||
|
@ -14,3 +14,12 @@ struct sshbuf *load_text_file(const char *name);
|
||||||
/* Load a bignum from a file */
|
/* Load a bignum from a file */
|
||||||
BIGNUM *load_bignum(const char *name);
|
BIGNUM *load_bignum(const char *name);
|
||||||
|
|
||||||
|
/* Accessors for key components */
|
||||||
|
const BIGNUM *rsa_n(struct sshkey *k);
|
||||||
|
const BIGNUM *rsa_e(struct sshkey *k);
|
||||||
|
const BIGNUM *rsa_p(struct sshkey *k);
|
||||||
|
const BIGNUM *rsa_q(struct sshkey *k);
|
||||||
|
const BIGNUM *dsa_g(struct sshkey *k);
|
||||||
|
const BIGNUM *dsa_pub_key(struct sshkey *k);
|
||||||
|
const BIGNUM *dsa_priv_key(struct sshkey *k);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: test_file.c,v 1.7 2018/09/12 01:36:45 djm Exp $ */
|
/* $OpenBSD: test_file.c,v 1.8 2018/09/13 09:03:20 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Regress test for sshkey.h key management API
|
* Regress test for sshkey.h key management API
|
||||||
*
|
*
|
||||||
|
@ -60,9 +60,9 @@ sshkey_file_tests(void)
|
||||||
a = load_bignum("rsa_1.param.n");
|
a = load_bignum("rsa_1.param.n");
|
||||||
b = load_bignum("rsa_1.param.p");
|
b = load_bignum("rsa_1.param.p");
|
||||||
c = load_bignum("rsa_1.param.q");
|
c = load_bignum("rsa_1.param.q");
|
||||||
ASSERT_BIGNUM_EQ(k1->rsa->n, a);
|
ASSERT_BIGNUM_EQ(rsa_n(k1), a);
|
||||||
ASSERT_BIGNUM_EQ(k1->rsa->p, b);
|
ASSERT_BIGNUM_EQ(rsa_p(k1), b);
|
||||||
ASSERT_BIGNUM_EQ(k1->rsa->q, c);
|
ASSERT_BIGNUM_EQ(rsa_q(k1), c);
|
||||||
BN_free(a);
|
BN_free(a);
|
||||||
BN_free(b);
|
BN_free(b);
|
||||||
BN_free(c);
|
BN_free(c);
|
||||||
|
@ -169,9 +169,9 @@ sshkey_file_tests(void)
|
||||||
a = load_bignum("dsa_1.param.g");
|
a = load_bignum("dsa_1.param.g");
|
||||||
b = load_bignum("dsa_1.param.priv");
|
b = load_bignum("dsa_1.param.priv");
|
||||||
c = load_bignum("dsa_1.param.pub");
|
c = load_bignum("dsa_1.param.pub");
|
||||||
ASSERT_BIGNUM_EQ(k1->dsa->g, a);
|
ASSERT_BIGNUM_EQ(dsa_g(k1), a);
|
||||||
ASSERT_BIGNUM_EQ(k1->dsa->priv_key, b);
|
ASSERT_BIGNUM_EQ(dsa_priv_key(k1), b);
|
||||||
ASSERT_BIGNUM_EQ(k1->dsa->pub_key, c);
|
ASSERT_BIGNUM_EQ(dsa_pub_key(k1), c);
|
||||||
BN_free(a);
|
BN_free(a);
|
||||||
BN_free(b);
|
BN_free(b);
|
||||||
BN_free(c);
|
BN_free(c);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: test_sshkey.c,v 1.16 2018/09/13 05:06:51 djm Exp $ */
|
/* $OpenBSD: test_sshkey.c,v 1.17 2018/09/13 09:03:20 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Regress test for sshkey.h key management API
|
* Regress test for sshkey.h key management API
|
||||||
*
|
*
|
||||||
|
@ -173,61 +173,6 @@ get_private(const char *n)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const BIGNUM *
|
|
||||||
rsa_n(struct sshkey *k)
|
|
||||||
{
|
|
||||||
const BIGNUM *n = NULL;
|
|
||||||
|
|
||||||
ASSERT_PTR_NE(k, NULL);
|
|
||||||
ASSERT_PTR_NE(k->rsa, NULL);
|
|
||||||
RSA_get0_key(k->rsa, &n, NULL, NULL);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const BIGNUM *
|
|
||||||
rsa_e(struct sshkey *k)
|
|
||||||
{
|
|
||||||
const BIGNUM *e = NULL;
|
|
||||||
|
|
||||||
ASSERT_PTR_NE(k, NULL);
|
|
||||||
ASSERT_PTR_NE(k->rsa, NULL);
|
|
||||||
RSA_get0_key(k->rsa, NULL, &e, NULL);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const BIGNUM *
|
|
||||||
rsa_p(struct sshkey *k)
|
|
||||||
{
|
|
||||||
const BIGNUM *p = NULL;
|
|
||||||
|
|
||||||
ASSERT_PTR_NE(k, NULL);
|
|
||||||
ASSERT_PTR_NE(k->rsa, NULL);
|
|
||||||
RSA_get0_factors(k->rsa, &p, NULL);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const BIGNUM *
|
|
||||||
dsa_g(struct sshkey *k)
|
|
||||||
{
|
|
||||||
const BIGNUM *g = NULL;
|
|
||||||
|
|
||||||
ASSERT_PTR_NE(k, NULL);
|
|
||||||
ASSERT_PTR_NE(k->dsa, NULL);
|
|
||||||
DSA_get0_pqg(k->dsa, NULL, NULL, &g);
|
|
||||||
return g;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const BIGNUM *
|
|
||||||
dsa_priv_key(struct sshkey *k)
|
|
||||||
{
|
|
||||||
const BIGNUM *priv_key = NULL;
|
|
||||||
|
|
||||||
ASSERT_PTR_NE(k, NULL);
|
|
||||||
ASSERT_PTR_NE(k->dsa, NULL);
|
|
||||||
DSA_get0_key(k->dsa, NULL, &priv_key);
|
|
||||||
return priv_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sshkey_tests(void)
|
sshkey_tests(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue