예제 #1
0
def test_write_new_specific():
    with open(os.path.join(pytest.test_dir, 'fixtures/test-ec-ecdsa-cert.pem'),
              'rb') as f:
        der_bytes = f.read()
    obj = optiga_objects.X509(0xe0e1)
    old_meta = {'change': obj.meta['change']}
    obj.meta = {'change': 'always'}
    optiga_objects.X509(0xe0e1).der = der_bytes
    obj.meta = old_meta
예제 #2
0
def test_write_new_default():
    with pytest.raises(IOError):
        with open(
                os.path.join(pytest.test_dir,
                             'fixtures/test-ec-ecdsa-cert.pem'), 'rb') as f:
            der_bytes = f.read()
        optiga_objects.X509(0xe0e0).der = der_bytes
예제 #3
0
def test_read_existing_multiple_times():
    c = optiga_objects.X509(0xe0e0)
    _ = c.pem
    _ = c.pem
    _ = c.pem
    _ = c.pem
    _ = c.pem
예제 #4
0
def test_write_new_faulty_objid():
    with pytest.raises(ValueError):
        with open(
                os.path.join(pytest.test_dir,
                             'fixtures/test-ec-ecdsa-cert.pem'), 'rb') as f:
            wr_bytes = f.read()

        optiga_objects.X509(0xe0ec).der = wr_bytes
예제 #5
0
def test_read_existing_verify_result():
    c = optiga_objects.X509(0xe0e0)

    der_bytes = c.der
    asn1_x509.Certificate.load(der_bytes)

    pem_str = c.pem
    _, _, der_str = asn1_pem.unarmor(pem_str)
    asn1_x509.Certificate.load(der_str)
예제 #6
0
def test_write_new_locked_object():
    c = optiga_objects.X509(0xe0e1)
    old_meta = c.meta['change']
    with pytest.raises(IOError):
        with open(
                os.path.join(pytest.test_dir,
                             'fixtures/test-ec-ecdsa-cert.pem'), 'rb') as f:
            wr_bytes = f.read()

        c.meta = {"change": "never"}
        c.der = wr_bytes

    c.meta = {'change': old_meta}
예제 #7
0
def test_meta_read_certificate():
    obj = objects.X509(0xe0e0)
    print(obj.meta)
예제 #8
0
def test_read_existing():
    c = optiga_objects.X509(0xe0e0)
    assert isinstance(c.der, bytes)
예제 #9
0
def test_read_existing_faulty_objid():
    with pytest.raises(ValueError):
        optiga_objects.X509(0xe0e7)