Skip to content

Commit

Permalink
Fix and rename sig_scheme_to_nid
Browse files Browse the repository at this point in the history
This recently started failing in the `client_real_world` test,
as the server switched to an ECDSA cert chain.
  • Loading branch information
ctz committed Jan 15, 2025
1 parent 37e6e49 commit 353ce99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::ffi::{c_int, CStr};
use openssl_sys::{
NID_X9_62_prime256v1, NID_rsaEncryption, NID_rsassaPss, NID_secp384r1, NID_secp521r1,
NID_ED25519, NID_ED448, NID_X25519, NID_X448,
NID_X9_62_id_ecPublicKey, NID_X9_62_prime256v1, NID_rsaEncryption, NID_rsassaPss,
NID_secp384r1, NID_secp521r1, NID_ED25519, NID_ED448, NID_X25519, NID_X448,
};

use rustls::{AlertDescription, NamedGroup, SignatureScheme};
Expand Down Expand Up @@ -88,14 +88,14 @@ pub fn alert_desc_to_short_string(value: c_int) -> &'static CStr {
}
}

pub fn sig_scheme_to_nid(scheme: SignatureScheme) -> Option<c_int> {
pub fn sig_scheme_to_type_nid(scheme: SignatureScheme) -> Option<c_int> {
use SignatureScheme::*;
match scheme {
RSA_PKCS1_SHA256 | RSA_PKCS1_SHA384 | RSA_PKCS1_SHA512 => Some(NID_rsaEncryption),
RSA_PSS_SHA256 | RSA_PSS_SHA384 | RSA_PSS_SHA512 => Some(NID_rsassaPss),
ECDSA_NISTP256_SHA256 => Some(NID_X9_62_prime256v1),
ECDSA_NISTP384_SHA384 => Some(NID_secp384r1),
ECDSA_NISTP521_SHA512 => Some(NID_secp521r1),
ECDSA_NISTP256_SHA256 | ECDSA_NISTP384_SHA384 | ECDSA_NISTP521_SHA512 => {
Some(NID_X9_62_id_ecPublicKey)
}
ED25519 => Some(NID_ED25519),
ED448 => Some(NID_ED448),
// Omitted: SHA1 legacy schemes.
Expand Down
4 changes: 2 additions & 2 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};

use crate::bio::{Bio, BIO, BIO_METHOD};
use crate::callbacks::SslCallbackContext;
use crate::constants::{named_group_to_nid, sig_scheme_to_nid};
use crate::constants::{named_group_to_nid, sig_scheme_to_type_nid};
use crate::error::{ffi_panic_boundary, Error, MysteriouslyOppositeReturnValue};
use crate::evp_pkey::EvpPkey;
use crate::ex_data::ExData;
Expand Down Expand Up @@ -1192,7 +1192,7 @@ entry! {
let sigalg_nid = try_clone_arc!(ssl)
.get()
.get_last_verification_sig_scheme()
.and_then(sig_scheme_to_nid);
.and_then(sig_scheme_to_type_nid);

match sigalg_nid {
Some(nid) => {
Expand Down

0 comments on commit 353ce99

Please sign in to comment.