lkml.org 
[lkml]   [2015]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH RFC v5 3/4] crypto: rsa: add a new rsa generic implementation
Date
Am Montag, 15. Juni 2015, 13:18:47 schrieb Tadeusz Struk:

Hi Tadeusz,

> Add a new rsa generic SW implementation.
> This implements only cryptographic primitives.

Thank you, that seems to address the issues around the FIPS side including the
self test code.

Though, I have one question:

> +
> +int rsa_get_n(void *context, size_t hdrlen, unsigned char tag,
> + const void *value, size_t vlen)
> +{
> + struct crypto_akcipher *tfm = context;
> + struct rsa_key *key = tfm->key;
> +
> + key->n = mpi_read_raw_data(value, vlen);
> +
> + if (!key->n)
> + return -ENOMEM;
> +
> + /* In FIPS mode only allow key size minimum 2K */
> + if (fips_enabled && (mpi_get_size(key->n) < 256)) {

Considering my previous email, shouldn't that check rather be

if (fips_enabled &&
((mpi_get_size(key->n) != 256) || (mpi_get_size(key->n) != 384))

?

> + pr_err("RSA: key size not allowed in FIPS mode\n");
> + mpi_free(key->n);
> + key->n = NULL;
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +int rsa_get_e(void *context, size_t hdrlen, unsigned char tag,
> + const void *value, size_t vlen)
> +{
> + struct crypto_akcipher *tfm = context;
> + struct rsa_key *key = tfm->key;
> +
> + key->e = mpi_read_raw_data(value, vlen);
> +
> + if (!key->e)
> + return -ENOMEM;
> +
> + return 0;
> +}
> +
> +int rsa_get_d(void *context, size_t hdrlen, unsigned char tag,
> + const void *value, size_t vlen)
> +{
> + struct crypto_akcipher *tfm = context;
> + struct rsa_key *key = tfm->key;
> +
> + key->d = mpi_read_raw_data(value, vlen);
> +
> + if (!key->d)
> + return -ENOMEM;
> +
> + /* In FIPS mode only allow key size minimum 2K */
> + if (fips_enabled && (mpi_get_size(key->d) < 256)) {

dto.

> + pr_err("RSA: key size not allowed in FIPS mode\n");
> + mpi_free(key->d);
> + key->d = NULL;
> + return -EINVAL;
> + }
> + return 0;
> +}
> +

Thanks
--
Ciao
Stephan


\
 
 \ /
  Last update: 2015-06-16 01:41    [W:0.125 / U:1.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site