Example #1
0
    def test_certs():
        cert = botan2.x509_cert(filename="src/tests/data/x509/ecc/CSCA.CSCA.csca-germany.1.crt")
        print("CSCA (Germany) Certificate\nDetails:")
        print("SHA-1 fingerprint:   %s" % cert.fingerprint("SHA-1"))
        print("Expected:            32:42:1C:C3:EC:54:D7:E9:43:EC:51:F0:19:23:BD:85:1D:F2:1B:B9")

        print("Not before:          %s" % cert.time_starts())
        print("Not after:           %s" % cert.time_expires())

        print("Serial number:       %s" % hex_encode(cert.serial_number()))
        print("Authority Key ID:    %s" % hex_encode(cert.authority_key_id()))
        print("Subject   Key ID:    %s" % hex_encode(cert.subject_key_id()))
        print("Public key bits:\n%s\n" % binascii.b2a_base64(cert.subject_public_key_bits()))

        pubkey = cert.subject_public_key()
        print("Public key algo:     %s" % pubkey.algo_name())
        print("Public key strength: %s" % pubkey.estimated_strength() + " bits")

        dn_fields = ("Name", "Email", "Organization", "Organizational Unit", "Country")
        for field in dn_fields:
            try:
                print("%s: %s" % (field, cert.subject_dn(field, 0)))
            except botan2.BotanException:
                print("Field: %s not found in certificate" % field)

        print(cert.to_string())
Example #2
0
    def test_certs():
        cert = botan2.x509_cert(filename="src/tests/data/x509/ecc/CSCA.CSCA.csca-germany.1.crt")
        print("CSCA (Germany) Certificate\nDetails:")
        print("SHA-1 fingerprint:   %s" % cert.fingerprint("SHA-1"))
        print("Expected:            32:42:1C:C3:EC:54:D7:E9:43:EC:51:F0:19:23:BD:85:1D:F2:1B:B9")

        print("Not before:          %s" % cert.time_starts())
        print("Not after:           %s" % cert.time_expires())

        print("Serial number:       %s" % hex_encode(cert.serial_number()))
        print("Authority Key ID:    %s" % hex_encode(cert.authority_key_id()))
        print("Subject   Key ID:    %s" % hex_encode(cert.subject_key_id()))
        print("Public key bits:\n%s\n" % binascii.b2a_base64(cert.subject_public_key_bits()))

        pubkey = cert.subject_public_key()
        print("Public key algo:     %s" % pubkey.algo_name())
        print("Public key strength: %s" % pubkey.estimated_strength() + " bits")

        dn_fields = ("Name", "Email", "Organization", "Organizational Unit", "Country")
        for field in dn_fields:
            try:
                print("%s: %s" % (field, cert.subject_dn(field, 0)))
            except botan2.BotanException:
                print("Field: %s not found in certificate" % field)

        print(cert.to_string())
Example #3
0
    def test_certs(self):
        cert = botan2.x509_cert(filename="src/tests/data/x509/ecc/CSCA.CSCA.csca-germany.1.crt")
        pubkey = cert.subject_public_key()

        self.assertEqual(pubkey.algo_name(), 'ECDSA')
        self.assertEqual(pubkey.estimated_strength(), 112)

        self.assertEqual(cert.fingerprint("SHA-1"),
                         "32:42:1C:C3:EC:54:D7:E9:43:EC:51:F0:19:23:BD:85:1D:F2:1B:B9")

        self.assertEqual(hex_encode(cert.serial_number()), "01")
        self.assertEqual(hex_encode(cert.authority_key_id()),
                         "0096452de588f966c4ccdf161dd1f3f5341b71e7")

        self.assertEqual(cert.subject_dn('Name', 0), 'csca-germany')
        self.assertEqual(cert.subject_dn('Email', 0), '*****@*****.**')
        self.assertEqual(cert.subject_dn('Organization', 0), 'bund')
        self.assertEqual(cert.subject_dn('Organizational Unit', 0), 'bsi')
        self.assertEqual(cert.subject_dn('Country', 0), 'DE')

        self.assertTrue(cert.to_string().startswith("Version: 3"))
Example #4
0
    def test_certs(self):
        cert = botan2.x509_cert(
            filename="src/tests/data/x509/ecc/CSCA.CSCA.csca-germany.1.crt")
        pubkey = cert.subject_public_key()

        self.assertEqual(pubkey.algo_name(), 'ECDSA')
        self.assertEqual(pubkey.estimated_strength(), 112)

        self.assertEqual(
            cert.fingerprint("SHA-1"),
            "32:42:1C:C3:EC:54:D7:E9:43:EC:51:F0:19:23:BD:85:1D:F2:1B:B9")

        self.assertEqual(hex_encode(cert.serial_number()), "01")
        self.assertEqual(hex_encode(cert.authority_key_id()),
                         "0096452de588f966c4ccdf161dd1f3f5341b71e7")

        self.assertEqual(cert.subject_dn('Name', 0), 'csca-germany')
        self.assertEqual(cert.subject_dn('Email', 0),
                         '*****@*****.**')
        self.assertEqual(cert.subject_dn('Organization', 0), 'bund')
        self.assertEqual(cert.subject_dn('Organizational Unit', 0), 'bsi')
        self.assertEqual(cert.subject_dn('Country', 0), 'DE')

        self.assertTrue(cert.to_string().startswith("Version: 3"))