From patchwork Sat Nov 11 17:28:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Carvalho X-Patchwork-Id: 837056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yZ3rC0FGJz9sNd for ; Sun, 12 Nov 2017 04:32:27 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yZ3rB6CsVzDrLm for ; Sun, 12 Nov 2017 04:32:26 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=cclaudio@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yZ3mN5TkkzDrLc for ; Sun, 12 Nov 2017 04:29:08 +1100 (AEDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vABHQkb2187217 for ; Sat, 11 Nov 2017 12:29:06 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e5uq91qg1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 11 Nov 2017 12:29:05 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 11 Nov 2017 10:29:05 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 11 Nov 2017 10:29:03 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vABHT3hK7340466; Sat, 11 Nov 2017 10:29:03 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48093C6037; Sat, 11 Nov 2017 10:29:03 -0700 (MST) Received: from legolas.ibm.com (unknown [9.85.175.178]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 809EEC603C; Sat, 11 Nov 2017 10:29:02 -0700 (MST) From: Claudio Carvalho To: skiboot@lists.ozlabs.org Date: Sat, 11 Nov 2017 15:28:31 -0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510421322-27237-1-git-send-email-cclaudio@linux.vnet.ibm.com> References: <1510421322-27237-1-git-send-email-cclaudio@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17111117-0012-0000-0000-000015477B63 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008051; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00944424; UDB=6.00476526; IPR=6.00724686; BA=6.00005688; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017969; XFM=3.00000015; UTC=2017-11-11 17:29:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111117-0013-0000-0000-0000503A26F6 Message-Id: <1510421322-27237-9-git-send-email-cclaudio@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-11_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711110250 Subject: [Skiboot] [PATCH 08/19] libstb/cvc.c: import softrom behavior from drivers/sw_driver.c X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Softrom is used only for testing with mambo. By setting compatible="ibm,secureboot-v1-softrom" in the "ibm,secureboot" node, firmware images can be properly measured even if the Container-Verification-Code (CVC) is not available. In this case, the mbedtls_sha512() function is used to calculate the sha512 hash of the firmware images. This imports the softrom behavior from libstb/drivers/sw_driver.c code into cvc.c, but now softrom is implemented as a flag. When the flag is set, the wrappers for the CVC services work the same way as in sw_driver.c. Signed-off-by: Claudio Carvalho --- libstb/cvc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libstb/cvc.c b/libstb/cvc.c index ddb6a1c..5f46e5e 100644 --- a/libstb/cvc.c +++ b/libstb/cvc.c @@ -25,6 +25,7 @@ #include #include "container.h" #include "cvc.h" +#include "mbedtls/sha512.h" /* * Assembly interfaces to call into the Container Verification Code. @@ -251,6 +252,15 @@ int call_cvc_sha512(const uint8_t *data, size_t data_len, uint8_t *digest, return OPAL_SUCCESS; memset(digest, 0, SHA512_DIGEST_LENGTH); + if (softrom) { + mbedtls_sha512_context ctx; + mbedtls_sha512_init(&ctx); + mbedtls_sha512_starts(&ctx, 0); // SHA512 = 0 + mbedtls_sha512_update(&ctx, data, data_len); + mbedtls_sha512_finish(&ctx, digest); + mbedtls_sha512_free(&ctx); + return OPAL_SUCCESS; + } service = cvc_find_service(CVC_SHA512_SERVICE); @@ -276,6 +286,9 @@ int call_cvc_verify(void *container, size_t len, const void *hw_key_hash, !hw_key_hash || hw_key_hash_size <= 0) return OPAL_PARAMETER; + if (softrom) + return OPAL_RESOURCE; + service = cvc_find_service(CVC_VERIFY_SERVICE); if (!service)