Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tests/device/test_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_more_wrap_data(session):
key.delete()


def test_wrap_data_many(session):
def test_wrap_data_many(session, info):
key_label = "wrap key"
raw_key = os.urandom(24)
w_key = WrapKey.put(
Expand All @@ -235,16 +235,21 @@ def test_wrap_data_many(session):
raw_key,
)

if info.version >= (2, 5, 0):
code = ERROR.INSUFFICIENT_PERMISSIONS
else:
code = ERROR.INVALID_DATA

for ln in range(1, 64):
data = os.urandom(ln)
wrap = w_key.wrap_data(data)
with pytest.raises(YubiHsmDeviceError) as context:
u_key.wrap_data(data)
assert context.value.code == ERROR.INVALID_DATA
assert context.value.code == code
plain = u_key.unwrap_data(wrap)
with pytest.raises(YubiHsmDeviceError) as context:
w_key.unwrap_data(wrap)
assert context.value.code == ERROR.INVALID_DATA
assert context.value.code == code
assert data == plain

u_key.delete()
Expand Down