Skip to contentSkip to conversation

lib/crypto, efi_loader: move some headers to include/crypto

PATCH New AKASHI Takahiro 2 participants 6 messages Apr 21, 2020 – May 5, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

---
 {lib => include}/crypto/pkcs7_parser.h | 0
 {lib => include}/crypto/x509_parser.h  | 0
 lib/crypto/pkcs7_parser.c              | 4 ++++
 lib/crypto/x509_cert_parser.c          | 4 ++++
 lib/crypto/x509_public_key.c           | 6 ++++--
 lib/efi_loader/efi_image_loader.c      | 4 ++--
 lib/efi_loader/efi_signature.c         | 4 ++--
 lib/efi_loader/efi_variable.c          | 2 +-
 test/lib/asn1.c                        | 4 ++--
 9 files changed, 19 insertions(+), 9 deletions(-)
 rename {lib => include}/crypto/pkcs7_parser.h (100%)
 rename {lib => include}/crypto/x509_parser.h (100%)
include/crypto/pkcs7_parser.h renamed from lib/crypto/pkcs7_parser.h +0 -0
similarity index 100%
rename from lib/crypto/pkcs7_parser.h
rename to include/crypto/pkcs7_parser.h
include/crypto/x509_parser.h renamed from lib/crypto/x509_parser.h +0 -0
similarity index 100%
rename from lib/crypto/x509_parser.h
rename to include/crypto/x509_parser.h
lib/crypto/pkcs7_parser.c +4 -0
index f5dda1179f8a..0ee207b6b1c8 100644
@@ -20,7 +20,11 @@
 #include <linux/err.h>
 #include <linux/oid_registry.h>
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/pkcs7_parser.h>
+#else
 #include "pkcs7_parser.h"
+#endif
 #include "pkcs7.asn1.h"
 
 MODULE_DESCRIPTION("PKCS#7 parser");
lib/crypto/x509_cert_parser.c +4 -0
index 4e41cffd2301..18f5407a076c 100644
@@ -18,7 +18,11 @@
 #include <linux/string.h>
 #endif
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include "x509_parser.h"
+#endif
 #include "x509.asn1.h"
 #include "x509_akid.asn1.h"
 
lib/crypto/x509_public_key.c +4 -2
index 676c0df17410..571af9a0adf9 100644
@@ -16,15 +16,17 @@
 #include <linux/module.h>
 #endif
 #include <linux/kernel.h>
-#ifndef __UBOOT__
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include <linux/slab.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#endif
 #include "x509_parser.h"
