Exemplo n.º 1
0
def test_invalid_key_size(data_dir):
    """Test Invalid Key size for ROTKH computation"""
    cfpa = CMPA("lpc55s6x")
    keys_path = [
        data_dir + "/ec_secp384r1_cert0.pem",
        data_dir + "/ec_secp384r1_cert1.pem",
        data_dir + "/ec_secp384r1_cert2.pem",
        data_dir + "/ec_secp384r1_cert3.pem",
    ]

    with pytest.raises(SPSDKPfrError):
        cfpa.export(keys=extract_public_keys(keys_path, password=None))
Exemplo n.º 2
0
def test_generate_cmpa(data_dir):
    """Test PFR tool - Generating CMPA binary."""
    binary = load_file(data_dir, "CMPA_96MHz.bin", mode="rb")
    key = load_pem_private_key(
        load_file(data_dir, "selfsign_privatekey_rsa2048.pem", mode="rb"),
        password=None,
        backend=default_backend(),
    )

    pfr_cfg_json = PfrConfiguration(os.path.join(data_dir, "cmpa_96mhz.json"))
    cmpa_json = CMPA("lpc55s6x", user_config=pfr_cfg_json)
    assert binary == cmpa_json.export(add_seal=False, keys=[key.public_key()])

    pfr_cfg_yml = PfrConfiguration(os.path.join(data_dir, "cmpa_96mhz.yml"))
    cmpa_yml = CMPA("lpc55s6x", user_config=pfr_cfg_yml)
    assert binary == cmpa_yml.export(add_seal=False, keys=[key.public_key()])
Exemplo n.º 3
0
def test_generate_cmpa(data_dir):
    config = json.loads(load_file(data_dir, 'cmpa_96mhz.json'))
    binary = load_file(data_dir, 'CMPA_96MHz.bin', mode='rb')
    key = load_pem_private_key(load_file(data_dir,
                                         'selfsign_privatekey_rsa2048.pem',
                                         mode='rb'),
                               password=None,
                               backend=default_backend())

    cmpa = CMPA('lpc55s6x',
                keys=[key.public_key()],
                user_config=config['settings'])
    assert binary == cmpa.export(add_seal=False, compute_inverses=True)
Exemplo n.º 4
0
def test_lpc55s3x_binary_ec384(data_dir):
    """Test silicon LPC55S3x ECC384. Binary generation/ROTKH computation"""
    cfpa = CMPA("lpc55s3x")
    keys_path = [
        data_dir + "/ec_secp384r1_cert0.pem",
        data_dir + "/ec_secp384r1_cert1.pem",
        data_dir + "/ec_secp384r1_cert2.pem",
        data_dir + "/ec_secp384r1_cert3.pem",
    ]

    data = cfpa.export(keys=extract_public_keys(keys_path, password=None))

    assert len(data) == 512
    with open(data_dir + "/lpc55s3x_CMPA_384.bin", "rb") as binary:
        assert data == binary.read()
Exemplo n.º 5
0
def test_basic_cmpa():
    cmpa = CMPA('lpc55s6x')
    with pytest.raises(AssertionError):
        cmpa.export()