diff options
author | David Benjamin <davidben@chromium.org> | 2016-01-28 10:58:06 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2016-02-17 02:54:38 +0300 |
commit | 3cadf63c68c26c2f5df2f6f2a1358db4772f0163 (patch) | |
tree | 0abcfdaece1851181e971b532845a68ca91ede7e /crypto/evp | |
parent | 985da09340a79cc35b26123e9b44870ab5dcc12f (diff) |
Remove DSA write_params.
This imports upstream's ea6b07b54c1f8fc2275a121cdda071e2df7bd6c1 along
with a bugfix in 987157f6f63fa70dbeffca3c8bc62f26e9767ff2.
In an SPKI, a DSA key is only an INTEGER, with the group information in
the AlgorithmIdentifier. But a standalone DSAPublicKey is more complex
(and apparently made up by OpenSSL). OpenSSL implemented this with a
write_params boolean and making DSAPublicKey a CHOICE.
Instead, have p_dsa_asn1.c encode an INTEGER directly. d2i_DSAPublicKey
only parses the standalone form. (That code will be replaced later, but
first do this in preparation for rewriting the DSA ASN.1 code.)
Change-Id: I6fbe298d2723b9816806e9c196c724359b9ffd63
Reviewed-on: https://boringssl-review.googlesource.com/7021
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/p_dsa_asn1.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/evp/p_dsa_asn1.c b/crypto/evp/p_dsa_asn1.c index a876eef4..bb68d20e 100644 --- a/crypto/evp/p_dsa_asn1.c +++ b/crypto/evp/p_dsa_asn1.c @@ -134,7 +134,6 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { int penclen; dsa = pkey->pkey.dsa; - dsa->write_params = 0; int ptype; if (dsa->p && dsa->q && dsa->g) { @@ -153,7 +152,14 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { ptype = V_ASN1_UNDEF; } - penclen = i2d_DSAPublicKey(dsa, &penc); + ASN1_INTEGER *pubint = BN_to_ASN1_INTEGER(dsa->pub_key, NULL); + if (pubint == NULL) { + goto err; + } + + penclen = i2d_ASN1_INTEGER(pubint, &penc); + ASN1_INTEGER_free(pubint); + if (penclen <= 0) { OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE); goto err; |