Skip to content

Expose peer signature algorithm and ML-DSA constants#511

Open
johnhurt wants to merge 1 commit into
cloudflare:masterfrom
johnhurt:mldsa-signature-algorithm
Open

Expose peer signature algorithm and ML-DSA constants#511
johnhurt wants to merge 1 commit into
cloudflare:masterfrom
johnhurt:mldsa-signature-algorithm

Conversation

@johnhurt
Copy link
Copy Markdown
Contributor

@johnhurt johnhurt commented Jun 2, 2026

Add Rust bindings for identifying the signature algorithm used by a TLS peer, including the post-quantum ML-DSA family added in the recent BoringSSL bump.

Changes

SslSignatureAlgorithm

  • ML_DSA_44 / ML_DSA_65 / ML_DSA_87 — constants for the ML-DSA (FIPS 204) signature schemes (SSL_SIGN_ML_DSA_44, etc.)
  • name() — wraps SSL_get_signature_algorithm_name, returning a human-readable name like "ecdsa_secp256r1_sha256" or "mldsa65". Uses include_curve=true for TLS 1.3-style names.
  • Display — formats as the algorithm name, or "unknown (0xNNNN)" for unrecognized codepoints.

SslRef

  • peer_signature_algorithm() — wraps SSL_get_peer_signature_algorithm, returning the signature scheme the peer used to authenticate the most recent handshake. Returns None when BoringSSL reports the zero sentinel (pre-handshake, session resumption, or protocol errors).

These bindings enable callers to identify post-quantum signature algorithms negotiated during TLS handshakes, which is needed for ML-DSA deployment monitoring and compliance.

Co-authored-by: Luke Valenta lvalenta@cloudflare.com

Add Rust bindings for identifying the signature algorithm used by a TLS
peer, including the post-quantum ML-DSA family.

Adds to SslSignatureAlgorithm:
  - ML_DSA_44 / ML_DSA_65 / ML_DSA_87 constants
  - name()   - wraps SSL_get_signature_algorithm_name
  - Display  - formats as the algorithm name or 'unknown (0xNNNN)'

Adds to SslRef:
  - peer_signature_algorithm() - wraps SSL_get_peer_signature_algorithm,
    returning None when BoringSSL reports the zero sentinel (pre-handshake,
    session resumption, or protocol errors).

Co-authored-by: Luke Valenta <lvalenta@cloudflare.com>
Comment thread boring/src/ssl/mod.rs
// `include_curve = true` returns the TLS 1.3 form for ECDSA algorithms
// (e.g. `ecdsa_secp256r1_sha256` rather than the TLS 1.2 `ecdsa_sha256`),
// matching what BoringSSL keylogs and modern TLS tooling use.
let ptr = ffi::SSL_get_signature_algorithm_name(self.0, true as c_int);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match surrounding style in the codebase:

Suggested change
let ptr = ffi::SSL_get_signature_algorithm_name(self.0, true as c_int);
let ptr = ffi::SSL_get_signature_algorithm_name(self.0, 1);

Comment thread boring/src/ssl/mod.rs
} else {
// SAFETY: BoringSSL returns a pointer to a static, NUL-terminated C string
// when non-null, and the documented contract guarantees valid UTF-8.
Some(str::from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match surrounding style in the codebase (https://github.com/cloudflare/boring/blob/master/boring/src/ssl/error.rs#L89, https://github.com/cloudflare/boring/blob/master/boring/src/error.rs#L264), and then we can drop the SAFETY comment.

Suggested change
Some(str::from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
CStr::from_ptr(ptr).to_str().ok()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants