示例#1
0
def test_plain_xip_crc_default_tz(data_dir, input_img, expected_mbi):
    """Test plain image with CRC and default TZ-M
    :param data_dir: absolute path, where test data are located
    :param input_img: file name of input image (binary)
    :param expected_mbi: file name of MBI image file with expected data
    """
    with open(os.path.join(data_dir, input_img), "rb") as f:
        org_data = f.read()

    mbi = MasterBootImage(app=org_data, load_addr=0, image_type=MasterBootImageType.CRC_XIP_IMAGE,
                          trust_zone=TrustZone.enabled())

    assert _compare_image(mbi, data_dir, expected_mbi)
示例#2
0
def test_plain_xip_crc_default_tz(data_dir, input_img, expected_mbi):
    """Test plain image with CRC and default TZ-M
    :param data_dir: absolute path, where test data are located
    :param input_img: file name of input image (binary)
    :param expected_mbi: file name of MBI image file with expected data
    """
    with open(os.path.join(data_dir, input_img), "rb") as f:
        org_data = f.read()

    mbi = Mbi_CrcXip(
        app=org_data,
        trust_zone=TrustZone.enabled(),
    )

    assert _compare_image(mbi, data_dir, expected_mbi)
示例#3
0
def test_tz_types(sample_tz_data):
    # TZ is enabled by default
    tz = TrustZone()
    assert tz.type == TrustZoneType.ENABLED
    tz = TrustZone.enabled()
    assert tz.type == TrustZoneType.ENABLED
    tz = TrustZone.disabled()
    assert tz.type == TrustZoneType.DISABLED

    tz = TrustZone(family="lpc55xx", customizations=sample_tz_data)
    assert tz.type == TrustZoneType.CUSTOM
    tz = TrustZone(family="lpc55xx",
                   customizations=sample_tz_data,
                   tz_type=TrustZoneType.CUSTOM)
    assert tz.type == TrustZoneType.CUSTOM
    tz = TrustZone(family="lpc55xx",
                   customizations=sample_tz_data,
                   tz_type=TrustZoneType.ENABLED)
    assert tz.type == TrustZoneType.CUSTOM
    tz = TrustZone.custom(family="lpc55xx", customizations=sample_tz_data)
    assert tz.type == TrustZoneType.CUSTOM
    assert "TrustZone" in str(tz)
示例#4
0
def test_simplified_export():
    assert TrustZone().export() == b""
    assert TrustZone.enabled().export() == b""
    assert TrustZone.disabled().export() == b""