[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-keyrings
Subject:    Re: [PATCH v5 10/10] integrity: support EC-RDSA signatures for asymmetric_verify
From:       Mimi Zohar <zohar () linux ! ibm ! com>
Date:       2019-02-26 12:07:43
Message-ID: 1551182863.27819.62.camel () linux ! ibm ! com
[Download RAW message or body]


> > > diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c
> > > index d775e03fbbcc..c4a3313e0210 100644
> > > --- a/security/integrity/digsig_asymmetric.c
> > > +++ b/security/integrity/digsig_asymmetric.c
> > > @@ -104,9 +104,14 @@ int asymmetric_verify(struct key *keyring, const char *sig,
> > >
> > >  	memset(&pks, 0, sizeof(pks));
> > >
> > > -	pks.pkey_algo = "rsa";
> > >  	pks.hash_algo = hash_algo_name[hdr->hash_algo];
> > > -	pks.encoding = "pkcs1";
> > > +	if (!strncmp(pks.hash_algo, "streebog", 8)) {
> > 
> > Is it possible to test hdr->hash_algo instead of pkcs.hash_algo? IMHO if
> > an integer value is available it's preferable to check it rather than
> > doing a string comparison.
> 
> Yes. But we have long tradition of comparing by the name too:
> 
>   --linux$ git grep str.*cmp.*'"sha[12]'
>   drivers/crypto/mxs-dcp.c:       if (strcmp(halg->base.cra_name, "sha1") == 0)
>   drivers/crypto/talitos.c:                   (!strcmp(alg->cra_name, "sha224") ||
>   net/sctp/sysctl.c:              if (!strncmp(tmp, "sha1", 4)) {
>   scripts/sign-file.c:    if (strcmp(hash_algo, "sha1") != 0) {

sign_file.c is a userspace program used for signing kernel modules.
 This example is not applicable.

>   security/integrity/ima/ima_main.c:              if (strncmp(str, "sha1", 4) == 0)

In the ima_main.c example, it is used in an __init function to set up
crypto defaults.  The code also predates the enumerations defined in
crypto/hash_info.c.

Mimi

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic