Skip to content

Commit 37a08f0

Browse files
holger-denglerhcahca
authored andcommitted
s390/pkey: fix/harmonize internal keyblob headers
Commit 'fa6999e326fe ("s390/pkey: support CCA and EP11 secure ECC private keys")' introduced PKEY_TYPE_EP11_AES as a supplement to PKEY_TYPE_EP11. All pkeys have an internal header/payload structure, which is opaque to the userspace. The header structures for PKEY_TYPE_EP11 and PKEY_TYPE_EP11_AES are nearly identical and there is no reason, why different structures are used. In preparation to fix the keyversion handling in the broken PKEY IOCTLs, the same header structure is used for PKEY_TYPE_EP11 and PKEY_TYPE_EP11_AES. This reduces the number of different code paths and increases the readability. 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 7645dcd commit 37a08f0

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

drivers/s390/crypto/pkey_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static int pkey_verifykey2(const u8 *key, size_t keylen,
895895
if (ktype)
896896
*ktype = PKEY_TYPE_EP11;
897897
if (ksize)
898-
*ksize = kb->head.keybitlen;
898+
*ksize = kb->head.bitlen;
899899

900900
rc = ep11_findcard2(&_apqns, &_nr_apqns, *cardnr, *domain,
901901
ZCRYPT_CEX7, EP11_API_V, kb->wkvp);

drivers/s390/crypto/zcrypt_ep11misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ int ep11_genaeskey(u16 card, u16 domain, u32 keybitsize, u32 keygenflags,
787787
kb->head.type = TOKTYPE_NON_CCA;
788788
kb->head.len = rep_pl->data_len;
789789
kb->head.version = TOKVER_EP11_AES;
790-
kb->head.keybitlen = keybitsize;
790+
kb->head.bitlen = keybitsize;
791791

792792
out:
793793
kfree(req);
@@ -1055,7 +1055,7 @@ static int ep11_unwrapkey(u16 card, u16 domain,
10551055
kb->head.type = TOKTYPE_NON_CCA;
10561056
kb->head.len = rep_pl->data_len;
10571057
kb->head.version = TOKVER_EP11_AES;
1058-
kb->head.keybitlen = keybitsize;
1058+
kb->head.bitlen = keybitsize;
10591059

10601060
out:
10611061
kfree(req);

drivers/s390/crypto/zcrypt_ep11misc.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ struct ep11keyblob {
2929
union {
3030
u8 session[32];
3131
/* only used for PKEY_TYPE_EP11: */
32-
struct {
33-
u8 type; /* 0x00 (TOKTYPE_NON_CCA) */
34-
u8 res0; /* unused */
35-
u16 len; /* total length in bytes of this blob */
36-
u8 version; /* 0x03 (TOKVER_EP11_AES) */
37-
u8 res1; /* unused */
38-
u16 keybitlen; /* clear key bit len, 0 for unknown */
39-
} head;
32+
struct ep11kblob_header head;
4033
};
4134
u8 wkvp[16]; /* wrapping key verification pattern */
4235
u64 attr; /* boolean key attributes */

0 commit comments

Comments
 (0)