def test_export_priv_encrypt(self): from ctypescrypto.cipher import CipherType key=PKey(privkey=self.rsa) pem=key.exportpriv(password='******',cipher=CipherType("aes256")) if pyver >2: pem = pem.encode("ascii") self.assertEqual(runopenssl(["pkey","-text_pub","-noout","-passin","pass:2222"], pem),self.rsakeytext)
def test_export_priv_der_enc(self): from ctypescrypto.cipher import CipherType key = PKey(privkey=self.rsa) der = key.exportpriv(format="DER", password='******', cipher=CipherType("aes256")) self.assertEqual( runopenssl(["pkcs8", "-passin", "pass:2222", "-inform", "DER"], der), self.rsa)
def test_export_priv_encrypt(self): from ctypescrypto.cipher import CipherType key = PKey(privkey=self.rsa) pem = key.exportpriv(password='******', cipher=CipherType("aes256")) if pyver > 2: pem = pem.encode("ascii") self.assertEqual( runopenssl(["pkey", "-text_pub", "-noout", "-passin", "pass:2222"], pem), self.rsakeytext)
def test_export_priv_der_enc(self): from ctypescrypto.cipher import CipherType key=PKey(privkey=self.rsa) der=key.exportpriv(format="DER",password='******',cipher=CipherType("aes256")) self.assertEqual(runopenssl(["pkcs8","-passin","pass:2222","-inform","DER"], der),self.rsa)
def test_export_priv_der(self): key=PKey(privkey=self.rsa) der=key.exportpriv(format="DER") self.assertEqual(runopenssl(["pkey","-text_pub","-noout","-inform","DER"], der),self.rsakeytext)
def test_export_priv_pem(self): key=PKey(privkey=self.ec1priv) out=key.exportpriv() self.assertEqual(self.ec1priv,out)
def test_export_priv_der(self): key = PKey(privkey=self.rsa) der = key.exportpriv(format="DER") self.assertEqual( runopenssl(["pkey", "-text_pub", "-noout", "-inform", "DER"], der), self.rsakeytext)