lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 2 Mar 2021 15:47:24 +0200
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Andy Lutomirski <luto@...capital.net>
Cc:     Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Shuah Khan <shuah@...nel.org>, X86 ML <x86@...nel.org>,
        linux-sgx@...r.kernel.org,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Jia Zhang <zhang.jia@...ux.alibaba.com>
Subject: Re: [PATCH] selftests/sgx: fix EINIT failure dueto
 SGX_INVALID_SIGNATURE

On Mon, Mar 01, 2021 at 09:54:37PM -0800, Andy Lutomirski wrote:
> On Mon, Mar 1, 2021 at 9:06 PM Tianjia Zhang
> <tianjia.zhang@...ux.alibaba.com> wrote:
> >
> >
> >
> > On 3/1/21 5:54 PM, Jarkko Sakkinen wrote:
> > > On Mon, Mar 01, 2021 at 01:18:36PM +0800, Tianjia Zhang wrote:
> > >> q2 is not always 384-byte length. Sometimes it only has 383-byte.
> > >
> > > What does determine this?
> > >
> > >> In this case, the valid portion of q2 is reordered reversely for
> > >> little endian order, and the remaining portion is filled with zero.
> > >
> > > I'm presuming that you want to say "In this case, q2 needs to be reversed because...".
> > >
> > > I'm lacking these details:
> > >
> > > 1. Why the length of Q2 can vary?
> > > 2. Why reversing the bytes is the correct measure to counter-measure
> > >     this variation?
> > >
> > > /Jarkko
> > >
> >
> > When use openssl to generate a key instead of using the built-in
> > sign_key.pem, there is a probability that will encounter this problem.
> >
> > Here is a problematic key I encountered. The calculated q1 and q2 of
> > this key are both 383 bytes, If the length is not processed, the
> > hardware signature will fail.
> 
> Presumably the issue is that some keys have parameters that have
> enough leading 0 bits to be effectively shorter.  The openssl API
> (and, sadly, a bunch  of the ASN.1 stuff) treats these parameters as
> variable-size integers.

But the test uses a static key. It used to generate a key on fly but
in some of the last versions I replaced key generation with a static
key:

static RSA *gen_sign_key(void)
{
	unsigned long sign_key_length;
	BIO *bio;
	RSA *key;

	sign_key_length = (unsigned long)&sign_key_end -
			  (unsigned long)&sign_key;

	bio = BIO_new_mem_buf(&sign_key, sign_key_length);
	if (!bio)
		return NULL;

	key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL);
	BIO_free(bio);

	return key;
}

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