mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: dhowells@redhat.com, keyrings@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Security: Keys: Big keys stored encrypted
Date: Fri, 01 Apr 2016 17:31:16 +0100	[thread overview]
Message-ID: <32088.1459528276@warthog.procyon.org.uk> (raw)
In-Reply-To: <1459345402-24112-1-git-send-email-k.marinushkin@gmail.com>

Kirill Marinushkin <k.marinushkin@gmail.com> wrote:

> +enum {
> +	ENC,
> +	DEC,
> +};

"enum big_key_mode" and use it as a parameter type to big_key_crypt().

Also BIG_KEY_ENC, BIG_KEY_DEC.  Please use prefixes consistently.

> +static const char *rng_name = "stdrng";
> +
> +/*
> + * Algorithm name for big_key data encryption
> + */
> +static const char *alg_name = "ecb(aes)";

Use const char arrays not const char pointers as that saves on a pointer
storage.

> +/*
> + * Aligned data length of big_key encryption
> + */
> +#define ALIGNED_LEN(l)	(l + ENC_BLOCK_SIZE - l % ENC_BLOCK_SIZE)

Surely there's a crypto thing for this?  The block size and key size ought to
be functions of the algorithm you select rather than being hardcoded.

> +static int gen_enckey(u8 *key)

big_key_gen_enckey().

> +{
> +	int ret = -EINVAL;
> +	struct crypto_rng *rng = NULL;
> +
> +	rng = crypto_alloc_rng(rng_name, 0, 0);
> +	if (IS_ERR(rng))
> +		return -EFAULT;
> +
> +	ret = crypto_rng_reset(rng, NULL, crypto_rng_seedsize(rng));
> +
> +	if (!ret)
> +		ret = crypto_rng_get_bytes(rng, key, ENC_KEY_SIZE);
> +
> +	if (rng)

rng can be NULL here?!

> +static int big_crypt(u8 op, u8 *data, size_t datalen, u8 *key)

big_key_crypt().

      reply	other threads:[~2016-04-01 16:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 13:43 Kirill Marinushkin
2016-04-01 16:31 ` David Howells [this message]

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=32088.1459528276@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=k.marinushkin@gmail.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@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

all inboxes | Powered by JetHome®