@@ -17,6 +17,8 @@ contract CertManager is ICertManager {
1717 using LibAsn1Ptr for Asn1Ptr;
1818 using LibBytes for bytes ;
1919
20+ error InvalidCertSignature ();
21+
2022 event CertVerified (bytes32 indexed certHash );
2123 event CertRevoked (bytes32 indexed certHash );
2224 event CertUnrevoked (bytes32 indexed certHash );
@@ -557,17 +559,17 @@ contract CertManager is ICertManager {
557559 function _certSignature (bytes memory certificate , Asn1Ptr sigPtr ) internal pure returns (bytes memory sigPacked ) {
558560 Asn1Ptr sigBPtr = certificate.bitstring (sigPtr);
559561 Asn1Ptr sigRoot = certificate.rootOf (sigBPtr);
560- require (certificate[sigRoot.header ()] == 0x30 , " invalid cert signature " );
561- require (
562- sigRoot. header () + sigRoot. totalLength () == sigBPtr. content () + sigBPtr. length (), " invalid cert signature "
563- );
562+ if (certificate[sigRoot.header ()] != 0x30 ) revert InvalidCertSignature ( );
563+ if (sigRoot. header () + sigRoot. totalLength () != sigBPtr. content () + sigBPtr. length ()) {
564+ revert InvalidCertSignature ();
565+ }
564566 Asn1Ptr sigRPtr = certificate.firstChildOf (sigRoot);
565- require (certificate[sigRPtr.header ()] == 0x02 , " invalid cert signature " );
567+ if (certificate[sigRPtr.header ()] != 0x02 ) revert InvalidCertSignature ( );
566568 Asn1Ptr sigSPtr = certificate.nextSiblingOf (sigRPtr);
567- require (certificate[sigSPtr.header ()] == 0x02 , " invalid cert signature " );
568- require (
569- sigSPtr. header () + sigSPtr. totalLength () == sigRoot. content () + sigRoot. length (), " invalid cert signature "
570- );
569+ if (certificate[sigSPtr.header ()] != 0x02 ) revert InvalidCertSignature ( );
570+ if (sigSPtr. header () + sigSPtr. totalLength () != sigRoot. content () + sigRoot. length ()) {
571+ revert InvalidCertSignature ();
572+ }
571573 (uint128 rhi , uint256 rlo ) = certificate.uint384At (sigRPtr);
572574 (uint128 shi , uint256 slo ) = certificate.uint384At (sigSPtr);
573575 sigPacked = abi.encodePacked (rhi, rlo, shi, slo);
0 commit comments