Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 2 | * All rights reserved. |
| 3 | * |
| 4 | * This package is an SSL implementation written |
| 5 | * by Eric Young (eay@cryptsoft.com). |
| 6 | * The implementation was written so as to conform with Netscapes SSL. |
| 7 | * |
| 8 | * This library is free for commercial and non-commercial use as long as |
| 9 | * the following conditions are aheared to. The following conditions |
| 10 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 11 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 12 | * included with this distribution is covered by the same copyright terms |
| 13 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 14 | * |
| 15 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 16 | * the code are not to be removed. |
| 17 | * If this package is used in a product, Eric Young should be given attribution |
| 18 | * as the author of the parts of the library used. |
| 19 | * This can be in the form of a textual message at program startup or |
| 20 | * in documentation (online or textual) provided with the package. |
| 21 | * |
| 22 | * Redistribution and use in source and binary forms, with or without |
| 23 | * modification, are permitted provided that the following conditions |
| 24 | * are met: |
| 25 | * 1. Redistributions of source code must retain the copyright |
| 26 | * notice, this list of conditions and the following disclaimer. |
| 27 | * 2. Redistributions in binary form must reproduce the above copyright |
| 28 | * notice, this list of conditions and the following disclaimer in the |
| 29 | * documentation and/or other materials provided with the distribution. |
| 30 | * 3. All advertising materials mentioning features or use of this software |
| 31 | * must display the following acknowledgement: |
| 32 | * "This product includes cryptographic software written by |
| 33 | * Eric Young (eay@cryptsoft.com)" |
| 34 | * The word 'cryptographic' can be left out if the rouines from the library |
| 35 | * being used are not cryptographic related :-). |
| 36 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 37 | * the apps directory (application code) you must include an acknowledgement: |
| 38 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 39 | * |
| 40 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 41 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 43 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 44 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 45 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 46 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 48 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 49 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 50 | * SUCH DAMAGE. |
| 51 | * |
| 52 | * The licence and distribution terms for any publically available version or |
| 53 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 54 | * copied and put under another distribution licence |
| 55 | * [including the GNU Public Licence.] */ |
| 56 | |
David Benjamin | 443a1f6 | 2015-09-04 15:05:05 -0400 | [diff] [blame] | 57 | #include <openssl/ssl.h> |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 58 | |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 59 | #include <assert.h> |
David Benjamin | 3a59611 | 2015-11-12 09:25:30 -0800 | [diff] [blame] | 60 | #include <limits.h> |
| 61 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 62 | #include <openssl/ec.h> |
| 63 | #include <openssl/ec_key.h> |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 64 | #include <openssl/err.h> |
| 65 | #include <openssl/evp.h> |
| 66 | #include <openssl/mem.h> |
David Benjamin | a972b78 | 2023-05-05 10:22:43 -0400 | [diff] [blame] | 67 | #include <openssl/span.h> |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 68 | |
David Benjamin | 2ee94aa | 2015-04-07 22:38:30 -0400 | [diff] [blame] | 69 | #include "internal.h" |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 70 | #include "../crypto/internal.h" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 71 | |
David Benjamin | 443a1f6 | 2015-09-04 15:05:05 -0400 | [diff] [blame] | 72 | |
Joshua Liebow-Feeser | 8c7c635 | 2018-08-26 18:53:36 -0700 | [diff] [blame] | 73 | BSSL_NAMESPACE_BEGIN |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 74 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 75 | bool ssl_is_key_type_supported(int key_type) { |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 76 | return key_type == EVP_PKEY_RSA || key_type == EVP_PKEY_EC || |
| 77 | key_type == EVP_PKEY_ED25519; |
David Benjamin | d1d8078 | 2015-07-05 11:54:09 -0400 | [diff] [blame] | 78 | } |
| 79 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 80 | static bool ssl_set_pkey(CERT *cert, EVP_PKEY *pkey) { |
David Benjamin | 890c201 | 2023-02-08 15:24:47 -0500 | [diff] [blame] | 81 | if (!ssl_is_key_type_supported(EVP_PKEY_id(pkey))) { |
Adam Langley | 52940c4 | 2017-02-01 12:40:31 -0800 | [diff] [blame] | 82 | OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CERTIFICATE_TYPE); |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 83 | return false; |
Adam Langley | fcf2583 | 2014-12-18 17:42:32 -0800 | [diff] [blame] | 84 | } |
| 85 | |
David Benjamin | e325c3f | 2018-04-12 16:11:15 -0400 | [diff] [blame] | 86 | if (cert->chain != nullptr && |
| 87 | sk_CRYPTO_BUFFER_value(cert->chain.get(), 0) != nullptr && |
David Benjamin | c11ea942 | 2017-08-29 16:33:21 -0400 | [diff] [blame] | 88 | // Sanity-check that the private key and the certificate match. |
Adam Langley | 52940c4 | 2017-02-01 12:40:31 -0800 | [diff] [blame] | 89 | !ssl_cert_check_private_key(cert, pkey)) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 90 | return false; |
Adam Langley | 52940c4 | 2017-02-01 12:40:31 -0800 | [diff] [blame] | 91 | } |
| 92 | |
David Benjamin | 2908dd1 | 2018-06-29 17:46:42 -0400 | [diff] [blame] | 93 | cert->privatekey = UpRef(pkey); |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 94 | return true; |
Adam Langley | fcf2583 | 2014-12-18 17:42:32 -0800 | [diff] [blame] | 95 | } |
| 96 | |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 97 | typedef struct { |
| 98 | uint16_t sigalg; |
| 99 | int pkey_type; |
| 100 | int curve; |
| 101 | const EVP_MD *(*digest_func)(void); |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 102 | bool is_rsa_pss; |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 103 | } SSL_SIGNATURE_ALGORITHM; |
| 104 | |
| 105 | static const SSL_SIGNATURE_ALGORITHM kSignatureAlgorithms[] = { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 106 | {SSL_SIGN_RSA_PKCS1_MD5_SHA1, EVP_PKEY_RSA, NID_undef, &EVP_md5_sha1, |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 107 | false}, |
| 108 | {SSL_SIGN_RSA_PKCS1_SHA1, EVP_PKEY_RSA, NID_undef, &EVP_sha1, false}, |
| 109 | {SSL_SIGN_RSA_PKCS1_SHA256, EVP_PKEY_RSA, NID_undef, &EVP_sha256, false}, |
| 110 | {SSL_SIGN_RSA_PKCS1_SHA384, EVP_PKEY_RSA, NID_undef, &EVP_sha384, false}, |
| 111 | {SSL_SIGN_RSA_PKCS1_SHA512, EVP_PKEY_RSA, NID_undef, &EVP_sha512, false}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 112 | |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 113 | {SSL_SIGN_RSA_PSS_RSAE_SHA256, EVP_PKEY_RSA, NID_undef, &EVP_sha256, true}, |
| 114 | {SSL_SIGN_RSA_PSS_RSAE_SHA384, EVP_PKEY_RSA, NID_undef, &EVP_sha384, true}, |
| 115 | {SSL_SIGN_RSA_PSS_RSAE_SHA512, EVP_PKEY_RSA, NID_undef, &EVP_sha512, true}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 116 | |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 117 | {SSL_SIGN_ECDSA_SHA1, EVP_PKEY_EC, NID_undef, &EVP_sha1, false}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 118 | {SSL_SIGN_ECDSA_SECP256R1_SHA256, EVP_PKEY_EC, NID_X9_62_prime256v1, |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 119 | &EVP_sha256, false}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 120 | {SSL_SIGN_ECDSA_SECP384R1_SHA384, EVP_PKEY_EC, NID_secp384r1, &EVP_sha384, |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 121 | false}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 122 | {SSL_SIGN_ECDSA_SECP521R1_SHA512, EVP_PKEY_EC, NID_secp521r1, &EVP_sha512, |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 123 | false}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 124 | |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 125 | {SSL_SIGN_ED25519, EVP_PKEY_ED25519, NID_undef, nullptr, false}, |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | static const SSL_SIGNATURE_ALGORITHM *get_signature_algorithm(uint16_t sigalg) { |
| 129 | for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kSignatureAlgorithms); i++) { |
| 130 | if (kSignatureAlgorithms[i].sigalg == sigalg) { |
| 131 | return &kSignatureAlgorithms[i]; |
| 132 | } |
| 133 | } |
| 134 | return NULL; |
| 135 | } |
| 136 | |
Christopher Patton | 9cde848 | 2018-07-17 11:36:36 -0700 | [diff] [blame] | 137 | bool ssl_has_private_key(const SSL_HANDSHAKE *hs) { |
Christopher Patton | 6c1b376 | 2018-07-17 12:49:41 -0700 | [diff] [blame] | 138 | if (hs->config->cert->privatekey != nullptr || |
| 139 | hs->config->cert->key_method != nullptr || |
| 140 | ssl_signing_with_dc(hs)) { |
| 141 | return true; |
| 142 | } |
| 143 | |
| 144 | return false; |
nagendra modadugu | 601448a | 2015-07-24 09:31:31 -0700 | [diff] [blame] | 145 | } |
| 146 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 147 | static bool pkey_supports_algorithm(const SSL *ssl, EVP_PKEY *pkey, |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 148 | uint16_t sigalg) { |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 149 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
| 150 | if (alg == NULL || |
| 151 | EVP_PKEY_id(pkey) != alg->pkey_type) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 152 | return false; |
David Benjamin | d246b81 | 2016-07-08 15:07:02 -0700 | [diff] [blame] | 153 | } |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 154 | |
David Benjamin | e8f57ca | 2022-11-29 18:40:11 -0500 | [diff] [blame] | 155 | if (ssl_protocol_version(ssl) < TLS1_2_VERSION) { |
| 156 | // TLS 1.0 and 1.1 do not negotiate algorithms and always sign one of two |
| 157 | // hardcoded algorithms. |
| 158 | return sigalg == SSL_SIGN_RSA_PKCS1_MD5_SHA1 || |
| 159 | sigalg == SSL_SIGN_ECDSA_SHA1; |
| 160 | } |
| 161 | |
| 162 | // |SSL_SIGN_RSA_PKCS1_MD5_SHA1| is not a real SignatureScheme for TLS 1.2 and |
| 163 | // higher. It is an internal value we use to represent TLS 1.0/1.1's MD5/SHA1 |
| 164 | // concatenation. |
| 165 | if (sigalg == SSL_SIGN_RSA_PKCS1_MD5_SHA1) { |
| 166 | return false; |
| 167 | } |
| 168 | |
David Benjamin | d1e3ce1 | 2017-10-06 18:31:15 -0400 | [diff] [blame] | 169 | if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) { |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 170 | // RSA keys may only be used with RSA-PSS. |
| 171 | if (alg->pkey_type == EVP_PKEY_RSA && !alg->is_rsa_pss) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 172 | return false; |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 173 | } |
| 174 | |
David Benjamin | c11ea942 | 2017-08-29 16:33:21 -0400 | [diff] [blame] | 175 | // EC keys have a curve requirement. |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 176 | if (alg->pkey_type == EVP_PKEY_EC && |
| 177 | (alg->curve == NID_undef || |
| 178 | EC_GROUP_get_curve_name( |
| 179 | EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pkey))) != alg->curve)) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 180 | return false; |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 184 | return true; |
David Benjamin | d246b81 | 2016-07-08 15:07:02 -0700 | [diff] [blame] | 185 | } |
| 186 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 187 | static bool setup_ctx(SSL *ssl, EVP_MD_CTX *ctx, EVP_PKEY *pkey, |
| 188 | uint16_t sigalg, bool is_verify) { |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 189 | if (!pkey_supports_algorithm(ssl, pkey, sigalg)) { |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 190 | OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SIGNATURE_TYPE); |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 191 | return false; |
David Benjamin | 887c300 | 2016-07-08 16:15:32 -0700 | [diff] [blame] | 192 | } |
David Benjamin | a2d81f1 | 2016-07-08 15:42:16 -0700 | [diff] [blame] | 193 | |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 194 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
David Benjamin | 1967094 | 2017-05-31 19:07:31 -0400 | [diff] [blame] | 195 | const EVP_MD *digest = alg->digest_func != NULL ? alg->digest_func() : NULL; |
| 196 | EVP_PKEY_CTX *pctx; |
| 197 | if (is_verify) { |
| 198 | if (!EVP_DigestVerifyInit(ctx, &pctx, digest, NULL, pkey)) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 199 | return false; |
David Benjamin | 1967094 | 2017-05-31 19:07:31 -0400 | [diff] [blame] | 200 | } |
| 201 | } else if (!EVP_DigestSignInit(ctx, &pctx, digest, NULL, pkey)) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 202 | return false; |
David Benjamin | a2d81f1 | 2016-07-08 15:42:16 -0700 | [diff] [blame] | 203 | } |
David Benjamin | a2d81f1 | 2016-07-08 15:42:16 -0700 | [diff] [blame] | 204 | |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 205 | if (alg->is_rsa_pss) { |
David Benjamin | 1967094 | 2017-05-31 19:07:31 -0400 | [diff] [blame] | 206 | if (!EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) || |
| 207 | !EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1 /* salt len = hash len */)) { |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 208 | return false; |
David Benjamin | 76feb1f | 2017-03-28 14:17:01 -0500 | [diff] [blame] | 209 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 210 | } |
| 211 | |
David Benjamin | 8525ff3 | 2018-09-05 18:44:15 -0500 | [diff] [blame] | 212 | return true; |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 213 | } |
| 214 | |
David Benjamin | b4d65fd | 2015-05-29 17:11:21 -0400 | [diff] [blame] | 215 | enum ssl_private_key_result_t ssl_private_key_sign( |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 216 | SSL_HANDSHAKE *hs, uint8_t *out, size_t *out_len, size_t max_out, |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 217 | uint16_t sigalg, Span<const uint8_t> in) { |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 218 | SSL *const ssl = hs->ssl; |
David Benjamin | 4a6c8fd | 2022-07-21 14:05:41 -0700 | [diff] [blame] | 219 | SSL_HANDSHAKE_HINTS *const hints = hs->hints.get(); |
| 220 | Array<uint8_t> spki; |
| 221 | if (hints) { |
| 222 | ScopedCBB spki_cbb; |
| 223 | if (!CBB_init(spki_cbb.get(), 64) || |
| 224 | !EVP_marshal_public_key(spki_cbb.get(), hs->local_pubkey.get()) || |
| 225 | !CBBFinishArray(spki_cbb.get(), &spki)) { |
| 226 | ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); |
| 227 | return ssl_private_key_failure; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | // Replay the signature from handshake hints if available. |
| 232 | if (hints && !hs->hints_requested && // |
| 233 | sigalg == hints->signature_algorithm && // |
| 234 | in == hints->signature_input && |
| 235 | MakeConstSpan(spki) == hints->signature_spki && |
| 236 | !hints->signature.empty() && // |
| 237 | hints->signature.size() <= max_out) { |
| 238 | // Signature algorithm and input both match. Reuse the signature from hints. |
| 239 | *out_len = hints->signature.size(); |
| 240 | OPENSSL_memcpy(out, hints->signature.data(), hints->signature.size()); |
| 241 | return ssl_private_key_success; |
| 242 | } |
| 243 | |
Christopher Patton | 6c1b376 | 2018-07-17 12:49:41 -0700 | [diff] [blame] | 244 | const SSL_PRIVATE_KEY_METHOD *key_method = hs->config->cert->key_method; |
| 245 | EVP_PKEY *privatekey = hs->config->cert->privatekey.get(); |
David Benjamin | 9b2cdb7 | 2021-04-01 23:21:53 -0400 | [diff] [blame] | 246 | assert(!hs->can_release_private_key); |
Christopher Patton | 6c1b376 | 2018-07-17 12:49:41 -0700 | [diff] [blame] | 247 | if (ssl_signing_with_dc(hs)) { |
| 248 | key_method = hs->config->cert->dc_key_method; |
| 249 | privatekey = hs->config->cert->dc_privatekey.get(); |
| 250 | } |
| 251 | |
| 252 | if (key_method != NULL) { |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 253 | enum ssl_private_key_result_t ret; |
| 254 | if (hs->pending_private_key_op) { |
Christopher Patton | 6c1b376 | 2018-07-17 12:49:41 -0700 | [diff] [blame] | 255 | ret = key_method->complete(ssl, out, out_len, max_out); |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 256 | } else { |
David Benjamin | 4a6c8fd | 2022-07-21 14:05:41 -0700 | [diff] [blame] | 257 | ret = key_method->sign(ssl, out, out_len, max_out, sigalg, in.data(), |
| 258 | in.size()); |
David Benjamin | d3440b4 | 2016-07-14 14:52:41 -0400 | [diff] [blame] | 259 | } |
David Benjamin | fa65113 | 2018-02-01 15:07:30 -0500 | [diff] [blame] | 260 | if (ret == ssl_private_key_failure) { |
| 261 | OPENSSL_PUT_ERROR(SSL, SSL_R_PRIVATE_KEY_OPERATION_FAILED); |
| 262 | } |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 263 | hs->pending_private_key_op = ret == ssl_private_key_retry; |
David Benjamin | 4a6c8fd | 2022-07-21 14:05:41 -0700 | [diff] [blame] | 264 | if (ret != ssl_private_key_success) { |
| 265 | return ret; |
| 266 | } |
| 267 | } else { |
| 268 | *out_len = max_out; |
| 269 | ScopedEVP_MD_CTX ctx; |
| 270 | if (!setup_ctx(ssl, ctx.get(), privatekey, sigalg, false /* sign */) || |
| 271 | !EVP_DigestSign(ctx.get(), out, out_len, in.data(), in.size())) { |
| 272 | return ssl_private_key_failure; |
| 273 | } |
David Benjamin | b4d65fd | 2015-05-29 17:11:21 -0400 | [diff] [blame] | 274 | } |
| 275 | |
David Benjamin | 4a6c8fd | 2022-07-21 14:05:41 -0700 | [diff] [blame] | 276 | // Save the hint if applicable. |
| 277 | if (hints && hs->hints_requested) { |
| 278 | hints->signature_algorithm = sigalg; |
| 279 | hints->signature_spki = std::move(spki); |
| 280 | if (!hints->signature_input.CopyFrom(in) || |
| 281 | !hints->signature.CopyFrom(MakeConstSpan(out, *out_len))) { |
| 282 | return ssl_private_key_failure; |
| 283 | } |
David Benjamin | 1386aad | 2017-07-19 23:57:40 -0400 | [diff] [blame] | 284 | } |
| 285 | return ssl_private_key_success; |
David Benjamin | b4d65fd | 2015-05-29 17:11:21 -0400 | [diff] [blame] | 286 | } |
| 287 | |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 288 | bool ssl_public_key_verify(SSL *ssl, Span<const uint8_t> signature, |
| 289 | uint16_t sigalg, EVP_PKEY *pkey, |
| 290 | Span<const uint8_t> in) { |
David Benjamin | 1386aad | 2017-07-19 23:57:40 -0400 | [diff] [blame] | 291 | ScopedEVP_MD_CTX ctx; |
David Benjamin | 4dfd5af | 2019-07-19 17:34:37 -0400 | [diff] [blame] | 292 | if (!setup_ctx(ssl, ctx.get(), pkey, sigalg, true /* verify */)) { |
| 293 | return false; |
| 294 | } |
| 295 | bool ok = EVP_DigestVerify(ctx.get(), signature.data(), signature.size(), |
| 296 | in.data(), in.size()); |
| 297 | #if defined(BORINGSSL_UNSAFE_FUZZER_MODE) |
| 298 | ok = true; |
| 299 | ERR_clear_error(); |
| 300 | #endif |
| 301 | return ok; |
Steven Valdez | 2b8415e | 2016-06-30 13:27:23 -0400 | [diff] [blame] | 302 | } |
| 303 | |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 304 | enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs, |
| 305 | uint8_t *out, |
| 306 | size_t *out_len, |
| 307 | size_t max_out, |
| 308 | Span<const uint8_t> in) { |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 309 | SSL *const ssl = hs->ssl; |
David Benjamin | 9b2cdb7 | 2021-04-01 23:21:53 -0400 | [diff] [blame] | 310 | assert(!hs->can_release_private_key); |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 311 | if (hs->config->cert->key_method != NULL) { |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 312 | enum ssl_private_key_result_t ret; |
| 313 | if (hs->pending_private_key_op) { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 314 | ret = hs->config->cert->key_method->complete(ssl, out, out_len, max_out); |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 315 | } else { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 316 | ret = hs->config->cert->key_method->decrypt(ssl, out, out_len, max_out, |
| 317 | in.data(), in.size()); |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 318 | } |
David Benjamin | fa65113 | 2018-02-01 15:07:30 -0500 | [diff] [blame] | 319 | if (ret == ssl_private_key_failure) { |
| 320 | OPENSSL_PUT_ERROR(SSL, SSL_R_PRIVATE_KEY_OPERATION_FAILED); |
| 321 | } |
David Benjamin | 4414874 | 2017-06-17 13:20:59 -0400 | [diff] [blame] | 322 | hs->pending_private_key_op = ret == ssl_private_key_retry; |
| 323 | return ret; |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 326 | RSA *rsa = EVP_PKEY_get0_RSA(hs->config->cert->privatekey.get()); |
David Benjamin | 758d127 | 2015-11-20 17:47:25 -0500 | [diff] [blame] | 327 | if (rsa == NULL) { |
David Benjamin | c11ea942 | 2017-08-29 16:33:21 -0400 | [diff] [blame] | 328 | // Decrypt operations are only supported for RSA keys. |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 329 | OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR); |
| 330 | return ssl_private_key_failure; |
| 331 | } |
| 332 | |
David Benjamin | c11ea942 | 2017-08-29 16:33:21 -0400 | [diff] [blame] | 333 | // Decrypt with no padding. PKCS#1 padding will be removed as part of the |
| 334 | // timing-sensitive code by the caller. |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 335 | if (!RSA_decrypt(rsa, out_len, out, max_out, in.data(), in.size(), |
| 336 | RSA_NO_PADDING)) { |
David Benjamin | 758d127 | 2015-11-20 17:47:25 -0500 | [diff] [blame] | 337 | return ssl_private_key_failure; |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 338 | } |
David Benjamin | 758d127 | 2015-11-20 17:47:25 -0500 | [diff] [blame] | 339 | return ssl_private_key_success; |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 340 | } |
| 341 | |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 342 | bool ssl_private_key_supports_signature_algorithm(SSL_HANDSHAKE *hs, |
| 343 | uint16_t sigalg) { |
David Benjamin | a232a71 | 2017-03-30 15:51:53 -0500 | [diff] [blame] | 344 | SSL *const ssl = hs->ssl; |
David Benjamin | e5fe31c | 2021-03-19 14:06:51 -0400 | [diff] [blame] | 345 | if (!pkey_supports_algorithm(ssl, hs->local_pubkey.get(), sigalg)) { |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 346 | return false; |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 347 | } |
| 348 | |
David Benjamin | c11ea942 | 2017-08-29 16:33:21 -0400 | [diff] [blame] | 349 | // Ensure the RSA key is large enough for the hash. RSASSA-PSS requires that |
| 350 | // emLen be at least hLen + sLen + 2. Both hLen and sLen are the size of the |
| 351 | // hash in TLS. Reasonable RSA key sizes are large enough for the largest |
| 352 | // defined RSASSA-PSS algorithm, but 1024-bit RSA is slightly too small for |
| 353 | // SHA-512. 1024-bit RSA is sometimes used for test credentials, so check the |
| 354 | // size so that we can fall back to another algorithm in that case. |
David Benjamin | 6114c3c | 2017-03-30 16:37:54 -0500 | [diff] [blame] | 355 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
David Benjamin | 31b0c9b | 2017-07-20 14:49:15 -0400 | [diff] [blame] | 356 | if (alg->is_rsa_pss && (size_t)EVP_PKEY_size(hs->local_pubkey.get()) < |
| 357 | 2 * EVP_MD_size(alg->digest_func()) + 2) { |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 358 | return false; |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 359 | } |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 360 | |
David Benjamin | 75a1f23 | 2017-10-11 17:19:19 -0400 | [diff] [blame] | 361 | return true; |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 362 | } |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 363 | |
Joshua Liebow-Feeser | 8c7c635 | 2018-08-26 18:53:36 -0700 | [diff] [blame] | 364 | BSSL_NAMESPACE_END |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 365 | |
| 366 | using namespace bssl; |
| 367 | |
| 368 | int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 369 | if (rsa == NULL || ssl->config == NULL) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 370 | OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER); |
| 371 | return 0; |
| 372 | } |
| 373 | |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 374 | UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new()); |
| 375 | if (!pkey || |
| 376 | !EVP_PKEY_set1_RSA(pkey.get(), rsa)) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 377 | OPENSSL_PUT_ERROR(SSL, ERR_R_EVP_LIB); |
| 378 | return 0; |
| 379 | } |
| 380 | |
David Benjamin | 0ce090a | 2018-07-02 20:24:40 -0400 | [diff] [blame] | 381 | return ssl_set_pkey(ssl->config->cert.get(), pkey.get()); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const uint8_t *der, size_t der_len) { |
| 385 | UniquePtr<RSA> rsa(RSA_private_key_from_bytes(der, der_len)); |
| 386 | if (!rsa) { |
| 387 | OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB); |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | return SSL_use_RSAPrivateKey(ssl, rsa.get()); |
| 392 | } |
| 393 | |
| 394 | int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 395 | if (pkey == NULL || ssl->config == NULL) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 396 | OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER); |
| 397 | return 0; |
| 398 | } |
| 399 | |
David Benjamin | 0ce090a | 2018-07-02 20:24:40 -0400 | [diff] [blame] | 400 | return ssl_set_pkey(ssl->config->cert.get(), pkey); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, const uint8_t *der, |
| 404 | size_t der_len) { |
| 405 | if (der_len > LONG_MAX) { |
| 406 | OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW); |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | const uint8_t *p = der; |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 411 | UniquePtr<EVP_PKEY> pkey(d2i_PrivateKey(type, NULL, &p, (long)der_len)); |
| 412 | if (!pkey || p != der + der_len) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 413 | OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 414 | return 0; |
| 415 | } |
| 416 | |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 417 | return SSL_use_PrivateKey(ssl, pkey.get()); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 421 | if (rsa == NULL) { |
| 422 | OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER); |
| 423 | return 0; |
| 424 | } |
| 425 | |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 426 | UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new()); |
| 427 | if (!pkey || |
| 428 | !EVP_PKEY_set1_RSA(pkey.get(), rsa)) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 429 | OPENSSL_PUT_ERROR(SSL, ERR_R_EVP_LIB); |
| 430 | return 0; |
| 431 | } |
| 432 | |
David Benjamin | 0ce090a | 2018-07-02 20:24:40 -0400 | [diff] [blame] | 433 | return ssl_set_pkey(ctx->cert.get(), pkey.get()); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const uint8_t *der, |
| 437 | size_t der_len) { |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 438 | UniquePtr<RSA> rsa(RSA_private_key_from_bytes(der, der_len)); |
| 439 | if (!rsa) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 440 | OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB); |
| 441 | return 0; |
| 442 | } |
| 443 | |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 444 | return SSL_CTX_use_RSAPrivateKey(ctx, rsa.get()); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) { |
| 448 | if (pkey == NULL) { |
| 449 | OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER); |
| 450 | return 0; |
| 451 | } |
| 452 | |
David Benjamin | 0ce090a | 2018-07-02 20:24:40 -0400 | [diff] [blame] | 453 | return ssl_set_pkey(ctx->cert.get(), pkey); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, const uint8_t *der, |
| 457 | size_t der_len) { |
| 458 | if (der_len > LONG_MAX) { |
| 459 | OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW); |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | const uint8_t *p = der; |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 464 | UniquePtr<EVP_PKEY> pkey(d2i_PrivateKey(type, NULL, &p, (long)der_len)); |
| 465 | if (!pkey || p != der + der_len) { |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 466 | OPENSSL_PUT_ERROR(SSL, ERR_R_ASN1_LIB); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 467 | return 0; |
| 468 | } |
| 469 | |
David Benjamin | 4492a61 | 2017-08-02 17:16:31 -0400 | [diff] [blame] | 470 | return SSL_CTX_use_PrivateKey(ctx, pkey.get()); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | void SSL_set_private_key_method(SSL *ssl, |
| 474 | const SSL_PRIVATE_KEY_METHOD *key_method) { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 475 | if (!ssl->config) { |
| 476 | return; |
| 477 | } |
| 478 | ssl->config->cert->key_method = key_method; |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | void SSL_CTX_set_private_key_method(SSL_CTX *ctx, |
| 482 | const SSL_PRIVATE_KEY_METHOD *key_method) { |
| 483 | ctx->cert->key_method = key_method; |
| 484 | } |
| 485 | |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 486 | static constexpr size_t kMaxSignatureAlgorithmNameLen = 23; |
| 487 | |
Adam Langley | c215ce7 | 2023-05-08 11:35:14 -0700 | [diff] [blame] | 488 | struct SignatureAlgorithmName { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 489 | uint16_t signature_algorithm; |
| 490 | const char name[kMaxSignatureAlgorithmNameLen]; |
Adam Langley | c215ce7 | 2023-05-08 11:35:14 -0700 | [diff] [blame] | 491 | }; |
| 492 | |
| 493 | // This was "constexpr" rather than "const", but that triggered a bug in MSVC |
| 494 | // where it didn't pad the strings to the correct length. |
| 495 | static const SignatureAlgorithmName kSignatureAlgorithmNames[] = { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 496 | {SSL_SIGN_RSA_PKCS1_MD5_SHA1, "rsa_pkcs1_md5_sha1"}, |
| 497 | {SSL_SIGN_RSA_PKCS1_SHA1, "rsa_pkcs1_sha1"}, |
| 498 | {SSL_SIGN_RSA_PKCS1_SHA256, "rsa_pkcs1_sha256"}, |
| 499 | {SSL_SIGN_RSA_PKCS1_SHA384, "rsa_pkcs1_sha384"}, |
| 500 | {SSL_SIGN_RSA_PKCS1_SHA512, "rsa_pkcs1_sha512"}, |
| 501 | {SSL_SIGN_ECDSA_SHA1, "ecdsa_sha1"}, |
| 502 | {SSL_SIGN_ECDSA_SECP256R1_SHA256, "ecdsa_secp256r1_sha256"}, |
| 503 | {SSL_SIGN_ECDSA_SECP384R1_SHA384, "ecdsa_secp384r1_sha384"}, |
| 504 | {SSL_SIGN_ECDSA_SECP521R1_SHA512, "ecdsa_secp521r1_sha512"}, |
| 505 | {SSL_SIGN_RSA_PSS_RSAE_SHA256, "rsa_pss_rsae_sha256"}, |
| 506 | {SSL_SIGN_RSA_PSS_RSAE_SHA384, "rsa_pss_rsae_sha384"}, |
| 507 | {SSL_SIGN_RSA_PSS_RSAE_SHA512, "rsa_pss_rsae_sha512"}, |
| 508 | {SSL_SIGN_ED25519, "ed25519"}, |
| 509 | }; |
| 510 | |
David Benjamin | 6cc352e | 2017-11-02 17:21:39 -0400 | [diff] [blame] | 511 | const char *SSL_get_signature_algorithm_name(uint16_t sigalg, |
| 512 | int include_curve) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 513 | if (!include_curve) { |
| 514 | switch (sigalg) { |
| 515 | case SSL_SIGN_ECDSA_SECP256R1_SHA256: |
| 516 | return "ecdsa_sha256"; |
| 517 | case SSL_SIGN_ECDSA_SECP384R1_SHA384: |
| 518 | return "ecdsa_sha384"; |
| 519 | case SSL_SIGN_ECDSA_SECP521R1_SHA512: |
| 520 | return "ecdsa_sha512"; |
Adam Langley | c215ce7 | 2023-05-08 11:35:14 -0700 | [diff] [blame] | 521 | // If adding more here, also update |
| 522 | // |SSL_get_all_signature_algorithm_names|. |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 523 | } |
David Benjamin | 6cc352e | 2017-11-02 17:21:39 -0400 | [diff] [blame] | 524 | } |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 525 | |
| 526 | for (const auto &candidate : kSignatureAlgorithmNames) { |
| 527 | if (candidate.signature_algorithm == sigalg) { |
| 528 | return candidate.name; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | return NULL; |
David Benjamin | 6cc352e | 2017-11-02 17:21:39 -0400 | [diff] [blame] | 533 | } |
| 534 | |
David Benjamin | a972b78 | 2023-05-05 10:22:43 -0400 | [diff] [blame] | 535 | size_t SSL_get_all_signature_algorithm_names(const char **out, size_t max_out) { |
Adam Langley | c215ce7 | 2023-05-08 11:35:14 -0700 | [diff] [blame] | 536 | const char *kPredefinedNames[] = {"ecdsa_sha256", "ecdsa_sha384", |
| 537 | "ecdsa_sha512"}; |
| 538 | return GetAllNames(out, max_out, MakeConstSpan(kPredefinedNames), |
| 539 | &SignatureAlgorithmName::name, |
| 540 | MakeConstSpan(kSignatureAlgorithmNames)); |
David Benjamin | a972b78 | 2023-05-05 10:22:43 -0400 | [diff] [blame] | 541 | } |
| 542 | |
David Benjamin | 6cc352e | 2017-11-02 17:21:39 -0400 | [diff] [blame] | 543 | int SSL_get_signature_algorithm_key_type(uint16_t sigalg) { |
| 544 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
| 545 | return alg != nullptr ? alg->pkey_type : EVP_PKEY_NONE; |
| 546 | } |
| 547 | |
| 548 | const EVP_MD *SSL_get_signature_algorithm_digest(uint16_t sigalg) { |
| 549 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
| 550 | if (alg == nullptr || alg->digest_func == nullptr) { |
| 551 | return nullptr; |
| 552 | } |
| 553 | return alg->digest_func(); |
| 554 | } |
| 555 | |
| 556 | int SSL_is_signature_algorithm_rsa_pss(uint16_t sigalg) { |
| 557 | const SSL_SIGNATURE_ALGORITHM *alg = get_signature_algorithm(sigalg); |
| 558 | return alg != nullptr && alg->is_rsa_pss; |
| 559 | } |
| 560 | |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 561 | static int compare_uint16_t(const void *p1, const void *p2) { |
| 562 | uint16_t u1 = *((const uint16_t *)p1); |
| 563 | uint16_t u2 = *((const uint16_t *)p2); |
| 564 | if (u1 < u2) { |
| 565 | return -1; |
| 566 | } else if (u1 > u2) { |
| 567 | return 1; |
| 568 | } else { |
| 569 | return 0; |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | static bool sigalgs_unique(Span<const uint16_t> in_sigalgs) { |
| 574 | if (in_sigalgs.size() < 2) { |
| 575 | return true; |
| 576 | } |
| 577 | |
| 578 | Array<uint16_t> sigalgs; |
| 579 | if (!sigalgs.CopyFrom(in_sigalgs)) { |
| 580 | return false; |
| 581 | } |
| 582 | |
| 583 | qsort(sigalgs.data(), sigalgs.size(), sizeof(uint16_t), compare_uint16_t); |
| 584 | |
| 585 | for (size_t i = 1; i < sigalgs.size(); i++) { |
| 586 | if (sigalgs[i - 1] == sigalgs[i]) { |
| 587 | OPENSSL_PUT_ERROR(SSL, SSL_R_DUPLICATE_SIGNATURE_ALGORITHM); |
| 588 | return false; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return true; |
| 593 | } |
| 594 | |
| 595 | static bool set_sigalg_prefs(Array<uint16_t> *out, Span<const uint16_t> prefs) { |
| 596 | if (!sigalgs_unique(prefs)) { |
| 597 | return false; |
| 598 | } |
| 599 | |
| 600 | // Check for invalid algorithms, and filter out |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 601 | Array<uint16_t> filtered; |
| 602 | if (!filtered.Init(prefs.size())) { |
| 603 | return false; |
| 604 | } |
| 605 | size_t added = 0; |
| 606 | for (uint16_t pref : prefs) { |
| 607 | if (pref == SSL_SIGN_RSA_PKCS1_MD5_SHA1) { |
| 608 | // Though not intended to be used with this API, we treat |
| 609 | // |SSL_SIGN_RSA_PKCS1_MD5_SHA1| as a real signature algorithm in |
| 610 | // |SSL_PRIVATE_KEY_METHOD|. Not accepting it here makes for a confusing |
| 611 | // abstraction. |
| 612 | continue; |
| 613 | } |
| 614 | if (get_signature_algorithm(pref) == nullptr) { |
| 615 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 616 | return false; |
| 617 | } |
| 618 | filtered[added] = pref; |
| 619 | added++; |
| 620 | } |
| 621 | filtered.Shrink(added); |
| 622 | |
| 623 | // This can happen if |prefs| contained only |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 624 | // Leaving it empty would revert to the default, so treat this as an error |
| 625 | // condition. |
| 626 | if (!prefs.empty() && filtered.empty()) { |
| 627 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 628 | return false; |
| 629 | } |
| 630 | |
| 631 | *out = std::move(filtered); |
| 632 | return true; |
| 633 | } |
| 634 | |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 635 | int SSL_CTX_set_signing_algorithm_prefs(SSL_CTX *ctx, const uint16_t *prefs, |
| 636 | size_t num_prefs) { |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 637 | return set_sigalg_prefs(&ctx->cert->sigalgs, MakeConstSpan(prefs, num_prefs)); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 638 | } |
| 639 | |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 640 | int SSL_set_signing_algorithm_prefs(SSL *ssl, const uint16_t *prefs, |
| 641 | size_t num_prefs) { |
Matthew Braithwaite | b7bc80a | 2018-04-13 15:51:30 -0700 | [diff] [blame] | 642 | if (!ssl->config) { |
| 643 | return 0; |
| 644 | } |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 645 | return set_sigalg_prefs(&ssl->config->cert->sigalgs, |
| 646 | MakeConstSpan(prefs, num_prefs)); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 647 | } |
| 648 | |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 649 | static constexpr struct { |
| 650 | int pkey_type; |
| 651 | int hash_nid; |
| 652 | uint16_t signature_algorithm; |
| 653 | } kSignatureAlgorithmsMapping[] = { |
| 654 | {EVP_PKEY_RSA, NID_sha1, SSL_SIGN_RSA_PKCS1_SHA1}, |
| 655 | {EVP_PKEY_RSA, NID_sha256, SSL_SIGN_RSA_PKCS1_SHA256}, |
| 656 | {EVP_PKEY_RSA, NID_sha384, SSL_SIGN_RSA_PKCS1_SHA384}, |
| 657 | {EVP_PKEY_RSA, NID_sha512, SSL_SIGN_RSA_PKCS1_SHA512}, |
| 658 | {EVP_PKEY_RSA_PSS, NID_sha256, SSL_SIGN_RSA_PSS_RSAE_SHA256}, |
| 659 | {EVP_PKEY_RSA_PSS, NID_sha384, SSL_SIGN_RSA_PSS_RSAE_SHA384}, |
| 660 | {EVP_PKEY_RSA_PSS, NID_sha512, SSL_SIGN_RSA_PSS_RSAE_SHA512}, |
| 661 | {EVP_PKEY_EC, NID_sha1, SSL_SIGN_ECDSA_SHA1}, |
| 662 | {EVP_PKEY_EC, NID_sha256, SSL_SIGN_ECDSA_SECP256R1_SHA256}, |
| 663 | {EVP_PKEY_EC, NID_sha384, SSL_SIGN_ECDSA_SECP384R1_SHA384}, |
| 664 | {EVP_PKEY_EC, NID_sha512, SSL_SIGN_ECDSA_SECP521R1_SHA512}, |
| 665 | {EVP_PKEY_ED25519, NID_undef, SSL_SIGN_ED25519}, |
| 666 | }; |
| 667 | |
| 668 | static bool parse_sigalg_pairs(Array<uint16_t> *out, const int *values, |
| 669 | size_t num_values) { |
| 670 | if ((num_values & 1) == 1) { |
| 671 | return false; |
| 672 | } |
| 673 | |
| 674 | const size_t num_pairs = num_values / 2; |
| 675 | if (!out->Init(num_pairs)) { |
| 676 | return false; |
| 677 | } |
| 678 | |
| 679 | for (size_t i = 0; i < num_values; i += 2) { |
| 680 | const int hash_nid = values[i]; |
| 681 | const int pkey_type = values[i+1]; |
| 682 | |
| 683 | bool found = false; |
| 684 | for (const auto &candidate : kSignatureAlgorithmsMapping) { |
| 685 | if (candidate.pkey_type == pkey_type && candidate.hash_nid == hash_nid) { |
| 686 | (*out)[i / 2] = candidate.signature_algorithm; |
| 687 | found = true; |
| 688 | break; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | if (!found) { |
| 693 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 694 | ERR_add_error_dataf("unknown hash:%d pkey:%d", hash_nid, pkey_type); |
| 695 | return false; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | return true; |
| 700 | } |
| 701 | |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 702 | int SSL_CTX_set1_sigalgs(SSL_CTX *ctx, const int *values, size_t num_values) { |
| 703 | Array<uint16_t> sigalgs; |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 704 | if (!parse_sigalg_pairs(&sigalgs, values, num_values)) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | if (!SSL_CTX_set_signing_algorithm_prefs(ctx, sigalgs.data(), |
| 709 | sigalgs.size()) || |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 710 | !SSL_CTX_set_verify_algorithm_prefs(ctx, sigalgs.data(), |
| 711 | sigalgs.size())) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | return 1; |
| 716 | } |
| 717 | |
| 718 | int SSL_set1_sigalgs(SSL *ssl, const int *values, size_t num_values) { |
| 719 | if (!ssl->config) { |
| 720 | OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | Array<uint16_t> sigalgs; |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 725 | if (!parse_sigalg_pairs(&sigalgs, values, num_values)) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | if (!SSL_set_signing_algorithm_prefs(ssl, sigalgs.data(), sigalgs.size()) || |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 730 | !SSL_set_verify_algorithm_prefs(ssl, sigalgs.data(), sigalgs.size())) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 731 | return 0; |
| 732 | } |
| 733 | |
| 734 | return 1; |
| 735 | } |
| 736 | |
| 737 | static bool parse_sigalgs_list(Array<uint16_t> *out, const char *str) { |
| 738 | // str looks like "RSA+SHA1:ECDSA+SHA256:ecdsa_secp256r1_sha256". |
| 739 | |
| 740 | // Count colons to give the number of output elements from any successful |
| 741 | // parse. |
| 742 | size_t num_elements = 1; |
| 743 | size_t len = 0; |
| 744 | for (const char *p = str; *p; p++) { |
| 745 | len++; |
| 746 | if (*p == ':') { |
| 747 | num_elements++; |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | if (!out->Init(num_elements)) { |
| 752 | return false; |
| 753 | } |
| 754 | size_t out_i = 0; |
| 755 | |
| 756 | enum { |
| 757 | pkey_or_name, |
| 758 | hash_name, |
| 759 | } state = pkey_or_name; |
| 760 | |
| 761 | char buf[kMaxSignatureAlgorithmNameLen]; |
| 762 | // buf_used is always < sizeof(buf). I.e. it's always safe to write |
| 763 | // buf[buf_used] = 0. |
| 764 | size_t buf_used = 0; |
| 765 | |
| 766 | int pkey_type = 0, hash_nid = 0; |
| 767 | |
| 768 | // Note that the loop runs to len+1, i.e. it'll process the terminating NUL. |
| 769 | for (size_t offset = 0; offset < len+1; offset++) { |
David Benjamin | 4f1fae3 | 2021-12-15 11:41:10 -0500 | [diff] [blame] | 770 | const unsigned char c = str[offset]; |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 771 | |
| 772 | switch (c) { |
| 773 | case '+': |
| 774 | if (state == hash_name) { |
| 775 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 776 | ERR_add_error_dataf("+ found in hash name at offset %zu", offset); |
| 777 | return false; |
| 778 | } |
| 779 | if (buf_used == 0) { |
| 780 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 781 | ERR_add_error_dataf("empty public key type at offset %zu", offset); |
| 782 | return false; |
| 783 | } |
| 784 | buf[buf_used] = 0; |
| 785 | |
| 786 | if (strcmp(buf, "RSA") == 0) { |
| 787 | pkey_type = EVP_PKEY_RSA; |
| 788 | } else if (strcmp(buf, "RSA-PSS") == 0 || |
| 789 | strcmp(buf, "PSS") == 0) { |
| 790 | pkey_type = EVP_PKEY_RSA_PSS; |
| 791 | } else if (strcmp(buf, "ECDSA") == 0) { |
| 792 | pkey_type = EVP_PKEY_EC; |
| 793 | } else { |
| 794 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 795 | ERR_add_error_dataf("unknown public key type '%s'", buf); |
| 796 | return false; |
| 797 | } |
| 798 | |
| 799 | state = hash_name; |
| 800 | buf_used = 0; |
| 801 | break; |
| 802 | |
| 803 | case ':': |
| 804 | OPENSSL_FALLTHROUGH; |
| 805 | case 0: |
| 806 | if (buf_used == 0) { |
| 807 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 808 | ERR_add_error_dataf("empty element at offset %zu", offset); |
| 809 | return false; |
| 810 | } |
| 811 | |
| 812 | buf[buf_used] = 0; |
| 813 | |
| 814 | if (state == pkey_or_name) { |
| 815 | // No '+' was seen thus this is a TLS 1.3-style name. |
| 816 | bool found = false; |
| 817 | for (const auto &candidate : kSignatureAlgorithmNames) { |
| 818 | if (strcmp(candidate.name, buf) == 0) { |
| 819 | assert(out_i < num_elements); |
| 820 | (*out)[out_i++] = candidate.signature_algorithm; |
| 821 | found = true; |
| 822 | break; |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | if (!found) { |
| 827 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 828 | ERR_add_error_dataf("unknown signature algorithm '%s'", buf); |
| 829 | return false; |
| 830 | } |
| 831 | } else { |
| 832 | if (strcmp(buf, "SHA1") == 0) { |
| 833 | hash_nid = NID_sha1; |
| 834 | } else if (strcmp(buf, "SHA256") == 0) { |
| 835 | hash_nid = NID_sha256; |
| 836 | } else if (strcmp(buf, "SHA384") == 0) { |
| 837 | hash_nid = NID_sha384; |
| 838 | } else if (strcmp(buf, "SHA512") == 0) { |
| 839 | hash_nid = NID_sha512; |
| 840 | } else { |
| 841 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 842 | ERR_add_error_dataf("unknown hash function '%s'", buf); |
| 843 | return false; |
| 844 | } |
| 845 | |
| 846 | bool found = false; |
| 847 | for (const auto &candidate : kSignatureAlgorithmsMapping) { |
| 848 | if (candidate.pkey_type == pkey_type && |
| 849 | candidate.hash_nid == hash_nid) { |
| 850 | assert(out_i < num_elements); |
| 851 | (*out)[out_i++] = candidate.signature_algorithm; |
| 852 | found = true; |
| 853 | break; |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | if (!found) { |
| 858 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 859 | ERR_add_error_dataf("unknown pkey:%d hash:%s", pkey_type, buf); |
| 860 | return false; |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | state = pkey_or_name; |
| 865 | buf_used = 0; |
| 866 | break; |
| 867 | |
| 868 | default: |
| 869 | if (buf_used == sizeof(buf) - 1) { |
| 870 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 871 | ERR_add_error_dataf("substring too long at offset %zu", offset); |
| 872 | return false; |
| 873 | } |
| 874 | |
Bob Beck | 00c70b8 | 2023-02-01 12:41:49 -0700 | [diff] [blame] | 875 | if (OPENSSL_isalnum(c) || c == '-' || c == '_') { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 876 | buf[buf_used++] = c; |
| 877 | } else { |
| 878 | OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_SIGNATURE_ALGORITHM); |
| 879 | ERR_add_error_dataf("invalid character 0x%02x at offest %zu", c, |
| 880 | offset); |
| 881 | return false; |
| 882 | } |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | assert(out_i == out->size()); |
| 887 | return true; |
| 888 | } |
| 889 | |
| 890 | int SSL_CTX_set1_sigalgs_list(SSL_CTX *ctx, const char *str) { |
| 891 | Array<uint16_t> sigalgs; |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 892 | if (!parse_sigalgs_list(&sigalgs, str)) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | if (!SSL_CTX_set_signing_algorithm_prefs(ctx, sigalgs.data(), |
| 897 | sigalgs.size()) || |
David Benjamin | f0a815c | 2020-02-03 20:03:52 -0500 | [diff] [blame] | 898 | !SSL_CTX_set_verify_algorithm_prefs(ctx, sigalgs.data(), |
| 899 | sigalgs.size())) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 900 | return 0; |
| 901 | } |
| 902 | |
| 903 | return 1; |
| 904 | } |
| 905 | |
| 906 | int SSL_set1_sigalgs_list(SSL *ssl, const char *str) { |
| 907 | if (!ssl->config) { |
| 908 | OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 909 | return 0; |
| 910 | } |
| 911 | |
| 912 | Array<uint16_t> sigalgs; |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 913 | if (!parse_sigalgs_list(&sigalgs, str)) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | if (!SSL_set_signing_algorithm_prefs(ssl, sigalgs.data(), sigalgs.size()) || |
David Benjamin | f0a815c | 2020-02-03 20:03:52 -0500 | [diff] [blame] | 918 | !SSL_set_verify_algorithm_prefs(ssl, sigalgs.data(), sigalgs.size())) { |
Adam Langley | 826ce15 | 2018-08-03 10:31:21 -0700 | [diff] [blame] | 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | return 1; |
| 923 | } |
| 924 | |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 925 | int SSL_CTX_set_verify_algorithm_prefs(SSL_CTX *ctx, const uint16_t *prefs, |
| 926 | size_t num_prefs) { |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 927 | return set_sigalg_prefs(&ctx->verify_sigalgs, |
| 928 | MakeConstSpan(prefs, num_prefs)); |
David Benjamin | 86e95b8 | 2017-07-18 16:34:25 -0400 | [diff] [blame] | 929 | } |
David Benjamin | f0a815c | 2020-02-03 20:03:52 -0500 | [diff] [blame] | 930 | |
| 931 | int SSL_set_verify_algorithm_prefs(SSL *ssl, const uint16_t *prefs, |
| 932 | size_t num_prefs) { |
| 933 | if (!ssl->config) { |
| 934 | OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 935 | return 0; |
| 936 | } |
| 937 | |
David Benjamin | 3a1b730 | 2022-11-29 18:44:46 -0500 | [diff] [blame] | 938 | return set_sigalg_prefs(&ssl->config->verify_sigalgs, |
| 939 | MakeConstSpan(prefs, num_prefs)); |
David Benjamin | f0a815c | 2020-02-03 20:03:52 -0500 | [diff] [blame] | 940 | } |