mtls_cert.rs 901 B

123456789101112131415161718192021222324
  1. //! Fuzz mTLS leaf-certificate parsing (`tls_client_auth`, RFC 8705).
  2. //!
  3. //! Arbitrary DER is hostile input: [`subject_dn`] and [`ensure_within_validity`]
  4. //! must fail closed on malformed bytes without panicking, and
  5. //! [`thumbprint_b64url`] hashes any bytes unconditionally. Validity is read
  6. //! against the wall clock, so this target never asserts a fixed verdict — only
  7. //! no-panic behavior and the fixed 43-character thumbprint length.
  8. #![no_main]
  9. use d_oauth::protocol::mtls::{ensure_within_validity, subject_dn, thumbprint_b64url};
  10. use libfuzzer_sys::fuzz_target;
  11. fuzz_target!(|data: &[u8]| {
  12. let _ = subject_dn(data);
  13. let _ = ensure_within_validity(data);
  14. let thumbprint = thumbprint_b64url(data);
  15. // base64url (no pad) of a SHA-256 digest is always 43 characters.
  16. assert_eq!(
  17. thumbprint.len(),
  18. 43,
  19. "thumbprint length is not the fixed SHA-256 rendering"
  20. );
  21. });