{
    "Function": "pkcs1Sha1",
    "File": "packages/protocol/contracts/automata-attestation/utils/RsaVerify.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [
        "staticcall(uint256,uint256,uint256,uint256,uint256,uint256)",
        "pop(uint256)",
        "gas()",
        "bytes.concat()"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function pkcs1Sha1(\n        bytes20 _sha1,\n        bytes memory _s,\n        bytes memory _e,\n        bytes memory _m\n    )\n        internal\n        view\n        returns (bool)\n    {\n        uint8[15] memory sha1Prefix = [\n            0x30,\n            0x21,\n            0x30,\n            0x09,\n            0x06,\n            0x05,\n            0x2b,\n            0x0e,\n            0x03,\n            0x02,\n            0x1a,\n            0x05,\n            0x00,\n            0x04,\n            0x14\n        ];\n\n        // decipher\n        bytes memory input =\n            bytes.concat(bytes32(_s.length), bytes32(_e.length), bytes32(_m.length), _s, _e, _m);\n        uint256 inputlen = input.length;\n\n        uint256 decipherlen = _m.length;\n        bytes memory decipher = new bytes(decipherlen);\n        assembly {\n            pop(\n                staticcall(\n                    sub(gas(), 2000),\n                    5,\n                    add(input, 0x20),\n                    inputlen,\n                    add(decipher, 0x20),\n                    decipherlen\n                )\n            )\n        }\n\n        // Check that is well encoded:\n        // 0x00 || 0x01 || PS || 0x00 || DigestInfo\n        // PS is padding filled with 0xff\n        // DigestInfo ::= SEQUENCE {\n        //    digestAlgorithm AlgorithmIdentifier,\n        //    digest OCTET STRING\n        // }\n\n        uint256 paddingLen = decipherlen - 3 - sha1Prefix.length - 20;\n\n        if (decipher[0] != 0 || decipher[1] != 0x01) {\n            return false;\n        }\n        for (uint256 i = 2; i < 2 + paddingLen; ++i) {\n            if (decipher[i] != 0xff) {\n                return false;\n            }\n        }\n        if (decipher[2 + paddingLen] != 0) {\n            return false;\n        }\n\n        // check digest algorithm\n        for (uint256 i; i < sha1Prefix.length; ++i) {\n            if (decipher[3 + paddingLen + i] != bytes1(sha1Prefix[i])) {\n                return false;\n            }\n        }\n\n        // check digest\n        for (uint256 i; i < _sha1.length; ++i) {\n            if (decipher[3 + paddingLen + sha1Prefix.length + i] != _sha1[i]) {\n                return false;\n            }\n        }\n\n        return true;\n    }"
}