Esempio n. 1
0
    def test_no_ecc(self):
        cap_data = TPMS_CAPABILITY_DATA()
        cap_data.data.algorithms[0] = TPMS_ALG_PROPERTY(alg=TPM2_ALG.RSA)

        def mock_getcap(*args, **kwargs):
            return (False, cap_data)

        self.ectx.get_capability = mock_getcap

        TSSPrivKey.create_ecc(self.ectx)
Esempio n. 2
0
    def test_no_ecc_no_rsa(self):
        cap_data = TPMS_CAPABILITY_DATA()

        def mock_getcap(*args, **kwargs):
            return (False, cap_data)

        self.ectx.get_capability = mock_getcap

        with self.assertRaises(RuntimeError) as e:
            TSSPrivKey.create_ecc(self.ectx)
        self.assertEqual(str(e.exception),
                         "Unable to find supported parent key type")
Esempio n. 3
0
    def test_persistent_parent_ecc(self):
        insens = TPM2B_SENSITIVE_CREATE()
        inpublic = TPM2B_PUBLIC(publicArea=parent_ecc_template)
        parent, _, _, _, _ = self.ectx.CreatePrimary(insens, inpublic)
        phandle = self.ectx.EvictControl(
            ESYS_TR.RH_OWNER, parent, 0x81000081, session1=ESYS_TR.PASSWORD
        )

        key = TSSPrivKey.create_ecc(self.ectx, parent=0x81000081)
        key.load(self.ectx)
        self.assertEqual(key.parent, 0x81000081)
Esempio n. 4
0
 def test_create_load_ecc(self):
     key = TSSPrivKey.create_ecc(self.ectx)
     key.load(self.ectx)
Esempio n. 5
0
 def test_create_no_password_load_password(self):
     key = TSSPrivKey.create_ecc(self.ectx)
     with self.assertWarns(UserWarning) as w:
         key.load(self.ectx, password=b"1234")
     self.assertEqual(str(w.warning),
                      "password specified but empty_auth is true")
Esempio n. 6
0
 def test_create_password_load_no_password(self):
     key = TSSPrivKey.create_ecc(self.ectx, password=b"1234")
     with self.assertRaises(RuntimeError) as e:
         key.load(self.ectx)
     self.assertEqual(str(e.exception),
                      "no password specified but it is required")
Esempio n. 7
0
 def test_create_load_ecc_password(self):
     key = TSSPrivKey.create_ecc(self.ectx, password=b"1234")
     key.load(self.ectx, password=b"1234")