Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1158293
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH RFC v3 1/3] crypto: add PKE API |
| Date | 2015-06-04 09:00 +0200 |
| Message-ID | <pxxia-1jd-7@gated-at.bofh.it> (permalink) |
| References | <pxpDY-6H6-15@gated-at.bofh.it> <pxpDZ-6H6-39@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH RFC v3 0/3] crypto: Introduce Public Key Encryption API Tadeusz Struk <tadeusz.struk@intel.com> - 2015-06-04 00:50 +0200
[PATCH RFC v3 1/3] crypto: add PKE API Tadeusz Struk <tadeusz.struk@intel.com> - 2015-06-04 00:50 +0200
Re: [PATCH RFC v3 1/3] crypto: add PKE API Herbert Xu <herbert@gondor.apana.org.au> - 2015-06-04 09:00 +0200
[PATCH RFC v3 3/3] crypto: add tests vectors for RSA Tadeusz Struk <tadeusz.struk@intel.com> - 2015-06-04 00:50 +0200
Re: [PATCH RFC v3 3/3] crypto: add tests vectors for RSA Stephan Mueller <smueller@chronox.de> - 2015-06-04 02:20 +0200
Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API Herbert Xu <herbert@gondor.apana.org.au> - 2015-06-04 09:00 +0200
csiph-web