dsa_pub_encode: Write out DSA parameters (p, q, g) in addition to key.
Change-Id: Id5ea49fc43aacfd1d348b2a230c9745484bed852 Reviewed-on: https://boringssl-review.googlesource.com/5174 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
c618c402a5
commit
e65886a520
@ -129,21 +129,37 @@ err:
|
|||||||
|
|
||||||
static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) {
|
static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) {
|
||||||
DSA *dsa;
|
DSA *dsa;
|
||||||
void *pval = NULL;
|
ASN1_STRING *pval = NULL;
|
||||||
uint8_t *penc = NULL;
|
uint8_t *penc = NULL;
|
||||||
int penclen;
|
int penclen;
|
||||||
|
|
||||||
dsa = pkey->pkey.dsa;
|
dsa = pkey->pkey.dsa;
|
||||||
dsa->write_params = 0;
|
dsa->write_params = 0;
|
||||||
|
|
||||||
penclen = i2d_DSAPublicKey(dsa, &penc);
|
int ptype;
|
||||||
|
if (dsa->p && dsa->q && dsa->g) {
|
||||||
|
pval = ASN1_STRING_new();
|
||||||
|
if (!pval) {
|
||||||
|
OPENSSL_PUT_ERROR(EVP, dsa_pub_encode, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
pval->length = i2d_DSAparams(dsa, &pval->data);
|
||||||
|
if (pval->length <= 0) {
|
||||||
|
OPENSSL_PUT_ERROR(EVP, dsa_pub_encode, ERR_R_MALLOC_FAILURE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
ptype = V_ASN1_SEQUENCE;
|
||||||
|
} else {
|
||||||
|
ptype = V_ASN1_UNDEF;
|
||||||
|
}
|
||||||
|
|
||||||
|
penclen = i2d_DSAPublicKey(dsa, &penc);
|
||||||
if (penclen <= 0) {
|
if (penclen <= 0) {
|
||||||
OPENSSL_PUT_ERROR(EVP, dsa_pub_encode, ERR_R_MALLOC_FAILURE);
|
OPENSSL_PUT_ERROR(EVP, dsa_pub_encode, ERR_R_MALLOC_FAILURE);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA), V_ASN1_UNDEF, pval,
|
if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA), ptype, pval,
|
||||||
penc, penclen)) {
|
penc, penclen)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user