+#endif
 
 /*
  * Set up the signature parameters in an X.509 certificate.  This involves
lib/efi_loader/efi_image_loader.c +2 -2
index 899adf8493d0..f59b9a01140e 100644
@@ -13,8 +13,8 @@
 #include <malloc.h>
 #include <pe.h>
 #include <sort.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
+#include "crypto/pkcs7_parser.h"
+#include "crypto/x509_parser.h"
 
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
lib/efi_loader/efi_signature.c +2 -2
index 6ad09e4acbd7..0ead10203aeb 100644
@@ -10,12 +10,12 @@
 #include <image.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <crypto/pkcs7_parser.h>
+#include <crypto/x509_parser.h>
 #include <linux/compat.h>
 #include <linux/oid_registry.h>
 #include <u-boot/rsa.h>
 #include <u-boot/sha256.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
 
 const efi_guid_t efi_guid_image_security_database =
 		EFI_IMAGE_SECURITY_DATABASE_GUID;
lib/efi_loader/efi_variable.c +1 -1
index 7df881a74b44..0c6d1deb58eb 100644
@@ -12,9 +12,9 @@
 #include <malloc.h>
 #include <rtc.h>
 #include <search.h>
+#include <crypto/pkcs7_parser.h>
 #include <linux/compat.h>
 #include <u-boot/crc.h>
-#include "../lib/crypto/pkcs7_parser.h"
 
 enum efi_secure_mode {
 	EFI_MODE_SETUP,
test/lib/asn1.c +2 -2
index d2b3f67e68da..8661fdd30687 100644
@@ -13,10 +13,10 @@
 #include <test/ut.h>
 
 #ifdef CONFIG_PKCS7_MESSAGE_PARSER
-#include "../../lib/crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
 #else
 #ifdef CONFIG_X509_CERTIFICATE_PARSER
-#include "../../lib/crypto/x509_parser.h"
+#include <crypto/x509_parser.h>
 #endif
 #endif
 
Signature · 1 line
2.25.2
#1 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Quoted 88 lines · AKASHI Takahiro

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

---
 {lib => include}/crypto/pkcs7_parser.h | 0
 {lib => include}/crypto/x509_parser.h  | 0
 lib/crypto/pkcs7_parser.c              | 4 ++++
 lib/crypto/x509_cert_parser.c          | 4 ++++
 lib/crypto/x509_public_key.c           | 6 ++++--
 lib/efi_loader/efi_image_loader.c      | 4 ++--
 lib/efi_loader/efi_signature.c         | 4 ++--
 lib/efi_loader/efi_variable.c          | 2 +-
 test/lib/asn1.c                        | 4 ++--
 9 files changed, 19 insertions(+), 9 deletions(-)
 rename {lib => include}/crypto/pkcs7_parser.h (100%)
 rename {lib => include}/crypto/x509_parser.h (100%)
include/crypto/pkcs7_parser.h renamed from lib/crypto/pkcs7_parser.h +0 -0
similarity index 100%
rename from lib/crypto/pkcs7_parser.h
rename to include/crypto/pkcs7_parser.h
include/crypto/x509_parser.h renamed from lib/crypto/x509_parser.h +0 -0
similarity index 100%
rename from lib/crypto/x509_parser.h
rename to include/crypto/x509_parser.h
lib/crypto/pkcs7_parser.c +4 -0
index f5dda1179f8a..0ee207b6b1c8 100644
@@ -20,7 +20,11 @@
 #include <linux/err.h>
 #include <linux/oid_registry.h>
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/pkcs7_parser.h>
+#else
 #include "pkcs7_parser.h"
+#endif
 #include "pkcs7.asn1.h"
 
 MODULE_DESCRIPTION("PKCS#7 parser");
lib/crypto/x509_cert_parser.c +4 -0
index 4e41cffd2301..18f5407a076c 100644
@@ -18,7 +18,11 @@
 #include <linux/string.h>
 #endif
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include "x509_parser.h"
+#endif
 #include "x509.asn1.h"
 #include "x509_akid.asn1.h"
 
lib/crypto/x509_public_key.c +4 -2
index 676c0df17410..571af9a0adf9 100644
@@ -16,15 +16,17 @@
 #include <linux/module.h>
 #endif
 #include <linux/kernel.h>
-#ifndef __UBOOT__
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include <linux/slab.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#endif
 #include "x509_parser.h"
+#endif
 
 /*
  * Set up the signature parameters in an X.509 certificate.  This involves
lib/efi_loader/efi_image_loader.c +0 -0
index 899adf8493d0..f59b9a01140e 100644

lib/efi_loader/efi_image_loader.c line 17

Quoted 7 lines
lib/efi_loader/efi_image_loader.c +2 -2
@@ -13,8 +13,8 @@
 #include <malloc.h>
 #include <pe.h>
 #include <sort.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
+#include "crypto/pkcs7_parser.h"
+#include "crypto/x509_parser.h"

Thanks for fixing this.

x509_parser.h is included in pkcs7_parser.h. Please, remove the superfluous line.

lib/efi_loader/efi_signature.c line 14

Quoted 13 lines
lib/efi_loader/efi_image_loader.c +0 -0
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
lib/efi_loader/efi_signature.c +2 -0
index 6ad09e4acbd7..0ead10203aeb 100644
@@ -10,12 +10,12 @@
 #include <image.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <crypto/pkcs7_parser.h>
+#include <crypto/x509_parser.h>

Same here.

Best regards

Heinrich

Quoted 42 lines
lib/efi_loader/efi_signature.c +0 -2
 #include <linux/compat.h>
 #include <linux/oid_registry.h>
 #include <u-boot/rsa.h>
 #include <u-boot/sha256.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
 
 const efi_guid_t efi_guid_image_security_database =
 		EFI_IMAGE_SECURITY_DATABASE_GUID;
lib/efi_loader/efi_variable.c +1 -1
index 7df881a74b44..0c6d1deb58eb 100644
@@ -12,9 +12,9 @@
 #include <malloc.h>
 #include <rtc.h>
 #include <search.h>
+#include <crypto/pkcs7_parser.h>
 #include <linux/compat.h>
 #include <u-boot/crc.h>
-#include "../lib/crypto/pkcs7_parser.h"
 
 enum efi_secure_mode {
 	EFI_MODE_SETUP,
test/lib/asn1.c +2 -2
index d2b3f67e68da..8661fdd30687 100644
@@ -13,10 +13,10 @@
 #include <test/ut.h>
 
 #ifdef CONFIG_PKCS7_MESSAGE_PARSER
-#include "../../lib/crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
 #else
 #ifdef CONFIG_X509_CERTIFICATE_PARSER
-#include "../../lib/crypto/x509_parser.h"
+#include <crypto/x509_parser.h>
 #endif
 #endif
 
#2 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Heinrich,

Quoted 99 lines · Heinrich Schuchardt
Quoted 88 lines · AKASHI Takahiro

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

---
 {lib => include}/crypto/pkcs7_parser.h | 0
 {lib => include}/crypto/x509_parser.h  | 0
 lib/crypto/pkcs7_parser.c              | 4 ++++
 lib/crypto/x509_cert_parser.c          | 4 ++++
 lib/crypto/x509_public_key.c           | 6 ++++--
 lib/efi_loader/efi_image_loader.c      | 4 ++--
 lib/efi_loader/efi_signature.c         | 4 ++--
 lib/efi_loader/efi_variable.c          | 2 +-
 test/lib/asn1.c                        | 4 ++--
 9 files changed, 19 insertions(+), 9 deletions(-)
 rename {lib => include}/crypto/pkcs7_parser.h (100%)
 rename {lib => include}/crypto/x509_parser.h (100%)
include/crypto/pkcs7_parser.h renamed from lib/crypto/pkcs7_parser.h +0 -0
similarity index 100%
rename from lib/crypto/pkcs7_parser.h
rename to include/crypto/pkcs7_parser.h
include/crypto/x509_parser.h renamed from lib/crypto/x509_parser.h +0 -0
similarity index 100%
rename from lib/crypto/x509_parser.h
rename to include/crypto/x509_parser.h
lib/crypto/pkcs7_parser.c +4 -0
index f5dda1179f8a..0ee207b6b1c8 100644
@@ -20,7 +20,11 @@
 #include <linux/err.h>
 #include <linux/oid_registry.h>
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/pkcs7_parser.h>
+#else
 #include "pkcs7_parser.h"
+#endif
 #include "pkcs7.asn1.h"
 
 MODULE_DESCRIPTION("PKCS#7 parser");
lib/crypto/x509_cert_parser.c +4 -0
index 4e41cffd2301..18f5407a076c 100644
@@ -18,7 +18,11 @@
 #include <linux/string.h>
 #endif
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include "x509_parser.h"
+#endif
 #include "x509.asn1.h"
 #include "x509_akid.asn1.h"
 
lib/crypto/x509_public_key.c +4 -2
index 676c0df17410..571af9a0adf9 100644
@@ -16,15 +16,17 @@
 #include <linux/module.h>
 #endif
 #include <linux/kernel.h>
-#ifndef __UBOOT__
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include <linux/slab.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#endif
 #include "x509_parser.h"
+#endif
 
 /*
  * Set up the signature parameters in an X.509 certificate.  This involves
lib/efi_loader/efi_image_loader.c +0 -0
index 899adf8493d0..f59b9a01140e 100644

lib/efi_loader/efi_image_loader.c line 17

Quoted 7 lines
lib/efi_loader/efi_image_loader.c +2 -2
@@ -13,8 +13,8 @@
 #include <malloc.h>
 #include <pe.h>
 #include <sort.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
+#include "crypto/pkcs7_parser.h"
+#include "crypto/x509_parser.h"

Thanks for fixing this.

Quoted 2 lines

x509_parser.h is included in pkcs7_parser.h. Please, remove the superfluous line.

See my comment in [1]

[1] https://lists.denx.de/pipermail/u-boot/2020-April/408160.html

-Takahiro Akashi

Quoted 63 lines

lib/efi_loader/efi_signature.c line 14

Quoted 13 lines
lib/efi_loader/efi_image_loader.c +0 -0
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
lib/efi_loader/efi_signature.c +2 -0
index 6ad09e4acbd7..0ead10203aeb 100644
@@ -10,12 +10,12 @@
 #include <image.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <crypto/pkcs7_parser.h>
+#include <crypto/x509_parser.h>

Same here.

Best regards

Heinrich

Quoted 42 lines
lib/efi_loader/efi_signature.c +0 -2
 #include <linux/compat.h>
 #include <linux/oid_registry.h>
 #include <u-boot/rsa.h>
 #include <u-boot/sha256.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
 
 const efi_guid_t efi_guid_image_security_database =
 		EFI_IMAGE_SECURITY_DATABASE_GUID;
lib/efi_loader/efi_variable.c +1 -1
index 7df881a74b44..0c6d1deb58eb 100644
@@ -12,9 +12,9 @@
 #include <malloc.h>
 #include <rtc.h>
 #include <search.h>
+#include <crypto/pkcs7_parser.h>
 #include <linux/compat.h>
 #include <u-boot/crc.h>
-#include "../lib/crypto/pkcs7_parser.h"
 
 enum efi_secure_mode {
 	EFI_MODE_SETUP,
test/lib/asn1.c +2 -2
index d2b3f67e68da..8661fdd30687 100644
@@ -13,10 +13,10 @@
 #include <test/ut.h>
 
 #ifdef CONFIG_PKCS7_MESSAGE_PARSER
-#include "../../lib/crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
 #else
 #ifdef CONFIG_X509_CERTIFICATE_PARSER
-#include "../../lib/crypto/x509_parser.h"
+#include <crypto/x509_parser.h>
 #endif
 #endif
 
#3 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Quoted 102 lines · AKASHI Takahiro

Heinrich,

Quoted 99 lines · Heinrich Schuchardt
Quoted 88 lines · AKASHI Takahiro

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

---
 {lib => include}/crypto/pkcs7_parser.h | 0
 {lib => include}/crypto/x509_parser.h  | 0
 lib/crypto/pkcs7_parser.c              | 4 ++++
 lib/crypto/x509_cert_parser.c          | 4 ++++
 lib/crypto/x509_public_key.c           | 6 ++++--
 lib/efi_loader/efi_image_loader.c      | 4 ++--
 lib/efi_loader/efi_signature.c         | 4 ++--
 lib/efi_loader/efi_variable.c          | 2 +-
 test/lib/asn1.c                        | 4 ++--
 9 files changed, 19 insertions(+), 9 deletions(-)
 rename {lib => include}/crypto/pkcs7_parser.h (100%)
 rename {lib => include}/crypto/x509_parser.h (100%)
include/crypto/pkcs7_parser.h renamed from lib/crypto/pkcs7_parser.h +0 -0
similarity index 100%
rename from lib/crypto/pkcs7_parser.h
rename to include/crypto/pkcs7_parser.h
include/crypto/x509_parser.h renamed from lib/crypto/x509_parser.h +0 -0
similarity index 100%
rename from lib/crypto/x509_parser.h
rename to include/crypto/x509_parser.h
lib/crypto/pkcs7_parser.c +4 -0
index f5dda1179f8a..0ee207b6b1c8 100644
@@ -20,7 +20,11 @@
 #include <linux/err.h>
 #include <linux/oid_registry.h>
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/pkcs7_parser.h>
+#else
 #include "pkcs7_parser.h"
+#endif
 #include "pkcs7.asn1.h"
 
 MODULE_DESCRIPTION("PKCS#7 parser");
lib/crypto/x509_cert_parser.c +4 -0
index 4e41cffd2301..18f5407a076c 100644
@@ -18,7 +18,11 @@
 #include <linux/string.h>
 #endif
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include "x509_parser.h"
+#endif
 #include "x509.asn1.h"
 #include "x509_akid.asn1.h"
 
lib/crypto/x509_public_key.c +4 -2
index 676c0df17410..571af9a0adf9 100644
@@ -16,15 +16,17 @@
 #include <linux/module.h>
 #endif
 #include <linux/kernel.h>
-#ifndef __UBOOT__
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include <linux/slab.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#endif
 #include "x509_parser.h"
+#endif
 
 /*
  * Set up the signature parameters in an X.509 certificate.  This involves
lib/efi_loader/efi_image_loader.c +0 -0
index 899adf8493d0..f59b9a01140e 100644

lib/efi_loader/efi_image_loader.c line 17

Quoted 7 lines
lib/efi_loader/efi_image_loader.c +2 -2
@@ -13,8 +13,8 @@
 #include <malloc.h>
 #include <pe.h>
 #include <sort.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
+#include "crypto/pkcs7_parser.h"
+#include "crypto/x509_parser.h"

Thanks for fixing this.

Quoted 6 lines
Quoted 2 lines

x509_parser.h is included in pkcs7_parser.h. Please, remove the superfluous line.

See my comment in [1]

[1] https://lists.denx.de/pipermail/u-boot/2020-April/408160.html

We want U-Boot to build as fast as possible. So we should not include anything twice. When looking through the rest of the U-Boot code you will have noticed that we do not include malloc.h and stdio.h everywhere because it is included via common.h.

As an example of a patch removing other unnecessary includes see for instance:

cmd: fat: remove unused includes
fd0e30b43b6b2401e68dc32c357869c617d4fdd1

Best regards

Heinrich

Quoted 67 lines

-Takahiro Akashi

Quoted 63 lines

lib/efi_loader/efi_signature.c line 14

Quoted 13 lines
lib/efi_loader/efi_image_loader.c +0 -0
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
lib/efi_loader/efi_signature.c +2 -0
index 6ad09e4acbd7..0ead10203aeb 100644
@@ -10,12 +10,12 @@
 #include <image.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <crypto/pkcs7_parser.h>
+#include <crypto/x509_parser.h>

Same here.

Best regards

Heinrich

Quoted 42 lines
lib/efi_loader/efi_signature.c +0 -2
 #include <linux/compat.h>
 #include <linux/oid_registry.h>
 #include <u-boot/rsa.h>
 #include <u-boot/sha256.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
 
 const efi_guid_t efi_guid_image_security_database =
 		EFI_IMAGE_SECURITY_DATABASE_GUID;
lib/efi_loader/efi_variable.c +1 -1
index 7df881a74b44..0c6d1deb58eb 100644
@@ -12,9 +12,9 @@
 #include <malloc.h>
 #include <rtc.h>
 #include <search.h>
+#include <crypto/pkcs7_parser.h>
 #include <linux/compat.h>
 #include <u-boot/crc.h>
-#include "../lib/crypto/pkcs7_parser.h"
 
 enum efi_secure_mode {
 	EFI_MODE_SETUP,
test/lib/asn1.c +2 -2
index d2b3f67e68da..8661fdd30687 100644
@@ -13,10 +13,10 @@
 #include <test/ut.h>
 
 #ifdef CONFIG_PKCS7_MESSAGE_PARSER
-#include "../../lib/crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
 #else
 #ifdef CONFIG_X509_CERTIFICATE_PARSER
-#include "../../lib/crypto/x509_parser.h"
+#include <crypto/x509_parser.h>
 #endif
 #endif
 
#4 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Heinrich,

Quoted 106 lines · Heinrich Schuchardt
Quoted 105 lines · AKASHI Takahiro

Heinrich,

Quoted 101 lines · Heinrich Schuchardt
Quoted 88 lines · AKASHI Takahiro

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

---
 {lib => include}/crypto/pkcs7_parser.h | 0
 {lib => include}/crypto/x509_parser.h  | 0
 lib/crypto/pkcs7_parser.c              | 4 ++++
 lib/crypto/x509_cert_parser.c          | 4 ++++
 lib/crypto/x509_public_key.c           | 6 ++++--
 lib/efi_loader/efi_image_loader.c      | 4 ++--
 lib/efi_loader/efi_signature.c         | 4 ++--
 lib/efi_loader/efi_variable.c          | 2 +-
 test/lib/asn1.c                        | 4 ++--
 9 files changed, 19 insertions(+), 9 deletions(-)
 rename {lib => include}/crypto/pkcs7_parser.h (100%)
 rename {lib => include}/crypto/x509_parser.h (100%)
include/crypto/pkcs7_parser.h renamed from lib/crypto/pkcs7_parser.h +0 -0
similarity index 100%
rename from lib/crypto/pkcs7_parser.h
rename to include/crypto/pkcs7_parser.h
include/crypto/x509_parser.h renamed from lib/crypto/x509_parser.h +0 -0
similarity index 100%
rename from lib/crypto/x509_parser.h
rename to include/crypto/x509_parser.h
lib/crypto/pkcs7_parser.c +4 -0
index f5dda1179f8a..0ee207b6b1c8 100644
@@ -20,7 +20,11 @@
 #include <linux/err.h>
 #include <linux/oid_registry.h>
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/pkcs7_parser.h>
+#else
 #include "pkcs7_parser.h"
+#endif
 #include "pkcs7.asn1.h"
 
 MODULE_DESCRIPTION("PKCS#7 parser");
lib/crypto/x509_cert_parser.c +4 -0
index 4e41cffd2301..18f5407a076c 100644
@@ -18,7 +18,11 @@
 #include <linux/string.h>
 #endif
 #include <crypto/public_key.h>
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include "x509_parser.h"
+#endif
 #include "x509.asn1.h"
 #include "x509_akid.asn1.h"
 
lib/crypto/x509_public_key.c +4 -2
index 676c0df17410..571af9a0adf9 100644
@@ -16,15 +16,17 @@
 #include <linux/module.h>
 #endif
 #include <linux/kernel.h>
-#ifndef __UBOOT__
+#ifdef __UBOOT__
+#include <crypto/x509_parser.h>
+#else
 #include <linux/slab.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#endif
 #include "x509_parser.h"
+#endif
 
 /*
  * Set up the signature parameters in an X.509 certificate.  This involves
lib/efi_loader/efi_image_loader.c +0 -0
index 899adf8493d0..f59b9a01140e 100644

lib/efi_loader/efi_image_loader.c line 17

Quoted 7 lines
lib/efi_loader/efi_image_loader.c +2 -2
@@ -13,8 +13,8 @@
 #include <malloc.h>
 #include <pe.h>
 #include <sort.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
+#include "crypto/pkcs7_parser.h"
+#include "crypto/x509_parser.h"

Thanks for fixing this.

x509_parser.h is included in pkcs7_parser.h. Please, remove the superfluous line.

Quoted 8 lines
Quoted 3 lines

See my comment in [1]

[1] https://lists.denx.de/pipermail/u-boot/2020-April/408160.html

We want U-Boot to build as fast as possible. So we should not include anything twice. When looking through the rest of the U-Boot code you will have noticed that we do not include malloc.h and stdio.h everywhere because it is included via common.h.

I can't agree with you.
"common.h" is not a good example; its purpose is to aggregate some some useful header files so that people don't get bothered with finding out an exact set of header files needed.

"common.h" is even a *bad* example if you say, "We want U-Boot to build as fast as possible." because "common.h" may contain a lot of header files that may never be used in a given C file.

So I won't change my patch.

-Takahiro Akashi

Quoted 78 lines

As an example of a patch removing other unnecessary includes see for instance:

cmd: fat: remove unused includes
fd0e30b43b6b2401e68dc32c357869c617d4fdd1

Best regards

Heinrich

Quoted 67 lines

-Takahiro Akashi

Quoted 63 lines

lib/efi_loader/efi_signature.c line 14

Quoted 13 lines
lib/efi_loader/efi_image_loader.c +0 -0
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
lib/efi_loader/efi_signature.c +2 -0
index 6ad09e4acbd7..0ead10203aeb 100644
@@ -10,12 +10,12 @@
 #include <image.h>
 #include <hexdump.h>
 #include <malloc.h>
+#include <crypto/pkcs7_parser.h>
+#include <crypto/x509_parser.h>

Same here.

Best regards

Heinrich

Quoted 42 lines
lib/efi_loader/efi_signature.c +0 -2
 #include <linux/compat.h>
 #include <linux/oid_registry.h>
 #include <u-boot/rsa.h>
 #include <u-boot/sha256.h>
-#include "../lib/crypto/pkcs7_parser.h"
-#include "../lib/crypto/x509_parser.h"
 
 const efi_guid_t efi_guid_image_security_database =
 		EFI_IMAGE_SECURITY_DATABASE_GUID;
lib/efi_loader/efi_variable.c +1 -1
index 7df881a74b44..0c6d1deb58eb 100644
@@ -12,9 +12,9 @@
 #include <malloc.h>
 #include <rtc.h>
 #include <search.h>
+#include <crypto/pkcs7_parser.h>
 #include <linux/compat.h>
 #include <u-boot/crc.h>
-#include "../lib/crypto/pkcs7_parser.h"
 
 enum efi_secure_mode {
 	EFI_MODE_SETUP,
test/lib/asn1.c +2 -2
index d2b3f67e68da..8661fdd30687 100644
@@ -13,10 +13,10 @@
 #include <test/ut.h>
 
 #ifdef CONFIG_PKCS7_MESSAGE_PARSER
-#include "../../lib/crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
 #else
 #ifdef CONFIG_X509_CERTIFICATE_PARSER
-#include "../../lib/crypto/x509_parser.h"
+#include <crypto/x509_parser.h>
 #endif
 #endif
 
#5 lore raw

PATCH 1/1 lib/crypto, efi_loader: move some headers to include/crypto

Quoted 13 lines · AKASHI Takahiro

Heinrich,

Quoted 10 lines · Heinrich Schuchardt
Quoted 9 lines · AKASHI Takahiro

Heinrich,

Quoted 6 lines · Heinrich Schuchardt
Quoted 5 lines · AKASHI Takahiro

Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths.

Patch is merged. Thanks Heinrich