* re: crypto: qat - Add support for RSA algorithm
@ 2015-07-20 15:12 Dan Carpenter
2015-07-20 15:12 ` Dan Carpenter
2015-07-20 16:13 ` Tadeusz Struk
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-07-20 15:12 UTC (permalink / raw)
To: tadeusz.struk; +Cc: qat-linux, linux-crypto
Hello Tadeusz Struk,
The patch a990532023b9: "crypto: qat - Add support for RSA algorithm"
from Jul 15, 2015, leads to the following Smatch warning:
drivers/crypto/qat/qat_common/qat_asym_algs.c:446 qat_rsa_get_n()
warn: was && intended here instead of ||?
drivers/crypto/qat/qat_common/qat_asym_algs.c
444 ret = -EINVAL;
445 /* In FIPS mode only allow key size 2K & 3K */
446 if (fips_enabled && (ctx->key_sz != 256 || ctx->key_sz != 384)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Looks like the static checker is correct.
447 pr_err("QAT: RSA: key size not allowed in FIPS mode\n");
448 goto err;
449 }
450 /* invalid key size provided */
451 if (!qat_rsa_enc_fn_id(ctx->key_sz))
452 goto err;
453
454 ret = -ENOMEM;
455 ctx->n = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_n, GFP_KERNEL);
456 if (!ctx->n)
457 goto err;
458
459 memcpy(ctx->n, ptr, ctx->key_sz);
460 return 0;
461 err:
462 ctx->key_sz = 0;
463 ctx->n = NULL;
464 return ret;
465 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: crypto: qat - Add support for RSA algorithm
2015-07-20 15:12 crypto: qat - Add support for RSA algorithm Dan Carpenter
@ 2015-07-20 15:12 ` Dan Carpenter
2015-07-20 16:13 ` Tadeusz Struk
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-07-20 15:12 UTC (permalink / raw)
To: tadeusz.struk; +Cc: qat-linux, linux-crypto
Also:
drivers/crypto/qat/qat_common/qat_asym_algs.c:513 qat_rsa_get_d()
warn: was && intended here instead of ||?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: crypto: qat - Add support for RSA algorithm
2015-07-20 15:12 crypto: qat - Add support for RSA algorithm Dan Carpenter
2015-07-20 15:12 ` Dan Carpenter
@ 2015-07-20 16:13 ` Tadeusz Struk
2015-07-20 18:59 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Tadeusz Struk @ 2015-07-20 16:13 UTC (permalink / raw)
To: Dan Carpenter; +Cc: qat-linux, linux-crypto
On 07/20/2015 08:12 AM, Dan Carpenter wrote:
> The patch a990532023b9: "crypto: qat - Add support for RSA algorithm"
> from Jul 15, 2015, leads to the following Smatch warning:
>
> drivers/crypto/qat/qat_common/qat_asym_algs.c:446 qat_rsa_get_n()
> warn: was && intended here instead of ||?
>
> drivers/crypto/qat/qat_common/qat_asym_algs.c
> 444 ret = -EINVAL;
> 445 /* In FIPS mode only allow key size 2K & 3K */
> 446 if (fips_enabled && (ctx->key_sz != 256 || ctx->key_sz != 384)) {
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Looks like the static checker is correct.
The logic is if fips_enabled we want to accept only key size 2K (256 bytes) or 3K (384 bytes)
so the condition looks ok to me. Maybe the comment above is misleading?
regards,
T
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: crypto: qat - Add support for RSA algorithm
2015-07-20 16:13 ` Tadeusz Struk
@ 2015-07-20 18:59 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-07-20 18:59 UTC (permalink / raw)
To: Tadeusz Struk; +Cc: qat-linux, linux-crypto
On Mon, Jul 20, 2015 at 09:13:32AM -0700, Tadeusz Struk wrote:
> On 07/20/2015 08:12 AM, Dan Carpenter wrote:
> > The patch a990532023b9: "crypto: qat - Add support for RSA algorithm"
> > from Jul 15, 2015, leads to the following Smatch warning:
> >
> > drivers/crypto/qat/qat_common/qat_asym_algs.c:446 qat_rsa_get_n()
> > warn: was && intended here instead of ||?
> >
> > drivers/crypto/qat/qat_common/qat_asym_algs.c
> > 444 ret = -EINVAL;
> > 445 /* In FIPS mode only allow key size 2K & 3K */
> > 446 if (fips_enabled && (ctx->key_sz != 256 || ctx->key_sz != 384)) {
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > Looks like the static checker is correct.
>
> The logic is if fips_enabled we want to accept only key size 2K (256 bytes) or 3K (384 bytes)
> so the condition looks ok to me. Maybe the comment above is misleading?
Logically ->key_sz can't be both 256 and 384 at the same time. What you
are describing is &&. This seems like an important function, my guess
is we have never tested it with fips_enabled?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-20 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-20 15:12 crypto: qat - Add support for RSA algorithm Dan Carpenter
2015-07-20 15:12 ` Dan Carpenter
2015-07-20 16:13 ` Tadeusz Struk
2015-07-20 18:59 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).