Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1341510 > unrolled thread

Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer

Started byMimi Zohar <zohar@linux.vnet.ibm.com>
First post2016-02-24 06:10 +0100
Last post2016-02-29 16:40 +0100
Articles 3 — 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.


Contents

  Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto  layer Mimi Zohar <zohar@linux.vnet.ibm.com> - 2016-02-24 06:10 +0100
    Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto  layer Mimi Zohar <zohar@linux.vnet.ibm.com> - 2016-02-24 07:10 +0100
      Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer David Howells <dhowells@redhat.com> - 2016-02-29 16:40 +0100

#1341510 — Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer

FromMimi Zohar <zohar@linux.vnet.ibm.com>
Date2016-02-24 06:10 +0100
SubjectRe: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer
Message-ID<r5zS2-84d-19@gated-at.bofh.it>
On Fri, 2016-02-19 at 17:18 +0000, David Howells wrote:

>  /*
>   * Verify a signature using a public key.
>   */
>  int public_key_verify_signature(const struct public_key *pkey,
>  				const struct public_key_signature *sig)
>  {
> +	struct public_key_completion compl;
> +	struct crypto_akcipher *tfm;
> +	struct akcipher_request *req;
> +	struct scatterlist sig_sg, digest_sg;
> +	int ret = -ENOMEM;
> +
> +	pr_devel("==>%s()\n", __func__);
> +
>  	BUG_ON(!pkey);
>  	BUG_ON(!sig);
>  	BUG_ON(!sig->digest);
>  	BUG_ON(!sig->s);
> 
> -	if (pkey->pkey_algo >= PKEY_ALGO__LAST)
> -		return -ENOPKG;
> +	tfm = crypto_alloc_akcipher(pkey_algo_name[sig->pkey_algo], 0, 0);
> +	if (IS_ERR(tfm))
> +		return PTR_ERR(tfm);

IMA fails here.   The security.ima xattr header includes the hash
algorithm as defined in 
include/uapi/linux/hash_info.h.

struct signature_v2_hdr {
        uint8_t type;           /* xattr type */
        uint8_t version;        /* signature format version */
        uint8_t hash_algo;      /* Digest algorithm [enum pkey_hash_algo] */
        uint32_t keyid;         /* IMA key identifier - not X509/PGP specific */
        uint16_t sig_size;      /* signature size */
        uint8_t sig[0];         /* signature payload */
} __packed;

Mimi

[toc] | [next] | [standalone]


#1341593

FromMimi Zohar <zohar@linux.vnet.ibm.com>
Date2016-02-24 07:10 +0100
Message-ID<r5AO6-ke-9@gated-at.bofh.it>
In reply to#1341510
On Wed, 2016-02-24 at 00:04 -0500, Mimi Zohar wrote:
> On Fri, 2016-02-19 at 17:18 +0000, David Howells wrote:
> 
> >  /*
> >   * Verify a signature using a public key.
> >   */
> >  int public_key_verify_signature(const struct public_key *pkey,
> >  				const struct public_key_signature *sig)
> >  {
> > +	struct public_key_completion compl;
> > +	struct crypto_akcipher *tfm;
> > +	struct akcipher_request *req;
> > +	struct scatterlist sig_sg, digest_sg;
> > +	int ret = -ENOMEM;
> > +
> > +	pr_devel("==>%s()\n", __func__);
> > +
> >  	BUG_ON(!pkey);
> >  	BUG_ON(!sig);
> >  	BUG_ON(!sig->digest);
> >  	BUG_ON(!sig->s);
> > 
> > -	if (pkey->pkey_algo >= PKEY_ALGO__LAST)
> > -		return -ENOPKG;
> > +	tfm = crypto_alloc_akcipher(pkey_algo_name[sig->pkey_algo], 0, 0);
> > +	if (IS_ERR(tfm))
> > +		return PTR_ERR(tfm);
> 
> IMA fails here.

Please include the following fix in this patch.

diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c
index 2fa3bc6..69a92e6 100644
--- a/security/integrity/digsig_asymmetric.c
+++ b/security/integrity/digsig_asymmetric.c
@@ -103,6 +103,7 @@ int asymmetric_verify(struct key *keyring, const char *sig,
 
 	memset(&pks, 0, sizeof(pks));
 
+	pks.pkey_algo = PKEY_ALGO_RSA;
 	pks.pkey_hash_algo = hdr->hash_algo;
 	pks.digest = (u8 *)data;
 	pks.digest_size = datalen;
-- 
2.1.0

[toc] | [prev] | [next] | [standalone]


#1345918 — Re: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer

FromDavid Howells <dhowells@redhat.com>
Date2016-02-29 16:40 +0100
SubjectRe: [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer
Message-ID<r7y5s-4Rv-21@gated-at.bofh.it>
In reply to#1341593
Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:

>  	memset(&pks, 0, sizeof(pks));
>  
> +	pks.pkey_algo = PKEY_ALGO_RSA;
>  	pks.pkey_hash_algo = hdr->hash_algo;
>  	pks.digest = (u8 *)data;
>  	pks.digest_size = datalen;

I've updated the patch.

David

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web