@@ -512,12 +512,14 @@ void SSL_CTX_set_private_key_method(SSL_CTX *ctx,
512512
513513static constexpr size_t kMaxSignatureAlgorithmNameLen = 23 ;
514514
515- // This was "constexpr" rather than "const", but that triggered a bug in MSVC
516- // where it didn't pad the strings to the correct length.
517- static const struct {
515+ struct SignatureAlgorithmName {
518516 uint16_t signature_algorithm;
519517 const char name[kMaxSignatureAlgorithmNameLen ];
520- } kSignatureAlgorithmNames [] = {
518+ };
519+
520+ // This was "constexpr" rather than "const", but that triggered a bug in MSVC
521+ // where it didn't pad the strings to the correct length.
522+ static const SignatureAlgorithmName kSignatureAlgorithmNames [] = {
521523 {SSL_SIGN_RSA_PKCS1_MD5_SHA1, " rsa_pkcs1_md5_sha1" },
522524 {SSL_SIGN_RSA_PKCS1_SHA1, " rsa_pkcs1_sha1" },
523525 {SSL_SIGN_RSA_PKCS1_SHA256, " rsa_pkcs1_sha256" },
@@ -543,6 +545,8 @@ const char *SSL_get_signature_algorithm_name(uint16_t sigalg,
543545 return " ecdsa_sha384" ;
544546 case SSL_SIGN_ECDSA_SECP521R1_SHA512:
545547 return " ecdsa_sha512" ;
548+ // If adding more here, also update
549+ // |SSL_get_all_signature_algorithm_names|.
546550 }
547551 }
548552
@@ -556,24 +560,11 @@ const char *SSL_get_signature_algorithm_name(uint16_t sigalg,
556560}
557561
558562size_t SSL_get_all_signature_algorithm_names (const char **out, size_t max_out) {
559- auto span = MakeSpan (out, max_out);
560- if (!span.empty ()) {
561- span[0 ] = " ecdsa_sha256" ;
562- span = span.subspan (1 );
563- }
564- if (!span.empty ()) {
565- span[0 ] = " ecdsa_sha384" ;
566- span = span.subspan (1 );
567- }
568- if (!span.empty ()) {
569- span[0 ] = " ecdsa_sha512" ;
570- span = span.subspan (1 );
571- }
572- span = span.subspan (0 , OPENSSL_ARRAY_SIZE (kSignatureAlgorithmNames ));
573- for (size_t i = 0 ; i < span.size (); i++) {
574- span[i] = kSignatureAlgorithmNames [i].name ;
575- }
576- return 3 + OPENSSL_ARRAY_SIZE (kSignatureAlgorithmNames );
563+ const char *kPredefinedNames [] = {" ecdsa_sha256" , " ecdsa_sha384" ,
564+ " ecdsa_sha512" };
565+ return GetAllNames (out, max_out, MakeConstSpan (kPredefinedNames ),
566+ &SignatureAlgorithmName::name,
567+ MakeConstSpan (kSignatureAlgorithmNames ));
577568}
578569
579570int SSL_get_signature_algorithm_key_type (uint16_t sigalg) {
0 commit comments