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

crypto: Add userspace report for cipher type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Steffen Klassert and committed by
Herbert Xu
07a5fa4a 792608e9

+37
+29
crypto/crypto_user.c
··· 70 70 return alg; 71 71 } 72 72 73 + static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg) 74 + { 75 + struct crypto_report_cipher rcipher; 76 + 77 + snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher"); 78 + 79 + rcipher.blocksize = alg->cra_blocksize; 80 + rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; 81 + rcipher.max_keysize = alg->cra_cipher.cia_max_keysize; 82 + 83 + NLA_PUT(skb, CRYPTOCFGA_REPORT_CIPHER, 84 + sizeof(struct crypto_report_cipher), &rcipher); 85 + 86 + return 0; 87 + 88 + nla_put_failure: 89 + return -EMSGSIZE; 90 + } 91 + 73 92 static int crypto_report_one(struct crypto_alg *alg, 74 93 struct crypto_user_alg *ualg, struct sk_buff *skb) 75 94 { ··· 117 98 if (alg->cra_type && alg->cra_type->report) { 118 99 if (alg->cra_type->report(skb, alg)) 119 100 goto nla_put_failure; 101 + 102 + goto out; 103 + } 104 + 105 + switch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) { 106 + case CRYPTO_ALG_TYPE_CIPHER: 107 + if (crypto_report_cipher(skb, alg)) 108 + goto nla_put_failure; 109 + 110 + break; 120 111 } 121 112 122 113 out:
+8
include/linux/cryptouser.h
··· 42 42 CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ 43 43 CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ 44 44 CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */ 45 + CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */ 45 46 __CRYPTOCFGA_MAX 46 47 47 48 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) ··· 66 65 char type[CRYPTO_MAX_NAME]; 67 66 unsigned int blocksize; 68 67 unsigned int digestsize; 68 + }; 69 + 70 + struct crypto_report_cipher { 71 + char type[CRYPTO_MAX_ALG_NAME]; 72 + unsigned int blocksize; 73 + unsigned int min_keysize; 74 + unsigned int max_keysize; 69 75 }; 70 76 71 77 struct crypto_report_blkcipher {