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

crypto: qce - Use skcipher for fallback

This patch replaces use of the obsolete ablkcipher with skcipher.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+17 -12
+16 -11
drivers/crypto/qce/ablkcipher.c
··· 15 15 #include <linux/interrupt.h> 16 16 #include <linux/types.h> 17 17 #include <crypto/aes.h> 18 - #include <crypto/algapi.h> 19 18 #include <crypto/des.h> 19 + #include <crypto/internal/skcipher.h> 20 20 21 21 #include "cipher.h" 22 22 ··· 189 189 memcpy(ctx->enc_key, key, keylen); 190 190 return 0; 191 191 fallback: 192 - ret = crypto_ablkcipher_setkey(ctx->fallback, key, keylen); 192 + ret = crypto_skcipher_setkey(ctx->fallback, key, keylen); 193 193 if (!ret) 194 194 ctx->enc_keylen = keylen; 195 195 return ret; ··· 212 212 213 213 if (IS_AES(rctx->flags) && ctx->enc_keylen != AES_KEYSIZE_128 && 214 214 ctx->enc_keylen != AES_KEYSIZE_256) { 215 - ablkcipher_request_set_tfm(req, ctx->fallback); 216 - ret = encrypt ? crypto_ablkcipher_encrypt(req) : 217 - crypto_ablkcipher_decrypt(req); 218 - ablkcipher_request_set_tfm(req, __crypto_ablkcipher_cast(tfm)); 215 + SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback); 216 + 217 + skcipher_request_set_tfm(subreq, ctx->fallback); 218 + skcipher_request_set_callback(subreq, req->base.flags, 219 + NULL, NULL); 220 + skcipher_request_set_crypt(subreq, req->src, req->dst, 221 + req->nbytes, req->info); 222 + ret = encrypt ? crypto_skcipher_encrypt(subreq) : 223 + crypto_skcipher_decrypt(subreq); 224 + skcipher_request_zero(subreq); 219 225 return ret; 220 226 } 221 227 ··· 245 239 memset(ctx, 0, sizeof(*ctx)); 246 240 tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx); 247 241 248 - ctx->fallback = crypto_alloc_ablkcipher(crypto_tfm_alg_name(tfm), 249 - CRYPTO_ALG_TYPE_ABLKCIPHER, 250 - CRYPTO_ALG_ASYNC | 251 - CRYPTO_ALG_NEED_FALLBACK); 242 + ctx->fallback = crypto_alloc_skcipher(crypto_tfm_alg_name(tfm), 0, 243 + CRYPTO_ALG_ASYNC | 244 + CRYPTO_ALG_NEED_FALLBACK); 252 245 if (IS_ERR(ctx->fallback)) 253 246 return PTR_ERR(ctx->fallback); 254 247 ··· 258 253 { 259 254 struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm); 260 255 261 - crypto_free_ablkcipher(ctx->fallback); 256 + crypto_free_skcipher(ctx->fallback); 262 257 } 263 258 264 259 struct qce_ablkcipher_def {
+1 -1
drivers/crypto/qce/cipher.h
··· 22 22 struct qce_cipher_ctx { 23 23 u8 enc_key[QCE_MAX_KEY_SIZE]; 24 24 unsigned int enc_keylen; 25 - struct crypto_ablkcipher *fallback; 25 + struct crypto_skcipher *fallback; 26 26 }; 27 27 28 28 /**