@@ -21,11 +21,23 @@ contract Asn1DecodeHarness {
2121 }
2222}
2323
24+ contract CertManagerHarness is CertManager {
25+ using Asn1Decode for bytes ;
26+
27+ constructor () CertManager (new P384Verifier ()) {}
28+
29+ function verifyBasicConstraints (bytes memory der , bool ca ) external pure returns (int64 ) {
30+ return _verifyBasicConstraintsExtension (der, der.root (), ca);
31+ }
32+ }
33+
2434contract CertManagerTest is Test {
2535 Asn1DecodeHarness public harness;
36+ CertManagerHarness public certManagerHarness;
2637
2738 function setUp () public {
2839 harness = new Asn1DecodeHarness ();
40+ certManagerHarness = new CertManagerHarness ();
2941 }
3042
3143 // 's' INTEGER from cabundle[3] (2026-04-02 attestation): DER-encoded with a 0x00
@@ -41,6 +53,38 @@ contract CertManagerTest is Test {
4153 assertEq (lo, 0xa2eda9c549dc01460f5fe650814ebe0e7ee855d3bcffde95afd2e82e21df0eac );
4254 }
4355
56+ function test_BasicConstraintsEmptySequenceIsClientCert () public view {
57+ assertEq (int256 (certManagerHarness.verifyBasicConstraints (hex "3000 " , false )), - 1 );
58+ }
59+
60+ function test_BasicConstraintsEmptySequenceRejectsCACert () public {
61+ vm.expectRevert ("isCA must be true for CA certs " );
62+ certManagerHarness.verifyBasicConstraints (hex "3000 " , true );
63+ }
64+
65+ function test_BasicConstraintsAcceptsCAWithoutPathLen () public view {
66+ assertEq (int256 (certManagerHarness.verifyBasicConstraints (hex "30030101ff " , true )), - 1 );
67+ }
68+
69+ function test_BasicConstraintsAcceptsCAWithPathLen () public view {
70+ assertEq (int256 (certManagerHarness.verifyBasicConstraints (hex "30060101ff020100 " , true )), 0 );
71+ }
72+
73+ function test_BasicConstraintsRejectsOutOfBoundsChild () public {
74+ vm.expectRevert ("basicConstraints out of bounds " );
75+ certManagerHarness.verifyBasicConstraints (hex "3003020200 " , false );
76+ }
77+
78+ function test_BasicConstraintsRejectsTrailingFields () public {
79+ vm.expectRevert ("trailing basicConstraints fields " );
80+ certManagerHarness.verifyBasicConstraints (hex "30090101ff020100020100 " , true );
81+ }
82+
83+ function test_BasicConstraintsRejectsUnknownField () public {
84+ vm.expectRevert ("invalid basicConstraints field " );
85+ certManagerHarness.verifyBasicConstraints (hex "30020400 " , false );
86+ }
87+
4488 // Cert chain from the 2026-04-02 ~15:35 UTC dev attestation that produced the live revert.
4589 // CB0 is the AWS Nitro root (keccak256(CB0) == CertManager.ROOT_CA_CERT_HASH, pinned in the
4690 // constructor), so the chain is verified starting from CB1.
0 commit comments