Ejemplo n.º 1
0
    def test_import_private_key_rsa2048_and_then_export(self):
        key_provider = KeyProvider()
        key_provider.setup_defaults()

        private_key = key_provider.import_private_key(
            TestData.RSA_PCKS8_2048_PRIVATE_KEY_DER)
        self.assertIsNotNone(private_key)

        exported_private_key = key_provider.export_private_key(private_key)
        self.assertIsNotNone(exported_private_key)

        self.assertEqual(TestData.RSA_PCKS8_2048_PRIVATE_KEY_DER,
                         exported_private_key)
Ejemplo n.º 2
0
    def test_import_private_key_ed25519_and_then_export(self):
        key_provider = KeyProvider()
        key_provider.setup_defaults()

        private_key = key_provider.import_private_key(
            TestData.ED25519_PRIVATE_KEY_PKCS8_DER)
        self.assertIsNotNone(private_key)

        exported_private_key = key_provider.export_private_key(private_key)
        self.assertIsNotNone(exported_private_key)

        self.assertEqual(TestData.ED25519_PRIVATE_KEY_PKCS8_DER,
                         exported_private_key)
Ejemplo n.º 3
0
    def export_private_key(private_key):
        # type: (VirgilPrivateKey) -> Union[Tuple[int], bytearray]
        """Exports private key to DER format

        Args:
            private_key: private key for export.


        Returns:
            Private key in DER format
        """
        key_provider = KeyProvider()
        rand = CtrDrbg()
        key_provider.set_random(rand)
        key_provider.setup_defaults()

        return key_provider.export_private_key(private_key.private_key)