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: drbg - make drbg_{ctr_bcc,kcapi_sym}() return *void*

drgb_kcapi_sym() always returns 0, so make it return void instead.
Consequently, make drbg_ctr_bcc() return void too.

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

[Sergey: fixed the subject, refreshed the patch]

Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Karina Yankevich and committed by
Herbert Xu
1617d93c 96feb73d

+14 -30
+14 -30
crypto/df_sp80090a.c
··· 17 17 static void drbg_kcapi_symsetkey(struct crypto_aes_ctx *aesctx, 18 18 const unsigned char *key, 19 19 u8 keylen); 20 - static int drbg_kcapi_sym(struct crypto_aes_ctx *aesctx, unsigned char *outval, 21 - const struct drbg_string *in, u8 blocklen_bytes); 22 - 23 20 static void drbg_kcapi_symsetkey(struct crypto_aes_ctx *aesctx, 24 21 const unsigned char *key, u8 keylen) 25 22 { 26 23 aes_expandkey(aesctx, key, keylen); 27 24 } 28 25 29 - static int drbg_kcapi_sym(struct crypto_aes_ctx *aesctx, unsigned char *outval, 30 - const struct drbg_string *in, u8 blocklen_bytes) 26 + static void drbg_kcapi_sym(struct crypto_aes_ctx *aesctx, 27 + unsigned char *outval, 28 + const struct drbg_string *in, u8 blocklen_bytes) 31 29 { 32 30 /* there is only component in *in */ 33 31 BUG_ON(in->len < blocklen_bytes); 34 32 aes_encrypt(aesctx, outval, in->buf); 35 - return 0; 36 33 } 37 34 38 35 /* BCC function for CTR DRBG as defined in 10.4.3 */ 39 36 40 - static int drbg_ctr_bcc(struct crypto_aes_ctx *aesctx, 41 - unsigned char *out, const unsigned char *key, 42 - struct list_head *in, 43 - u8 blocklen_bytes, 44 - u8 keylen) 37 + static void drbg_ctr_bcc(struct crypto_aes_ctx *aesctx, 38 + unsigned char *out, const unsigned char *key, 39 + struct list_head *in, 40 + u8 blocklen_bytes, 41 + u8 keylen) 45 42 { 46 - int ret = 0; 47 43 struct drbg_string *curr = NULL; 48 44 struct drbg_string data; 49 45 short cnt = 0; ··· 56 60 /* 10.4.3 step 4.2 */ 57 61 if (blocklen_bytes == cnt) { 58 62 cnt = 0; 59 - ret = drbg_kcapi_sym(aesctx, out, &data, blocklen_bytes); 60 - if (ret) 61 - return ret; 63 + drbg_kcapi_sym(aesctx, out, &data, blocklen_bytes); 62 64 } 63 65 out[cnt] ^= *pos; 64 66 pos++; ··· 66 72 } 67 73 /* 10.4.3 step 4.2 for last block */ 68 74 if (cnt) 69 - ret = drbg_kcapi_sym(aesctx, out, &data, blocklen_bytes); 70 - 71 - return ret; 75 + drbg_kcapi_sym(aesctx, out, &data, blocklen_bytes); 72 76 } 73 77 74 78 /* ··· 116 124 u8 blocklen_bytes, 117 125 u8 statelen) 118 126 { 119 - int ret = -EFAULT; 120 127 unsigned char L_N[8]; 121 128 /* S3 is input */ 122 129 struct drbg_string S1, S2, S4, cipherin; ··· 187 196 */ 188 197 drbg_cpu_to_be32(i, iv); 189 198 /* 10.4.2 step 9.2 -- BCC and concatenation with temp */ 190 - ret = drbg_ctr_bcc(aesctx, temp + templen, K, &bcc_list, 191 - blocklen_bytes, keylen); 192 - if (ret) 193 - goto out; 199 + drbg_ctr_bcc(aesctx, temp + templen, K, &bcc_list, 200 + blocklen_bytes, keylen); 194 201 /* 10.4.2 step 9.3 */ 195 202 i++; 196 203 templen += blocklen_bytes; ··· 209 220 * implicit as the key is only drbg_blocklen in size based on 210 221 * the implementation of the cipher function callback 211 222 */ 212 - ret = drbg_kcapi_sym(aesctx, X, &cipherin, blocklen_bytes); 213 - if (ret) 214 - goto out; 223 + drbg_kcapi_sym(aesctx, X, &cipherin, blocklen_bytes); 215 224 blocklen = (blocklen_bytes < 216 225 (bytes_to_return - generated_len)) ? 217 226 blocklen_bytes : ··· 219 232 generated_len += blocklen; 220 233 } 221 234 222 - ret = 0; 223 - 224 - out: 225 235 memset(iv, 0, blocklen_bytes); 226 236 memset(temp, 0, statelen + blocklen_bytes); 227 237 memset(pad, 0, blocklen_bytes); 228 - return ret; 238 + return 0; 229 239 } 230 240 EXPORT_SYMBOL_GPL(crypto_drbg_ctr_df); 231 241