Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1576694pxb; Thu, 4 Mar 2021 15:17:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1Q110YfV4TenaMuDzPkyzdJsl6AUcFLnLZO60svWebX5wsv6he1mEstQKIWgCb3JUrlBH X-Received: by 2002:aa7:c550:: with SMTP id s16mr6861293edr.98.1614899879122; Thu, 04 Mar 2021 15:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899879; cv=none; d=google.com; s=arc-20160816; b=OL6DSdfKuMxShBHZCqoaXQ/ogzi+r7jYtaCbujDsJ5c1ngKY3jwEKqwtUGsNR+OnUX WQMRw0R2Fa2kliuGVjZStPvs7OV+KuQDUddt85jCehhcMg8Nj9hPSLPYv3f61TSOYNyA b7pgjJ7LRIWLPwbRLCCifc5QSy22GUKVOIuCoBmUGMin3JKrnec9+xlEuAvcVGadn0Sg 01UFnVh3ofYS857sbqWoze6MPq0563sTXu/dbS3Jeq7+R3irZ/tcYHlyf43nQY1ulivY C+t1y9tH46HeohoMGikBhB2TxA3QSuZ8sFX8yNfWZPg6jxA5qBcflbiLGxaAlsTTlPhf nvrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=FVkAnSS9B6fVkak8T/VDIOyay8ei0A1fw9elCz5VGA8=; b=lL9u+VX6Z+YHGjEyHKsj/D8YVu5roOek0wCkfJzs9pU+SSFpNFUFIC94q79uyUkpoq 8Myd/l0voFiENoHJLEKN6NMWoXfEIWcpGkA7LwlYZVj5gGnUFWEtf/3FKjKYzRx7bg0i NEhsj19nLk60oQRXMwHEzM1ZyJqtN/myJ8uaMt98vJQNyJMhOlZBuGj6t9jYK6o9HX7w SpMrTJ7pf8IJpmykIGrhfRRCrjsFRzO9yikq28Yo9y44OahF457pEynYVHe/LqQvHjYX 9aWgk898DrWAd199tL1IDyKp0uRjQroMc0H61VSw/9txiIXcaOK0G2kObi4Gv77XPHz/ RHrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bv10si346212ejb.352.2021.03.04.15.17.36; Thu, 04 Mar 2021 15:17:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384952AbhCCQjv (ORCPT + 99 others); Wed, 3 Mar 2021 11:39:51 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:39385 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239577AbhCCMFO (ORCPT ); Wed, 3 Mar 2021 07:05:14 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0UQFn22N_1614772990; Received: from B-455UMD6M-2027.local(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UQFn22N_1614772990) by smtp.aliyun-inc.com(127.0.0.1); Wed, 03 Mar 2021 20:03:11 +0800 Subject: Re: [PATCH] selftests/sgx: fix EINIT failure dueto SGX_INVALID_SIGNATURE To: Andy Lutomirski Cc: Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Sean Christopherson , Shuah Khan , X86 ML , linux-sgx@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Jia Zhang References: <20210301051836.30738-1-tianjia.zhang@linux.alibaba.com> <3bcdcf04-4bed-ed95-84b6-790675f18240@linux.alibaba.com> From: Tianjia Zhang Message-ID: <870e9a2e-65dd-131d-78c2-24de1ffffd31@linux.alibaba.com> Date: Wed, 3 Mar 2021 20:03:10 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/21 1:54 PM, Andy Lutomirski wrote: > On Mon, Mar 1, 2021 at 9:06 PM Tianjia Zhang > 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. > I agree with your opinion. Thanks, Tianjia