linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: <linux-crypto@vger.kernel.org>, Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Miller <davem@davemloft.net>
Subject: Re: [PATCH v1] crypto: ccp - Add hash state import and export support
Date: Fri, 22 Jan 2016 11:22:48 -0600	[thread overview]
Message-ID: <56A26568.3000806@amd.com> (raw)
In-Reply-To: <20160112171738.23496.44254.stgit@tlendack-t1.amdoffice.net>

On 01/12/2016 11:17 AM, Tom Lendacky wrote:
> Commit 8996eafdcbad ("crypto: ahash - ensure statesize is non-zero")
> added a check to prevent ahash algorithms from successfully registering
> if the import and export functions were not implemented. This prevents
> an oops in the hash_accept function of algif_hash. This commit causes
> the ccp-crypto module SHA support and AES CMAC support from successfully
> registering and causing the ccp-crypto module load to fail because the
> ahash import and export functions are not implemented.
> 
> Update the CCP Crypto API support to provide import and export support
> for ahash algorithms.
> 
> Cc: <stable@vger.kernel.org> # 3.14.x-
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>

Herbert, is it possible this patch can be part of Crypto Fixes for 4.5?

Thanks,
Tom

> ---
>  drivers/crypto/ccp/ccp-crypto-aes-cmac.c |   23 +++++++++++++++++++++++
>  drivers/crypto/ccp/ccp-crypto-sha.c      |   23 +++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> index d89f20c..00207cf 100644
> --- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> +++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> @@ -220,6 +220,26 @@ static int ccp_aes_cmac_digest(struct ahash_request *req)
>  	return ccp_aes_cmac_finup(req);
>  }
>  
> +static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
> +{
> +	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
> +	struct ccp_aes_cmac_req_ctx *state = out;
> +
> +	*state = *rctx;
> +
> +	return 0;
> +}
> +
> +static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
> +{
> +	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
> +	const struct ccp_aes_cmac_req_ctx *state = in;
> +
> +	*rctx = *state;
> +
> +	return 0;
> +}
> +
>  static int ccp_aes_cmac_setkey(struct crypto_ahash *tfm, const u8 *key,
>  			       unsigned int key_len)
>  {
> @@ -352,10 +372,13 @@ int ccp_register_aes_cmac_algs(struct list_head *head)
>  	alg->final = ccp_aes_cmac_final;
>  	alg->finup = ccp_aes_cmac_finup;
>  	alg->digest = ccp_aes_cmac_digest;
> +	alg->export = ccp_aes_cmac_export;
> +	alg->import = ccp_aes_cmac_import;
>  	alg->setkey = ccp_aes_cmac_setkey;
>  
>  	halg = &alg->halg;
>  	halg->digestsize = AES_BLOCK_SIZE;
> +	halg->statesize = sizeof(struct ccp_aes_cmac_req_ctx);
>  
>  	base = &halg->base;
>  	snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "cmac(aes)");
> diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
> index d14b3f2..3aae58d 100644
> --- a/drivers/crypto/ccp/ccp-crypto-sha.c
> +++ b/drivers/crypto/ccp/ccp-crypto-sha.c
> @@ -207,6 +207,26 @@ static int ccp_sha_digest(struct ahash_request *req)
>  	return ccp_sha_finup(req);
>  }
>  
> +static int ccp_sha_export(struct ahash_request *req, void *out)
> +{
> +	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
> +	struct ccp_sha_req_ctx *state = out;
> +
> +	*state = *rctx;
> +
> +	return 0;
> +}
> +
> +static int ccp_sha_import(struct ahash_request *req, const void *in)
> +{
> +	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
> +	const struct ccp_sha_req_ctx *state = in;
> +
> +	*rctx = *state;
> +
> +	return 0;
> +}
> +
>  static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key,
>  			  unsigned int key_len)
>  {
> @@ -403,9 +423,12 @@ static int ccp_register_sha_alg(struct list_head *head,
>  	alg->final = ccp_sha_final;
>  	alg->finup = ccp_sha_finup;
>  	alg->digest = ccp_sha_digest;
> +	alg->export = ccp_sha_export;
> +	alg->import = ccp_sha_import;
>  
>  	halg = &alg->halg;
>  	halg->digestsize = def->digest_size;
> +	halg->statesize = sizeof(struct ccp_sha_req_ctx);
>  
>  	base = &halg->base;
>  	snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "%s", def->name);
> 

  reply	other threads:[~2016-01-22 17:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12 17:17 [PATCH v1] crypto: ccp - Add hash state import and export support Tom Lendacky
2016-01-22 17:22 ` Tom Lendacky [this message]
2016-01-25  7:20   ` Herbert Xu
2016-01-25 14:58     ` Tom Lendacky
2016-01-26 11:16       ` Herbert Xu
2016-01-25 14:48 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56A26568.3000806@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).