diff --git a/tests/device/cli/test_hsmauth.py b/tests/device/cli/test_hsmauth.py index d803b12d..7887fd1a 100644 --- a/tests/device/cli/test_hsmauth.py +++ b/tests/device/cli/test_hsmauth.py @@ -4,12 +4,22 @@ from cryptography.hazmat.primitives.asymmetric import ec from yubikit.management import CAPABILITY +from yubikit.hsmauth import ( + TAG_LABEL, + TAG_CONTEXT, + TAG_CREDENTIAL_PASSWORD, + INS_CALCULATE, + _parse_label, + _parse_credential_password, +) +from yubikit.core import Tlv from .. import condition import pytest import re import os import tempfile +import struct DEFAULT_MANAGEMENT_KEY = "00000000000000000000000000000000" NON_DEFAULT_MANAGEMENT_KEY = "11111111111111111111111111111111" @@ -49,13 +59,13 @@ def tmp_file(): @pytest.fixture(autouse=True) -@condition.capability(CAPABILITY.OATH) +@condition.capability(CAPABILITY.HSMAUTH) @condition.min_version(5, 4, 3) def preconditions(ykman_cli): ykman_cli("hsmauth", "reset", "-f") -class TestOATH: +class TestHsmAuth: def test_hsmauth_info(self, ykman_cli): output = ykman_cli("hsmauth", "info").output assert "version:" in output @@ -68,7 +78,27 @@ def test_hsmauth_reset(self, ykman_cli): ) +def calculate_session_keys_apdu(label, context, credential_password): + data = ( + Tlv(TAG_LABEL, _parse_label(label)) + + Tlv(TAG_CONTEXT, context) + + Tlv(TAG_CREDENTIAL_PASSWORD, _parse_credential_password(credential_password)) + ) + + apdu = struct.pack("