[linux-yocto] [PATCH] cryptodev: replace deprecated ablkcipher APIs to skcipher APIs

Bruce Ashfield bruce.ashfield at windriver.com
Thu Nov 17 06:25:33 PST 2016


On 2016-11-16 08:01 PM, Yang Shi wrote:
> Due to the upstream change [1], ablkcipher APIs have bene deprecated,
> so replace it to the new skcipher APIs.

Thanks Yang.

I've grabbed this change.

Bruce

>
> [1] https://www.spinics.net/lists/linux-crypto/msg18133.html
>
> Signed-off-by: Yang Shi <yang.shi at windriver.com>
> ---
>  drivers/staging/crypto/cryptodev/cryptlib.c | 36 ++++++++++++++---------------
>  drivers/staging/crypto/cryptodev/cryptlib.h |  4 ++--
>  drivers/staging/crypto/cryptodev/ioctl.c    |  3 ++-
>  3 files changed, 21 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/staging/crypto/cryptodev/cryptlib.c b/drivers/staging/crypto/cryptodev/cryptlib.c
> index b68f460..a6b0564 100644
> --- a/drivers/staging/crypto/cryptodev/cryptlib.c
> +++ b/drivers/staging/crypto/cryptodev/cryptlib.c
> @@ -132,19 +132,17 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
>  				uint8_t *keyp, size_t keylen, int stream, int aead)
>  {
>  	int ret;
> -	struct crypto_skcipher *tfm;
>
>  	if (aead == 0) {
> -		struct ablkcipher_alg *alg;
> +		struct skcipher_alg *alg;
>
> -		tfm = crypto_alloc_skcipher(alg_name, 0, 0);
> -		out->async.s->base = tfm->base;
> +		out->async.s = crypto_alloc_skcipher(alg_name, 0, 0);
>  		if (unlikely(IS_ERR(out->async.s))) {
>  			ddebug(1, "Failed to load cipher %s", alg_name);
>  				return -EINVAL;
>  		}
>
> -		alg = crypto_ablkcipher_alg(out->async.s);
> +		alg = crypto_skcipher_alg(out->async.s);
>  		if (alg != NULL) {
>  			/* Was correct key length supplied? */
>  			if (alg->max_keysize > 0 &&
> @@ -157,11 +155,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
>  			}
>  		}
>
> -		out->blocksize = crypto_ablkcipher_blocksize(out->async.s);
> -		out->ivsize = crypto_ablkcipher_ivsize(out->async.s);
> -		out->alignmask = crypto_ablkcipher_alignmask(out->async.s);
> +		out->blocksize = crypto_skcipher_blocksize(out->async.s);
> +		out->ivsize = crypto_skcipher_ivsize(out->async.s);
> +		out->alignmask = crypto_skcipher_alignmask(out->async.s);
>
> -		ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen);
> +		ret = crypto_skcipher_setkey(out->async.s, keyp, keylen);
>  	} else {
>  		out->async.as = crypto_alloc_aead(alg_name, 0, 0);
>  		if (unlikely(IS_ERR(out->async.as))) {
> @@ -194,14 +192,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
>  	init_completion(&out->async.result->completion);
>
>  	if (aead == 0) {
> -		out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL);
> +		out->async.request = skcipher_request_alloc(out->async.s, GFP_KERNEL);
>  		if (unlikely(!out->async.request)) {
>  			derr(1, "error allocating async crypto request");
>  			ret = -ENOMEM;
>  			goto error;
>  		}
>
> -		ablkcipher_request_set_callback(out->async.request,
> +		skcipher_request_set_callback(out->async.request,
>  					CRYPTO_TFM_REQ_MAY_BACKLOG,
>  					cryptodev_complete, out->async.result);
>  	} else {
> @@ -222,9 +220,9 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
>  error:
>  	if (aead == 0) {
>  		if (out->async.request)
> -			ablkcipher_request_free(out->async.request);
> +			skcipher_request_free(out->async.request);
>  		if (out->async.s)
> -			crypto_free_ablkcipher(out->async.s);
> +			crypto_free_skcipher(out->async.s);
>  	} else {
>  		if (out->async.arequest)
>  			aead_request_free(out->async.arequest);
> @@ -241,9 +239,9 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata)
>  	if (cdata->init) {
>  		if (cdata->aead == 0) {
>  			if (cdata->async.request)
> -				ablkcipher_request_free(cdata->async.request);
> +				skcipher_request_free(cdata->async.request);
>  			if (cdata->async.s)
> -				crypto_free_ablkcipher(cdata->async.s);
> +				crypto_free_skcipher(cdata->async.s);
>  		} else {
>  			if (cdata->async.arequest)
>  				aead_request_free(cdata->async.arequest);
> @@ -292,10 +290,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata,
>  	reinit_completion(&cdata->async.result->completion);
>
>  	if (cdata->aead == 0) {
> -		ablkcipher_request_set_crypt(cdata->async.request,
> +		skcipher_request_set_crypt(cdata->async.request,
>  			(struct scatterlist *)src, dst,
>  			len, cdata->async.iv);
> -		ret = crypto_ablkcipher_encrypt(cdata->async.request);
> +		ret = crypto_skcipher_encrypt(cdata->async.request);
>  	} else {
>  		aead_request_set_crypt(cdata->async.arequest,
>  			(struct scatterlist *)src, dst,
> @@ -314,10 +312,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata,
>
>  	reinit_completion(&cdata->async.result->completion);
>  	if (cdata->aead == 0) {
> -		ablkcipher_request_set_crypt(cdata->async.request,
> +		skcipher_request_set_crypt(cdata->async.request,
>  			(struct scatterlist *)src, dst,
>  			len, cdata->async.iv);
> -		ret = crypto_ablkcipher_decrypt(cdata->async.request);
> +		ret = crypto_skcipher_decrypt(cdata->async.request);
>  	} else {
>  		aead_request_set_crypt(cdata->async.arequest,
>  			(struct scatterlist *)src, dst,
> diff --git a/drivers/staging/crypto/cryptodev/cryptlib.h b/drivers/staging/crypto/cryptodev/cryptlib.h
> index 0c20092..1b3e1e8 100644
> --- a/drivers/staging/crypto/cryptodev/cryptlib.h
> +++ b/drivers/staging/crypto/cryptodev/cryptlib.h
> @@ -10,8 +10,8 @@ struct cipher_data {
>  	int alignmask;
>  	struct {
>  		/* block ciphers */
> -		struct crypto_ablkcipher *s;
> -		struct ablkcipher_request *request;
> +		struct crypto_skcipher *s;
> +		struct skcipher_request *request;
>
>  		/* AEAD ciphers */
>  		struct crypto_aead *as;
> diff --git a/drivers/staging/crypto/cryptodev/ioctl.c b/drivers/staging/crypto/cryptodev/ioctl.c
> index b23f5fd..8177c68 100644
> --- a/drivers/staging/crypto/cryptodev/ioctl.c
> +++ b/drivers/staging/crypto/cryptodev/ioctl.c
> @@ -47,6 +47,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/rtnetlink.h>
>  #include <crypto/authenc.h>
> +#include <crypto/skcipher.h>
>
>  #include <linux/sysctl.h>
>
> @@ -765,7 +766,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop)
>
>  	if (ses_ptr->cdata.init) {
>  		if (ses_ptr->cdata.aead == 0)
> -			tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s);
> +			tfm = crypto_skcipher_tfm(ses_ptr->cdata.async.s);
>  		else
>  			tfm = crypto_aead_tfm(ses_ptr->cdata.async.as);
>  		tfm_info_to_alg_info(&siop->cipher_info, tfm);
>



More information about the linux-yocto mailing list