示例#1
0
def test_uct04_activate_locking_sp(nvme0, comid, new_passwd=b'123456'):
    # take ownership
    tcg.Command(nvme0, comid).start_anybody_adminsp_session(0x65).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).get_msid_cpin_pin(hsn, tsn).send()
    password = tcg.Response(nvme0, comid).receive().get_c_pin_msid()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    tcg.Command(nvme0, comid).start_adminsp_session(0x66, password).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).set_sid_cpin_pin(hsn, tsn, new_passwd).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # activate locking sp
    tcg.Command(nvme0, comid).start_adminsp_session(0x66, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).get_locking_sp_lifecycle(hsn, tsn).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).activate(hsn, tsn).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()
示例#2
0
def test_uct08_erasing_range(nvme0,
                             nvme0n1,
                             qpair,
                             verify,
                             comid,
                             new_passwd=b'123456'):
    # TODO: skip on pyrite

    # verify data before erasing
    buf = d.Buffer(64 * 512)
    nvme0n1.read(qpair, buf, 0, 64).waitdone()
    assert buf.data(11, 8) == 0x5aa55aa5

    # erasing
    tcg.Command(nvme0, comid).start_auth_session(0x69, 0, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).get_active_key(hsn, tsn, 1).send()
    prev_data = tcg.Response(nvme0, comid).receive().get_active_key()
    tcg.Command(nvme0, comid).gen_new_key(hsn, tsn, 1, prev_data).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # verify
    buf = d.Buffer(64 * 512)
    nvme0n1.read(qpair, buf, 0, 64).waitdone()
    assert buf.data(11, 8) == 0
示例#3
0
def test_uct12_revert_locking_sp(nvme0, comid, new_passwd=b'123456'):
    # revert
    orig_timeout = nvme0.timeout
    nvme0.timeout = 100000
    tcg.Command(nvme0, comid).start_adminsp_session(0x69, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).revert_tper(hsn, tsn).send()
    tcg.Response(nvme0, comid).receive()
    nvme0.timeout = orig_timeout
示例#4
0
def test_uct07_unlocking_range(nvme0,
                               nvme0n1,
                               qpair,
                               verify,
                               comid,
                               new_passwd=b'123456'):
    tcg.Command(nvme0, comid).start_auth_session(0x69, 0, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).lock_unlock_range(hsn, tsn, 1, False,
                                                False).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    buf = d.Buffer(64 * 512)
    nvme0n1.read(qpair, buf, 0, 64).waitdone()
    assert buf.data(11, 8) == 0x5aa55aa5
示例#5
0
def test_uct02_properties(nvme0):
    host_properties = {
        b"MaxComPacketSize": 4096,
        b"MaxPacketSize": 4076,
        b"MaxIndTokenSize": 4040,
    }

    comid = tcg.Response(nvme0).receive().level0_discovery()
    tcg.Command(nvme0, comid).properties(host_properties).send()
    tcg.Response(nvme0, comid).receive()
示例#6
0
def test_uct06_configuring_locking_objects(nvme0,
                                           nvme0n1,
                                           qpair,
                                           subsystem,
                                           verify,
                                           comid,
                                           new_passwd=b'123456'):
    # setup range and link to user1
    tcg.Command(nvme0, comid).start_auth_session(0x69, 0, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).setup_range(hsn, tsn, 1, 0, 64).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).lock_unlock_range(hsn, tsn, 1, False,
                                                False).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # write and verify
    buf = d.Buffer(64 * 512, pvalue=0x5aa55aa5, ptype=32)
    nvme0n1.write(qpair, buf, 0, 64).waitdone()
    buf = d.Buffer(64 * 512)
    nvme0n1.read(qpair, buf, 0, 64).waitdone()
    assert buf.data(11, 8) == 0x5aa55aa5
示例#7
0
def test_uct05_configuring_authorities(nvme0, comid, new_passwd=b'123456'):
    # enable user1 and passwd
    tcg.Command(nvme0, comid).start_auth_session(0x66, 0, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).enable_user(hsn, tsn, 1).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).set_new_passwd(hsn, tsn, 1, b"111111").send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # admin auth session
    tcg.Command(nvme0, comid).start_auth_session(0x66, 0, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # user auth session and change passwd
    tcg.Command(nvme0, comid).start_auth_session(0x66, 1, b"111111").send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).set_new_passwd(hsn, tsn, 1, b"111111").send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()
示例#8
0
def test_uct03_take_ownership(nvme0, comid, new_passwd):
    # take ownership
    tcg.Command(nvme0, comid).start_anybody_adminsp_session(0x65).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).get_msid_cpin_pin(hsn, tsn).send()
    password = tcg.Response(nvme0, comid).receive().get_c_pin_msid()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    tcg.Command(nvme0, comid).start_adminsp_session(0x66, password).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).set_sid_cpin_pin(hsn, tsn, new_passwd).send()
    tcg.Response(nvme0, comid).receive()
    tcg.Command(nvme0, comid).end_session(hsn, tsn).send(False)
    tcg.Response(nvme0, comid).receive()

    # revert
    orig_timeout = nvme0.timeout
    nvme0.timeout = 100000
    tcg.Command(nvme0, comid).start_adminsp_session(0x69, new_passwd).send()
    hsn, tsn = tcg.Response(nvme0, comid).receive().start_session()
    tcg.Command(nvme0, comid).revert_tper(hsn, tsn).send()
    tcg.Response(nvme0, comid).receive()
    nvme0.timeout = orig_timeout