Skip to content

Commit 745742d

Browse files
holger-denglerhcahca
authored andcommitted
s390/pkey: fix PKEY_TYPE_EP11_AES handling in PKEY_VERIFYKEY2 IOCTL
Commit 'fa6999e326fe ("s390/pkey: support CCA and EP11 secure ECC private keys")' introduced a new PKEY_TYPE_EP11_AES type for the PKEY_VERIFYKEY2 IOCTL to verify keyblobs of this type. Unfortunately, all PKEY_VERIFYKEY2 IOCTL requests with keyblobs of this type return with an error (-EINVAL). Fix PKEY_TYPE_EP11_AES handling in PKEY_VERIFYKEY2 IOCTL, so that userspace can verify keyblobs of this type. Fixes: fa6999e ("s390/pkey: support CCA and EP11 secure ECC private keys") Signed-off-by: Holger Dengler <[email protected]> Reviewed-by: Ingo Franzki <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent d1fdfb0 commit 745742d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/s390/crypto/pkey_api.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ static int pkey_verifykey2(const u8 *key, size_t keylen,
912912
*ksize = kb->head.bitlen;
913913

914914
rc = ep11_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain,
915-
ZCRYPT_CEX7, EP11_API_V, kb->wkvp);
915+
ZCRYPT_CEX7, EP11_API_V,
916+
ep11_kb_wkvp(key, keylen));
916917
if (rc)
917918
goto out;
918919

@@ -922,6 +923,30 @@ static int pkey_verifykey2(const u8 *key, size_t keylen,
922923
*cardnr = ((struct pkey_apqn *)_apqns)->card;
923924
*domain = ((struct pkey_apqn *)_apqns)->domain;
924925

926+
} else if (hdr->type == TOKTYPE_NON_CCA &&
927+
hdr->version == TOKVER_EP11_AES_WITH_HEADER) {
928+
struct ep11kblob_header *kh = (struct ep11kblob_header *)key;
929+
930+
rc = ep11_check_aes_key_with_hdr(debug_info, 3,
931+
key, keylen, 1);
932+
if (rc)
933+
goto out;
934+
if (ktype)
935+
*ktype = PKEY_TYPE_EP11_AES;
936+
if (ksize)
937+
*ksize = kh->bitlen;
938+
939+
rc = ep11_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain,
940+
ZCRYPT_CEX7, EP11_API_V,
941+
ep11_kb_wkvp(key, keylen));
942+
if (rc)
943+
goto out;
944+
945+
if (flags)
946+
*flags = PKEY_FLAGS_MATCH_CUR_MKVP;
947+
948+
*cardnr = ((struct pkey_apqn *)_apqns)->card;
949+
*domain = ((struct pkey_apqn *)_apqns)->domain;
925950
} else {
926951
rc = -EINVAL;
927952
}

0 commit comments

Comments
 (0)