void print_ssl_summary(SSL *s)
{
+ const char *sigalg;
const SSL_CIPHER *c;
X509 *peer = SSL_get0_peer_certificate(s);
EVP_PKEY *peer_rpk = SSL_get0_peer_rpk(s);
BIO_puts(bio_err, "\n");
if (SSL_get_peer_signature_nid(s, &nid))
BIO_printf(bio_err, "Hash used: %s\n", OBJ_nid2sn(nid));
- if (SSL_get_peer_signature_type_nid(s, &nid))
- BIO_printf(bio_err, "Signature type: %s\n", get_sigtype(nid));
+ if (SSL_get0_peer_signature_name(s, &sigalg))
+ BIO_printf(bio_err, "Signature type: %s\n", sigalg);
print_verify_detail(s, bio_err);
} else if (peer_rpk != NULL) {
BIO_printf(bio_err, "Peer used raw public key\n");
- if (SSL_get_peer_signature_type_nid(s, &nid))
- BIO_printf(bio_err, "Signature type: %s\n", get_sigtype(nid));
+ if (SSL_get0_peer_signature_name(s, &sigalg))
+ BIO_printf(bio_err, "Signature type: %s\n", sigalg);
print_verify_detail(s, bio_err);
} else {
BIO_puts(bio_err, "No peer certificate or raw public key\n");
=head1 NAME
-SSL_get_peer_signature_nid, SSL_get_peer_signature_type_nid,
-SSL_get_signature_nid, SSL_get_signature_type_nid - get TLS message signing
-types
+SSL_get0_peer_signature_name, SSL_get_peer_signature_nid,
+SSL_get_peer_signature_type_nid, SSL_get0_signature_name,
+SSL_get_signature_nid, SSL_get_signature_type_nid -
+get TLS message signing types
=head1 SYNOPSIS
#include <openssl/ssl.h>
+ int SSL_get0_peer_signature_name(const SSL *ssl, const char **sigalg);
int SSL_get_peer_signature_nid(SSL *ssl, int *psig_nid);
int SSL_get_peer_signature_type_nid(const SSL *ssl, int *psigtype_nid);
+ int SSL_get0_signature_name(SSL *ssl, const char **sigalg);
int SSL_get_signature_nid(SSL *ssl, int *psig_nid);
int SSL_get_signature_type_nid(const SSL *ssl, int *psigtype_nid);
=head1 DESCRIPTION
+SSL_get0_peer_signature_name() sets I<*sigalg> to the IANA name of the
+L<signature scheme|https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-signaturescheme>
+used by the peer to sign the TLS handshake.
+The caller must not free the returned pointer.
+The returned string should be copied if it is to be retained beyond the
+lifetime of the SSL connection.
+
SSL_get_peer_signature_nid() sets B<*psig_nid> to the NID of the digest used
by the peer to sign TLS messages. It is implemented as a macro.
B<rsa_pss_rsae_*> and B<rsa_pss_pss_*> signatures, it's necessary to check
the type of public key in the peer's certificate.
-SSL_get_signature_nid() and SSL_get_signature_type_nid() return the equivalent
-information for the local end of the connection.
+SSL_get0_signature_name(), SSL_get_signature_nid() and
+SSL_get_signature_type_nid() return the equivalent information for the local
+end of the connection.
=head1 RETURN VALUES
These functions return 1 for success and 0 for failure. There are several
-possible reasons for failure: the cipher suite has no signature (e.g. it
-uses RSA key exchange or is anonymous), the TLS version is below 1.2 or
-the functions were called too early, e.g. before the peer signed a message.
+possible reasons for failure: the peer or local end is a client and did not
+sign the handshake (did not use a client certificate), the cipher suite has no
+signature (e.g. it uses RSA key exchange or is anonymous), the TLS version is
+below 1.2 or the functions were called too early, e.g. before the peer signed a
+message.
=head1 SEE ALSO
L<ssl(7)>, L<SSL_get_peer_certificate(3)>,
+=head1 HISTORY
+
+The SSL_get0_peer_signature_name() and SSL_get0_signature_name() functions were
+added in OpenSSL 3.5.
+
=head1 COPYRIGHT
-Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2017-2025 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
=head1 COPYRIGHT
-Copyright 2024 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
=head1 COPYRIGHT
-Copyright 2024 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
# define SSL_CTRL_GET_VERIFY_CERT_STORE 137
# define SSL_CTRL_GET_CHAIN_CERT_STORE 138
# define SSL_CTRL_GET0_IMPLEMENTED_GROUPS 139
+# define SSL_CTRL_GET_SIGNATURE_NAME 140
+# define SSL_CTRL_GET_PEER_SIGNATURE_NAME 141
# define SSL_CERT_SET_FIRST 1
# define SSL_CERT_SET_NEXT 2
# define SSL_CERT_SET_SERVER 3
(char *)(clist))
# define SSL_set1_client_certificate_types(s, clist, clistlen) \
SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist))
+# define SSL_get0_signature_name(s, str) \
+ SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NAME,0,(1?(str):(const char **)NULL))
# define SSL_get_signature_nid(s, pn) \
SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn)
+# define SSL_get0_peer_signature_name(s, str) \
+ SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NAME,0,(1?(str):(const char **)NULL))
# define SSL_get_peer_signature_nid(s, pn) \
SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)
# define SSL_get_peer_tmp_key(s, pk) \
case SSL_CTRL_GET_CHAIN_CERT_STORE:
return ssl_cert_get_cert_store(sc->cert, parg, 1);
+ case SSL_CTRL_GET_PEER_SIGNATURE_NAME:
+ if (parg == NULL && sc->s3.tmp.peer_sigalg == NULL)
+ return 0;
+ *(const char **)parg = sc->s3.tmp.peer_sigalg->name;
+ return 1;
+
case SSL_CTRL_GET_PEER_SIGNATURE_NID:
if (sc->s3.tmp.peer_sigalg == NULL)
return 0;
*(int *)parg = sc->s3.tmp.peer_sigalg->hash;
return 1;
+ case SSL_CTRL_GET_SIGNATURE_NAME:
+ if (parg == NULL || sc->s3.tmp.sigalg == NULL)
+ return 0;
+ *(const char **)parg = sc->s3.tmp.sigalg->name;
+ return 1;
+
case SSL_CTRL_GET_SIGNATURE_NID:
if (sc->s3.tmp.sigalg == NULL)
return 0;
sizeof(bad_early_data), &written)))
goto end;
}
- /* fallthrough */
+ /* FALLTHROUGH */
case 3:
/*
OSSL_LIB_CTX *tmpctx = OSSL_LIB_CTX_new();
OSSL_LIB_CTX *clientctx = libctx, *serverctx = libctx;
OSSL_PROVIDER *filterprov = NULL;
- int sig, hash;
+ int sig, hash, numshared, numshared_expected, hash_expected, sig_expected;
+ const char *sigalg_name, *signame_expected;
if (!TEST_ptr(tmpctx))
goto end;
goto end;
if (idx != 5) {
+ /* RSA first server key */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
&sctx, &cctx, cert, privkey)))
goto end;
} else {
+ /* ECDSA P-256 first server key */
if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
TLS_client_method(),
TLS1_VERSION,
goto end;
}
+ /* ECDSA P-256 second server key, unless already first */
if (idx != 5
&& (!TEST_int_eq(SSL_CTX_use_certificate_file(sctx, cert2,
SSL_FILETYPE_PEM), 1)
goto end;
/* For tests 0 and 3 we expect 2 shared sigalgs, otherwise exactly 1 */
- if (!TEST_int_eq(SSL_get_shared_sigalgs(serverssl, 0, &sig, &hash, NULL,
- NULL, NULL),
- (idx == 0 || idx == 3) ? 2 : 1))
- goto end;
-
- if (!TEST_int_eq(hash, idx == 0 ? NID_sha384 : NID_sha256))
- goto end;
-
- if (!TEST_int_eq(sig, (idx == 4 || idx == 5) ? EVP_PKEY_EC
- : NID_rsassaPss))
+ numshared = SSL_get_shared_sigalgs(serverssl, 0, &sig, &hash,
+ NULL, NULL, NULL);
+ numshared_expected = 1;
+ hash_expected = NID_sha256;
+ sig_expected = NID_rsassaPss;
+ signame_expected = "rsa_pss_rsae_sha256";
+ switch (idx) {
+ case 0:
+ hash_expected = NID_sha384;
+ signame_expected = "rsa_pss_rsae_sha384";
+ /* FALLTHROUGH */
+ case 3:
+ numshared_expected = 2;
+ break;
+ case 4:
+ case 5:
+ sig_expected = EVP_PKEY_EC;
+ signame_expected = "ecdsa_secp256r1_sha256";
+ break;
+ }
+ if (!TEST_int_eq(numshared, numshared_expected)
+ || !TEST_int_eq(hash, hash_expected)
+ || !TEST_int_eq(sig, sig_expected)
+ || !TEST_true(SSL_get0_peer_signature_name(clientssl, &sigalg_name))
+ || !TEST_ptr(sigalg_name)
+ || !TEST_str_eq(sigalg_name, signame_expected))
goto end;
testresult = filter_provider_check_clean_finish();
OSSL_PROVIDER *defaultprov = OSSL_PROVIDER_load(libctx, "default");
char *certfilename = "tls-prov-cert.pem";
char *privkeyfilename = "tls-prov-key.pem";
+ const char *sigalg_name = NULL, *expected_sigalg_name;
int sigidx = idx % 3;
int rpkidx = idx / 3;
int do_conf_cmd = 0;
do_conf_cmd = 1;
}
+ /* See create_cert_key() above */
+ expected_sigalg_name = (sigidx == 0) ? "xorhmacsig" : "xorhmacsha2sig";
+
/* create key and certificate for the different algorithm types */
if (!TEST_ptr(tlsprov)
|| !TEST_true(create_cert_key(sigidx, certfilename, privkeyfilename)))
if (rpkidx && !TEST_long_eq(SSL_get_verify_result(clientssl), X509_V_ERR_RPK_UNTRUSTED))
goto end;
+ if (!TEST_true(SSL_get0_peer_signature_name(clientssl, &sigalg_name))
+ || !TEST_str_eq(sigalg_name, expected_sigalg_name)
+ || !TEST_ptr(sigalg_name))
+ goto end;
+
testresult = 1;
end:
SSL_get_min_proto_version define
SSL_get_mode define
SSL_get_peer_certificate define deprecated 3.0.0
+SSL_get0_peer_signature_name define
SSL_get_peer_signature_nid define
SSL_get_peer_tmp_key define
SSL_get_secure_renegotiation_support define
SSL_get_shared_curve define
SSL_get_shared_group define
SSL_get_negotiated_group define
+SSL_get0_signature_name define
SSL_get_signature_nid define
SSL_get_time define
SSL_get_timeout define