コード例 #1
0
    def test_single_and_should_match_solo(self):
        expected_result = bytearray.fromhex(
            "3F44FB41486D4A36A8ADCA2203E73A5068BFED5FDCE5092B9A3C6CCE8ABF3B0C")

        test1 = t2pc.PolicyTreeSolo(
            t2pc.PolicyCommandCode("TPM_CC_ClearControl"))
        test2 = t2pc.PolicyTreeSolo(t2pc.PolicyCommandCode("TPM_CC_Clear"))
        orTest = t2pc.PolicyTreeOr([test1, test2])

        phash = t2pc.PolicyHasher('sha256')
        self.assertEqual(orTest.get_policy(phash), expected_result)
コード例 #2
0
    def test_complex_policy_1(self):
        expected_result = bytearray.fromhex(
            "DFFDB6C8EAFCBE691E358882B18703121EAB40DE2386F7A8E7B4A06591E1F0EE")

        # Computation details:
        #   A = TPM2_PolicyLocality(3 & 4)
        #   B = TPM2_PolicyCommandCode(TPM_CC_NV_UndefineSpaceSpecial)
        #   C = TPM2_PolicyCommandCode(TPM_CC_NV_Write)
        #   policy = {{A} AND {C}} OR {{A} AND {B}}

        a = t2pc.PolicyLocality([3, 4])
        b = t2pc.PolicyCommandCode('TPM_CC_NV_UndefineSpaceSpecial')
        c = t2pc.PolicyCommandCode('TPM_CC_NV_Write')

        leg1 = t2pc.PolicyTreeAnd([a, c])
        leg2 = t2pc.PolicyTreeAnd([a, b])
        final = t2pc.PolicyTreeOr([leg1, leg2])

        phash = t2pc.PolicyHasher('sha256')
        self.assertEqual(final.get_policy(phash), expected_result)