Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: ecdsa - Fix enc/dec size reported by KEYCTL_PKEY_QUERY

KEYCTL_PKEY_QUERY system calls for ecdsa keys return the key size as
max_enc_size and max_dec_size, even though such keys cannot be used for
encryption/decryption. They're exclusively for signature generation or
verification.

Only rsa keys with pkcs1 encoding can also be used for encryption or
decryption.

Return 0 instead for ecdsa keys (as well as ecrdsa keys).

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Ignat Korchagin <ignat@cloudflare.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Lukas Wunner and committed by
Herbert Xu
3828485e 61bb8db6

+7 -2
+7 -2
crypto/asymmetric_keys/public_key.c
··· 188 188 ptr = pkey_pack_u32(ptr, pkey->paramlen); 189 189 memcpy(ptr, pkey->params, pkey->paramlen); 190 190 191 + memset(info, 0, sizeof(*info)); 192 + 191 193 if (issig) { 192 194 sig = crypto_alloc_sig(alg_name, 0, 0); 193 195 if (IS_ERR(sig)) { ··· 213 211 info->supported_ops |= KEYCTL_SUPPORTS_SIGN; 214 212 215 213 if (strcmp(params->encoding, "pkcs1") == 0) { 214 + info->max_enc_size = len; 215 + info->max_dec_size = len; 216 + 216 217 info->supported_ops |= KEYCTL_SUPPORTS_ENCRYPT; 217 218 if (pkey->key_is_private) 218 219 info->supported_ops |= KEYCTL_SUPPORTS_DECRYPT; ··· 237 232 len = crypto_akcipher_maxsize(tfm); 238 233 info->max_sig_size = len; 239 234 info->max_data_size = len; 235 + info->max_enc_size = len; 236 + info->max_dec_size = len; 240 237 241 238 info->supported_ops = KEYCTL_SUPPORTS_ENCRYPT; 242 239 if (pkey->key_is_private) ··· 246 239 } 247 240 248 241 info->key_size = len * 8; 249 - info->max_enc_size = len; 250 - info->max_dec_size = len; 251 242 252 243 ret = 0; 253 244