From patchwork Mon Dec 9 06:00:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1205919 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YQCl/azg"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47WXbD2rNLz9sNH for ; Mon, 9 Dec 2019 16:59:52 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 073E18164B; Mon, 9 Dec 2019 06:59:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YQCl/azg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E9C481653; Mon, 9 Dec 2019 06:59:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 197278163A for ; Mon, 9 Dec 2019 06:59:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1042.google.com with SMTP id l4so5384962pjt.5 for ; Sun, 08 Dec 2019 21:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mWQep0Iuau6MvIsaAqXLvNS/kbsgyC5O6EkPQja20xI=; b=YQCl/azg/b+cgrMsvg+icHxN5c1gyWEzl+L7jzclvUDQxswv+UDnEjgwzTmCEx8YwS sXbLYQA1OzjBIVmfkqczfc9SDzLBhfeqQcESvDYRsCkmGIBzAwFfIWhvqT+U2K6wpj24 RQl8GDG6j5q0bkkjaXPDtPVQ5XOwoT3FPmEkPiWNlZb3ahUXENH0AMVSrPYClYw9oRqE vOESiVWcDBkB8snJZ0FLiqOdsO8Y/rrsV69WmiDcvfsEouHIBWMjloZvcaK2Z/iRrzk2 zy8wU9yT3JZEE1NIXDf5GflfMbFgfP3J0n4ciTnP8MQfod8eU0swjVbmKrkUNjPLH388 1nvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mWQep0Iuau6MvIsaAqXLvNS/kbsgyC5O6EkPQja20xI=; b=dSM2H+fkwuvk18Y0Te8BsHh2DLU7V7j7Y0BddC22rrydGj0v4pBYFzHthyD8awzJ+L LsWQ4aHqPTXSdIY2/JeH6bv0NBYmKIGLhBWPZrteJNbv/pksA6KQyoByAf/ra8LQ+vXU 3PEA5B4SQaV9CnV1WBQrUnK3RDhlNYJPXADTHuq/J214PaMV+7vJtvKDtEogHu98XgSM HlXal8h6XU6E06kz/Xd/m9Pfl+Slk4261iOBdlhBwS+QqWPNlv6l7fAjvHlZ/zGmuW7x ApH162CY+Zi8SLJY9PRO5if0t18uln4SPLaMpU0q8KHAgIVQ7YkJbletxykph0KnoF7M 90rg== X-Gm-Message-State: APjAAAVTd/LH5cvtCiN3gu0FPTWgHVlEKyYynwrErRJ4mrB5iQxS9fxh IUlR/fUZq5Vgl00qKRJ80XeFlw== X-Google-Smtp-Source: APXvYqxrixwJzIEaAkg5D5jSfcoYZyVaB8k1PXyQilNxUOHauYF51Mpz5YWwF9BYfYRv0VrcZ0SnFA== X-Received: by 2002:a17:90b:4391:: with SMTP id in17mr30528315pjb.33.1575871172400; Sun, 08 Dec 2019 21:59:32 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id u10sm23099925pgg.41.2019.12.08.21.59.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2019 21:59:31 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v3 01/16] include: pe.h: add signature-related definitions Date: Mon, 9 Dec 2019 15:00:41 +0900 Message-Id: <20191209060056.32426-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209060056.32426-1-takahiro.akashi@linaro.org> References: <20191209060056.32426-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean The index (IMAGE_DIRECTORY_ENTRY_SECURITY) in a table points to a region containing authentication information (image's signature) in PE format. WIN_CERTIFICATE structure defines an embedded signature format. Those definitions will be used in my UEFI secure boot patch. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- include/pe.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/pe.h b/include/pe.h index bff3b0aa7a6c..086f2b860e99 100644 --- a/include/pe.h +++ b/include/pe.h @@ -155,6 +155,8 @@ typedef struct _IMAGE_SECTION_HEADER { uint32_t Characteristics; } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; +/* Indices for Optional Header Data Directories */ +#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 typedef struct _IMAGE_BASE_RELOCATION @@ -252,4 +254,20 @@ typedef struct _IMAGE_RELOCATION #define IMAGE_REL_AMD64_PAIR 0x000F #define IMAGE_REL_AMD64_SSPAN32 0x0010 +/* certificate appended to PE image */ +typedef struct _WIN_CERTIFICATE { + uint32_t dwLength; + uint16_t wRevision; + uint16_t wCertificateType; + uint8_t bCertificate[]; +} WIN_CERTIFICATE, *LPWIN_CERTIFICATE; + +/* Definitions for the contents of the certs data block */ +#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002 +#define WIN_CERT_TYPE_EFI_OKCS115 0x0EF0 +#define WIN_CERT_TYPE_EFI_GUID 0x0EF1 + +#define WIN_CERT_REVISION_1_0 0x0100 +#define WIN_CERT_REVISION_2_0 0x0200 + #endif /* _PE_H */