Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1422123 > unrolled thread
| Started by | Mat Martineau <mathew.j.martineau@linux.intel.com> |
|---|---|
| First post | 2016-06-14 19:30 +0200 |
| Last post | 2016-06-15 09:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 3/6] crypto: AF_ALG -- add asymmetric cipher interface Mat Martineau <mathew.j.martineau@linux.intel.com> - 2016-06-14 19:30 +0200
Re: [PATCH v6 3/6] crypto: AF_ALG -- add asymmetric cipher interface Stephan Mueller <smueller@chronox.de> - 2016-06-15 09:10 +0200
| From | Mat Martineau <mathew.j.martineau@linux.intel.com> |
|---|---|
| Date | 2016-06-14 19:30 +0200 |
| Subject | Re: [PATCH v6 3/6] crypto: AF_ALG -- add asymmetric cipher interface |
| Message-ID | <rK0k1-7St-9@gated-at.bofh.it> |
Stephan,
On Sat, 14 May 2016, Tadeusz Struk wrote:
> From: Stephan Mueller <smueller@chronox.de>
>
> This patch adds the user space interface for asymmetric ciphers. The
> interface allows the use of sendmsg as well as vmsplice to provide data.
>
> This version has been rebased on top of 4.6 and a few chackpatch issues
> have been fixed.
>
> Signed-off-by: Stephan Mueller <smueller@chronox.de>
> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
> ---
> crypto/algif_akcipher.c | 542 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 542 insertions(+)
> create mode 100644 crypto/algif_akcipher.c
>
> diff --git a/crypto/algif_akcipher.c b/crypto/algif_akcipher.c
> new file mode 100644
> index 0000000..6342b6e
> --- /dev/null
> +++ b/crypto/algif_akcipher.c
> +
> +static int akcipher_sendmsg(struct socket *sock, struct msghdr *msg,
> + size_t size)
> +{
> + struct sock *sk = sock->sk;
> + struct alg_sock *ask = alg_sk(sk);
> + struct akcipher_ctx *ctx = ask->private;
> + struct akcipher_sg_list *sgl = &ctx->tsgl;
> + struct af_alg_control con = {};
> + long copied = 0;
> + int op = 0;
> + bool init = 0;
> + int err;
> +
> + if (msg->msg_controllen) {
> + err = af_alg_cmsg_send(msg, &con);
> + if (err)
> + return err;
> +
> + init = 1;
> + switch (con.op) {
> + case ALG_OP_VERIFY:
> + case ALG_OP_SIGN:
> + case ALG_OP_ENCRYPT:
> + case ALG_OP_DECRYPT:
> + op = con.op;
> + break;
> + default:
> + return -EINVAL;
> + }
> + }
> +
> + lock_sock(sk);
> + if (!ctx->more && ctx->used)
> + goto unlock;
err might be uninitialised at this goto. Should it be set to something
like -EALREADY to indicate that data is already queued for a different
crypto op?
<snip>
> +unlock:
> + akcipher_data_wakeup(sk);
> + release_sock(sk);
> +
> + return err ?: copied;
> +}
Regards,
--
Mat Martineau
Intel OTC
[toc] | [next] | [standalone]
| From | Stephan Mueller <smueller@chronox.de> |
|---|---|
| Date | 2016-06-15 09:10 +0200 |
| Subject | Re: [PATCH v6 3/6] crypto: AF_ALG -- add asymmetric cipher interface |
| Message-ID | <rKd7z-7Q2-3@gated-at.bofh.it> |
| In reply to | #1422123 |
Am Dienstag, 14. Juni 2016, 10:22:15 schrieb Mat Martineau:
Hi Mat,
> Stephan,
>
> On Sat, 14 May 2016, Tadeusz Struk wrote:
> > From: Stephan Mueller <smueller@chronox.de>
> >
> > This patch adds the user space interface for asymmetric ciphers. The
> > interface allows the use of sendmsg as well as vmsplice to provide data.
> >
> > This version has been rebased on top of 4.6 and a few chackpatch issues
> > have been fixed.
> >
> > Signed-off-by: Stephan Mueller <smueller@chronox.de>
> > Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
> > ---
> > crypto/algif_akcipher.c | 542
> > +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 542
> > insertions(+)
> > create mode 100644 crypto/algif_akcipher.c
> >
> > diff --git a/crypto/algif_akcipher.c b/crypto/algif_akcipher.c
> > new file mode 100644
> > index 0000000..6342b6e
> > --- /dev/null
> > +++ b/crypto/algif_akcipher.c
> > +
> > +static int akcipher_sendmsg(struct socket *sock, struct msghdr *msg,
> > + size_t size)
> > +{
> > + struct sock *sk = sock->sk;
> > + struct alg_sock *ask = alg_sk(sk);
> > + struct akcipher_ctx *ctx = ask->private;
> > + struct akcipher_sg_list *sgl = &ctx->tsgl;
> > + struct af_alg_control con = {};
> > + long copied = 0;
> > + int op = 0;
> > + bool init = 0;
> > + int err;
> > +
> > + if (msg->msg_controllen) {
> > + err = af_alg_cmsg_send(msg, &con);
> > + if (err)
> > + return err;
> > +
> > + init = 1;
> > + switch (con.op) {
> > + case ALG_OP_VERIFY:
> > + case ALG_OP_SIGN:
> > + case ALG_OP_ENCRYPT:
> > + case ALG_OP_DECRYPT:
> > + op = con.op;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > + }
> > +
> > + lock_sock(sk);
> > + if (!ctx->more && ctx->used)
> > + goto unlock;
>
> err might be uninitialised at this goto. Should it be set to something
> like -EALREADY to indicate that data is already queued for a different
> crypto op?
Thanks for the hint. Tadeusz, I will provide you with an updated
algif_akcipher.c for your patchset.
I will also have a look at the comment from Andrew.
>
> <snip>
>
> > +unlock:
> > + akcipher_data_wakeup(sk);
> > + release_sock(sk);
> > +
> > + return err ?: copied;
> > +}
>
> Regards,
>
> --
> Mat Martineau
> Intel OTC
Ciao
Stephan
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web