Re: [PATCH RFC v6 1/3] crypto: add PKE API

From: Herbert Xu
Date: Tue Jun 16 2015 - 04:20:15 EST


On Tue, Jun 16, 2015 at 01:01:59AM -0700, Tadeusz Struk wrote:
>
> @@ -28,6 +28,7 @@ crypto_hash-y += shash.o
> obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
>
> obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o
> +obj-$(CONFIG_CRYPTO_AKCIPHER) += akcipher.o

s/AKCIPHER/AKCIPHER2/

> +/**
> + * struct akcipher_request - public key request
> + *
> + * @base: Common attributes for async crypto requests
> + * @src: Pointer to memory containing the input parameters
> + * The format of the parameter(s) is expeted to be Octet String
> + * @dst: Pointer to memory whare the result will be stored
> + * @src_len: Size of the input parameter
> + * @dst_len: Size of the output buffer. It needs to be at leaset
> + * as big as the expected result depending on the operation
> + * After operation it will be updated with the acctual size of the
> + * result. In case of error, where the dst_len was insufficient,
> + * it will be updated to the size required for the operation.
> + * @result_len: If not NULL this will be updated by the implementation to
> + * reflect the acctual size of the result

result_len is still here.

> + * @__ctx: Start of private context data
> + */
> +struct akcipher_request {
> + struct crypto_async_request base;
> + void *src;
> + void *dst;
> + unsigned int src_len;
> + unsigned int *dst_len;

dst_len doesn't need to be a pointer. A simple int will do.

> +static inline int crypto_akcipher_encrypt(struct akcipher_request *req)
> +{
> + struct crypto_akcipher *tfm = __crypto_akcipher_tfm(req->base.tfm);

You should add a reqtfm helper like crypto_aead_reqtfm so that
implementors don't need to do this ugly __crypto_akcipher_tfm.

In fact you already have that helper so you just need to use it.

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/