diff options
author | Curl Upstream <curl-library@lists.haxx.se> | 2022-05-11 06:11:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-05-16 15:43:24 (GMT) |
commit | 9d8f81f4f8ac4a234ced9c446958fdfcaed4faa3 (patch) | |
tree | 24a75f8e8a5f38c6d227189b3a76f4d35edb3dc0 /lib/vtls/x509asn1.c | |
parent | 2a9bc9ebf09fbafa5378d143083434204e9f233e (diff) | |
download | CMake-9d8f81f4f8ac4a234ced9c446958fdfcaed4faa3.zip CMake-9d8f81f4f8ac4a234ced9c446958fdfcaed4faa3.tar.gz CMake-9d8f81f4f8ac4a234ced9c446958fdfcaed4faa3.tar.bz2 |
curl 2022-05-11 (462196e6)
Code extracted from:
https://github.com/curl/curl.git
at commit 462196e6b4a47f924293a0e26b8e9c23d37ac26f (curl-7_83_1).
Diffstat (limited to 'lib/vtls/x509asn1.c')
-rw-r--r-- | lib/vtls/x509asn1.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index f64acb8..dfb9386 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -945,6 +945,24 @@ static int do_pubkey(struct Curl_easy *data, int certnum, /* Generate all information records for the public key. */ + if(strcasecompare(algo, "ecPublicKey")) { + /* + * ECC public key is all the data, a value of type BIT STRING mapped to + * OCTET STRING and should not be parsed as an ASN.1 value. + */ + const unsigned long len = + (unsigned long)((pubkey->end - pubkey->beg - 2) * 4); + if(!certnum) + infof(data, " ECC Public Key (%lu bits)", len); + if(data->set.ssl.certinfo) { + char q[sizeof(len) * 8 / 3 + 1]; + msnprintf(q, sizeof(q), "%lu", len); + if(Curl_ssl_push_certinfo(data, certnum, "ECC Public Key", q)) + return 1; + } + return do_pubkey_field(data, certnum, "ecPublicKey", pubkey); + } + /* Get the public key (single element). */ if(!getASN1Element(&pk, pubkey->beg + 1, pubkey->end)) return 1; @@ -971,14 +989,10 @@ static int do_pubkey(struct Curl_easy *data, int certnum, if(!certnum) infof(data, " RSA Public Key (%lu bits)", len); if(data->set.ssl.certinfo) { - q = curl_maprintf("%lu", len); - if(q) { - CURLcode result = - Curl_ssl_push_certinfo(data, certnum, "RSA Public Key", q); - free((char *) q); - if(result) - return 1; - } + char r[sizeof(len) * 8 / 3 + 1]; + msnprintf(r, sizeof(r), "%lu", len); + if(Curl_ssl_push_certinfo(data, certnum, "RSA Public Key", r)) + return 1; } /* Generate coefficients. */ if(do_pubkey_field(data, certnum, "rsa(n)", &elem)) |