-
Notifications
You must be signed in to change notification settings - Fork 21
/
test_slot.py
52 lines (40 loc) · 1.39 KB
/
test_slot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2023 Ledger SAS
# SPDX-License-Identifier: LicenseRef-LEDGER
"""
This module provides Ragger tests for Slots feature
"""
import pytest
from ragger.backend import BackendInterface
from application_client.command_sender import CommandSender
from application_client.app_def import Errors, DataObject, PassWord
from utils import check_pincode, generate_key
def test_slot(backend: BackendInterface) -> None:
# Use the app interface instead of raw interface
client = CommandSender(backend)
# Check slots availability
nb_slots, def_slot = client.get_slot_config()
print("Slots configuration:")
print(f" Nb: {nb_slots}")
print(f" default: {def_slot}")
if nb_slots == 1:
pytest.skip("single slot configuration")
# Generate the SIG Key Pair
generate_key(client, DataObject.DO_SIG_KEY)
# Read slot
slot = client.get_slot()
assert slot == 0
# Read the SIG pub Key
rapdu = client.read_key(DataObject.DO_SIG_KEY)
assert rapdu.status == Errors.SW_OK
# Verify PW2
check_pincode(client, PassWord.PW2)
# Change slot
rapdu = client.set_slot(2)
assert rapdu.status == Errors.SW_OK
# Read slot
slot = client.get_slot()
assert slot == 2
# Read an empty pub key
rapdu = client.read_key(DataObject.DO_SIG_KEY)
assert rapdu.status == Errors.SW_REFERENCED_DATA_NOT_FOUND