Beispiel #1
0
def test_keypair_faulty():
	with pytest.raises(ValueError):
		k = objects.RSAKey(0xe0fc)
		crypto.generate_pair(key_object=k, key_size=100)

	with pytest.raises(ValueError):
		objects.RSAKey(0xe0f1)
def test_meta_check_key_usage_rsa():
    obj = objects.RSAKey(0xe0fc)
    crypto.generate_pair(key_object=obj,
                         key_size=1024,
                         key_usage=['key_agreement', 'encryption'])
    assert ['key_agreement', 'encryption'] == obj.meta['key_usage'] or \
           ['encryption', 'key_agreement'] == obj.meta['key_usage']
Beispiel #3
0
def test_keypair_2k_keyid(ki):
	k = objects.RSAKey(ki)
	pkey, _ = crypto.generate_pair(key_object=k, key_size=2048)
	assert isinstance(pkey, bytes)
	assert len(pkey) > 0
	assert k.id == ki
	assert k.key_size == 2048
def test_csr_ok_rsa(ki):
    csr_key_obj = objects.RSAKey(0xe0fc)
    print(csr_key_obj)
    pkey, _ = crypto.generate_pair(key_object=csr_key_obj, key_size=ki)

    builder = CSRBuilder(
        {
            'country_name': 'DE',
            'state_or_province_name': 'Bayern',
            'organization_name': 'Infineon Technologies AG',
            'common_name': 'OPTIGA(TM) Trust IoT',
        }, pkey)

    builder.build(csr_key_obj)
def test_meta_read_key_meta():
    obj = objects.ECCKey(0xe0f0)
    print(obj.meta)
    obj = objects.RSAKey(0xe0fc)
    print(obj.meta)
def test_meta_check_algorithm_rsa(key_size):
    obj = objects.RSAKey(0xe0fc)
    crypto.generate_pair(key_object=obj, key_size=key_size)
    assert ('rsa' + str(key_size)) == obj.meta['algorithm']
Beispiel #7
0
def test_keypair_1k():
	k = objects.RSAKey(0xe0fc)
	pkey, _ = crypto.generate_pair(key_object=k, key_size=1024)
	assert isinstance(pkey, bytes)
	assert len(pkey) > 0
	assert k.key_size == 1024
Beispiel #8
0
def setup_keys_2k():
    k1 = objects.RSAKey(0xe0fc)
    k2 = objects.RSAKey(0xe0fd)
    pytest.twok, _ = crypto.generate_pair(key_object=k1, key_size=2048)
    pytest.twok_fail, _ = crypto.generate_pair(key_object=k2, key_size=2048)
    return k1, k2
Beispiel #9
0
def setup_keys_1k():
    k1 = objects.RSAKey(0xe0fc)
    k2 = objects.RSAKey(0xe0fd)
    pytest.onek, _ = crypto.generate_pair(key_object=k1, key_size=1024)
    pytest.onek_fail, _ = crypto.generate_pair(key_object=k2, key_size=1024)
    return k1, k2