mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Tadeusz Struk <tadeusz.struk@intel.com>
Cc: linux-kernel@vger.kernel.org, keescook@chromium.org,
	jwboyer@redhat.com, richard@nod.at, steved@redhat.com,
	qat-linux@intel.com, dhowells@redhat.com,
	linux-crypto@vger.kernel.org, james.l.morris@oracle.com,
	jkosina@suse.cz, zohar@linux.vnet.ibm.com, davem@davemloft.net,
	vgoyal@redhat.com
Subject: Re: [PATCH RFC v3 1/3] crypto: add PKE API
Date: Thu, 4 Jun 2015 14:49:29 +0800	[thread overview]
Message-ID: <20150604064929.GA22158@gondor.apana.org.au> (raw)
In-Reply-To: <20150603224408.22310.45114.stgit@tstruk-mobl1>

On Wed, Jun 03, 2015 at 03:44:08PM -0700, Tadeusz Struk wrote:
>
> +/**
> + * struct akcipher_alg - generic public key algorithm
> + *
> + * @sign:	Function performs a sign operation as defined by public key
> + *		algorithm
> + * @verify:	Function performs a sign operation as defined by public key
> + *		algorithm
> + * @encrypt:	Function performs an encrytp operation as defined by public key
> + *		algorithm
> + * @decrypt:	Function performs a decrypt operation as defined by public key
> + *		algorithm
> + * @reqsize:	Request context size required by algorithm implementation
> + * @base:	Common crypto API algorithm data structure
> + */
> +struct akcipher_alg {
> +	int (*sign)(struct akcipher_request *req);
> +	int (*verify)(struct akcipher_request *req);
> +	int (*encrypt)(struct akcipher_request *req);
> +	int (*decrypt)(struct akcipher_request *req);
> +
> +	unsigned int reqsize;
> +	struct crypto_alg base;
> +};

Because the caller is going to be allocating memory for the output,
we need to provide a way for them to know how much memory to
allocate.

This presumably will depend on the key size.

So something like

	int (*maxsize)(struct crypto_akcipher *tfm);

is needed.

You should also provide setkey here.  You can't just save a pointer
to the key.  The transform must hold the key physically as the
original may go away.  It should also ensure that the key is
actually valid for the transform.

> +/**
> + * struct crypto_akcipher - user-instantiated objects which encapsulate
> + * algorithms and core processing logic
> + *
> + * @base:	Common crypto API algorithm data structure
> + * @pkey:	Key representation. Note: this can be both public or private
> + *		key, depending on the operation.
> + * @__ctx:	Start of private context data
> + */
> +struct crypto_akcipher {
> +	struct crypto_tfm base;
> +	const struct public_key *pkey;
> +	void *__ctx[] CRYPTO_MINALIGN_ATTR;
> +};

base already has ctx so you should get rid of ctx and move base
to the end of the struct.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2015-06-04  6:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03 22:44 [PATCH RFC v3 0/3] crypto: Introduce Public Key Encryption API Tadeusz Struk
2015-06-03 22:44 ` [PATCH RFC v3 1/3] crypto: add PKE API Tadeusz Struk
2015-06-04  6:49   ` Herbert Xu [this message]
2015-06-04 17:23     ` Tadeusz Struk
2015-06-03 22:44 ` [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new " Tadeusz Struk
2015-06-04  6:53   ` Herbert Xu
2015-06-04 17:23     ` Tadeusz Struk
2015-06-05  8:50   ` Paul Bolle
2015-06-05 16:42     ` Tadeusz Struk
2015-06-03 22:44 ` [PATCH RFC v3 3/3] crypto: add tests vectors for RSA Tadeusz Struk
2015-06-04  0:15   ` Stephan Mueller
2015-06-04 16:28     ` Tadeusz Struk

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=20150604064929.GA22158@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=james.l.morris@oracle.com \
    --cc=jkosina@suse.cz \
    --cc=jwboyer@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=richard@nod.at \
    --cc=steved@redhat.com \
    --cc=tadeusz.struk@intel.com \
    --cc=vgoyal@redhat.com \
    --cc=zohar@linux.vnet.ibm.com \
    /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

all inboxes | Powered by JetHome®