Exemplo n.º 1
0
 def test_identifier_rsa(self):
     bytes = TestCertificates.PKCS1_rsa_ca.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     should = "FA:CC:60:F4:20:6B:25:C7:A4:AD:1D:FE:37:C4:76:09:73:07:BE:35:E9:50:2B:28:1A:10:6A:30:2C:09:D4:A9"
     ident = str(container.public_key_hash())
     self.assertEqual(ident, should)
Exemplo n.º 2
0
 def test_identifier_rsa(self):
     bytes = TestCertificates.PKCS1_rsa_ca.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     should = "FA:CC:60:F4:20:6B:25:C7:A4:AD:1D:FE:37:C4:76:09:73:07:BE:35:E9:50:2B:28:1A:10:6A:30:2C:09:D4:A9"
     ident = str(container.public_key_hash())
     self.assertEqual(ident, should)
Exemplo n.º 3
0
 def test_identifier_ec(self):
     bytes = TestCertificates.PKCS1_ec.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     should = "7D:83:F3:D5:9F:B1:CC:36:2B:50:E7:FD:7A:45:A1:60:63:48:FB:58:B7:AA:31:7A:A1:C4:B5:D4:C1:59:82:CE"
     ident = container.public_key_hash()
     self.assertEqual(ident, should)
Exemplo n.º 4
0
 def test_identifier_ec(self):
     bytes = TestCertificates.PKCS1_ec.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     should = "7D:83:F3:D5:9F:B1:CC:36:2B:50:E7:FD:7A:45:A1:60:63:48:FB:58:B7:AA:31:7A:A1:C4:B5:D4:C1:59:82:CE"
     ident = container.public_key_hash()
     self.assertEqual(ident, should)
Exemplo n.º 5
0
 def test_to_private_key(self):
     bytes = TestCertificates.PKCS1_ec.read()
     priv = PKCS1Reader.by_bytes(bytes)
     priv.parse()
     privatekey = strongMan.apps.certificates.models.certificates.PrivateKey.by_reader(priv)
     self.assertIsNotNone(privatekey)
     self.assertIsNotNone(privatekey.algorithm)
     self.assertIsNotNone(privatekey.der_container)
Exemplo n.º 6
0
    def test_is_private_key_not(self):
        bytes = TestCertificates.X509_ec.read()
        x509 = X509Reader.by_bytes(bytes)
        x509.parse()

        bytes = TestCertificates.PKCS1_rsa_ca.read()
        key = PKCS1Reader.by_bytes(bytes)
        key.parse()
        self.assertFalse(x509.is_cert_of(key))
Exemplo n.º 7
0
    def test_is_private_key_not(self):
        bytes = TestCertificates.X509_ec.read()
        x509 = X509Reader.by_bytes(bytes)
        x509.parse()

        bytes = TestCertificates.PKCS1_rsa_ca.read()
        key = PKCS1Reader.by_bytes(bytes)
        key.parse()
        self.assertFalse(x509.is_cert_of(key))
Exemplo n.º 8
0
 def test_to_private_key(self):
     bytes = TestCertificates.PKCS1_ec.read()
     priv = PKCS1Reader.by_bytes(bytes)
     priv.parse()
     privatekey = strongMan.apps.certificates.models.certificates.PrivateKey.by_reader(
         priv)
     self.assertIsNotNone(privatekey)
     self.assertIsNotNone(privatekey.algorithm)
     self.assertIsNotNone(privatekey.der_container)
Exemplo n.º 9
0
 def test_dump_rsa(self):
     bytes = TestCertificates.PKCS1_ec.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     self.assertIsNotNone(container.der_dump())
Exemplo n.º 10
0
 def test_algorithm_ec(self):
     bytes = TestCertificates.PKCS1_ec.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     self.assertEqual(container.algorithm(), "ec")
Exemplo n.º 11
0
 def test_parse(self):
     bytes = TestCertificates.PKCS1_rsa_ca.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     self.assertIsNotNone(container.asn1)
Exemplo n.º 12
0
 def test_dsa(self):
     bytes = TestCertificates.PKCS1_dsa.read()
     x509 = PKCS1Reader.by_bytes(bytes)
     with self.assertRaises(Exception):
         x509.parse()
Exemplo n.º 13
0
 def test_decryption(self):
     bytes = TestCertificates.PKCS1_rsa_ca_encrypted.read()
     container = PKCS1Reader.by_bytes(bytes, password=b"strongman")
     container.parse()
     self.assertEqual(container.algorithm(), "rsa")
Exemplo n.º 14
0
 def read_pkcs1(self, password=None):
     bytes = self.read()
     reader = PKCS1Reader.by_bytes(bytes, password)
     reader.parse()
     return reader
Exemplo n.º 15
0
 def test_dump_rsa(self):
     bytes = TestCertificates.PKCS1_rsa_ca.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     self.assertIsNotNone(container.der_dump())
Exemplo n.º 16
0
 def test_algorithm_ec(self):
     bytes = TestCertificates.PKCS1_ec.read()
     container = PKCS1Reader.by_bytes(bytes)
     container.parse()
     self.assertEqual(container.algorithm(), "ec")
Exemplo n.º 17
0
 def test_dsa(self):
     bytes = TestCertificates.PKCS1_dsa.read()
     x509 = PKCS1Reader.by_bytes(bytes)
     with self.assertRaises(Exception):
         x509.parse()
Exemplo n.º 18
0
 def test_decryption(self):
     bytes = TestCertificates.PKCS1_rsa_ca_encrypted.read()
     container = PKCS1Reader.by_bytes(bytes, password=b"strongman")
     container.parse()
     self.assertEqual(container.algorithm(), "rsa")