Exemple #1
0
 def decode_from_pem_key(cls, key):
     keyType = SubjectPublicKeyInfo()
     der = pem.pem_to_der_public_key(key)
     key_asn1 = decoder.decode(der, asn1Spec=keyType)[0]
     if len(key_asn1) < 1:
         raise ValueError("No RSA public key found after ASN.1 decoding.")
     return key_asn1
Exemple #2
0
 def decode_from_pem_key(cls, key):
     keyType = SubjectPublicKeyInfo()
     der = pem_to_der_public_key(key)
     key_asn1 = decoder.decode(der, asn1Spec=keyType)[0]
     if len(key_asn1) < 1:
         raise ValueError("No RSA public key found after ASN.1 decoding.")
     return key_asn1
 def test_codec_identity(self):
   self.assertEqual(der_to_pem_public_key(
     pem_to_der_public_key(public_key)).strip(), public_key.strip())
   self.assertEqual(der_to_pem_certificate(
     pem_to_der_certificate(certificate)).strip(), certificate.strip())
   self.assertEqual(der_to_pem_private_key(
     pem_to_der_private_key(private_key)).strip(), private_key.strip())
   self.assertEqual(der_to_pem_private_rsa_key(
     pem_to_der_private_rsa_key(private_rsa_key)).strip(),
                    private_rsa_key.strip())
 def test_codec_identity(self):
   self.assertEqual(pem.der_to_pem_public_key(
     pem.pem_to_der_public_key(PUBLIC_KEY)).strip(), PUBLIC_KEY.strip())
   self.assertEqual(pem.der_to_pem_certificate(
     pem.pem_to_der_certificate(CERTIFICATE)).strip(), CERTIFICATE.strip())
   self.assertEqual(pem.der_to_pem_private_key(
     pem.pem_to_der_private_key(PRIVATE_KEY)).strip(), PRIVATE_KEY.strip())
   self.assertEqual(pem.der_to_pem_private_rsa_key(
     pem.pem_to_der_private_rsa_key(PRIVATE_RSA_KEY)).strip(),
                    PRIVATE_RSA_KEY.strip())
 def test_decode(self):
   self.assertEqual(pem_to_der_public_key(public_key), public_key_der)
 def test_decode(self):
   self.assertEqual(pem.pem_to_der_public_key(PUBLIC_KEY), PUBLIC_KEY_DER)