diff mbox

[U-Boot] includes: move openssl headers to include/u-boot

Message ID 1402604832-11697-1-git-send-email-jeroen@myspectrum.nl
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Jeroen Hofstee June 12, 2014, 8:27 p.m. UTC
commit 18b06652cd "tools: include u-boot version of sha256.h"
unconditionally forced the sha256.h from u-boot to be used
for tools instead of the host version. This is fragile though
as it will also include the host version. Therefore move it
to include/u-boot to join u-boot/md5.h etc which were renamed
for the same reason.

cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
---
build tested for ARM/powerpc/mips/sandbox
---
 board/gdsys/p1022/controlcenterd-id.c | 2 +-
 board/pcs440ep/pcs440ep.c             | 2 +-
 common/cmd_sha1sum.c                  | 2 +-
 common/hash.c                         | 4 ++--
 common/image-fit.c                    | 4 ++--
 common/image-sig.c                    | 4 ++--
 common/image.c                        | 2 +-
 drivers/crypto/ace_sha.c              | 4 ++--
 drivers/misc/cros_ec_sandbox.c        | 2 +-
 drivers/mmc/rpmb.c                    | 2 +-
 include/image.h                       | 2 +-
 include/{ => u-boot}/rsa-checksum.h   | 4 ++--
 include/{ => u-boot}/rsa.h            | 0
 include/{ => u-boot}/sha1.h           | 0
 include/{ => u-boot}/sha256.h         | 0
 lib/rsa/rsa-checksum.c                | 6 +++---
 lib/rsa/rsa-verify.c                  | 6 +++---
 lib/sha1.c                            | 2 +-
 lib/sha256.c                          | 2 +-
 lib/tpm.c                             | 2 +-
 tools/Makefile                        | 1 -
 tools/dumpimage.h                     | 2 +-
 tools/imagetool.h                     | 2 +-
 tools/mkimage.h                       | 2 +-
 tools/ubsha1.c                        | 2 +-
 25 files changed, 30 insertions(+), 31 deletions(-)
 rename include/{ => u-boot}/rsa-checksum.h (91%)
 rename include/{ => u-boot}/rsa.h (100%)
 rename include/{ => u-boot}/sha1.h (100%)
 rename include/{ => u-boot}/sha256.h (100%)

Comments

Simon Glass June 18, 2014, 5:25 a.m. UTC | #1
Hi Jeroen,

On 12 June 2014 13:27, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> commit 18b06652cd "tools: include u-boot version of sha256.h"
> unconditionally forced the sha256.h from u-boot to be used
> for tools instead of the host version. This is fragile though
> as it will also include the host version. Therefore move it
> to include/u-boot to join u-boot/md5.h etc which were renamed
> for the same reason.
>
> cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

This seems like a much better solution. But I think you should keep
the sort order - so u-boot/xxx should go after asm/xxx in the
#includes I think.

Regards,
Simon
Jeroen Hofstee June 18, 2014, 6:12 p.m. UTC | #2
On di, 2014-06-17 at 22:25 -0700, Simon Glass wrote:
> Hi Jeroen,
> 
> On 12 June 2014 13:27, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> > commit 18b06652cd "tools: include u-boot version of sha256.h"
> > unconditionally forced the sha256.h from u-boot to be used
> > for tools instead of the host version. This is fragile though
> > as it will also include the host version. Therefore move it
> > to include/u-boot to join u-boot/md5.h etc which were renamed
> > for the same reason.
> >
> > cc: Simon Glass <sjg@chromium.org>
> > Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
> 
> This seems like a much better solution. But I think you should keep
> the sort order - so u-boot/xxx should go after asm/xxx in the
> #includes I think.

I considered it, but e.g. common/image.c contains this before this
patch:

#include <u-boot/md5.h>
#include <sha1.h>
#include <asm/errno.h>
#include <asm/io.h>

While I can rearrange them, I think it should be a separate patch,
since it is not sorted in the first place. Furthermore if possible I
would prefer this commit to go into the current release and hence want
to keep it as short as possible. What I hadn't realized with the
original patch is that we don't replace the header but include them all.

On FreeBSD u-boot/sha256.h is included because the makefile said so,
but the host version of sha256.h is included as well by the source code
and the openssl/* will include similar headers again. And hence fails to
compile in the end.

Likely the same holds for libfdt_env.h, but this likely works for the
time being, since they have the same include guard.

Regards,
Jeroen
Simon Glass June 19, 2014, 1:21 a.m. UTC | #3
Hi,

On 18 June 2014 11:12, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
> On di, 2014-06-17 at 22:25 -0700, Simon Glass wrote:
>> Hi Jeroen,
>>
>> On 12 June 2014 13:27, Jeroen Hofstee <jeroen@myspectrum.nl> wrote:
>> > commit 18b06652cd "tools: include u-boot version of sha256.h"
>> > unconditionally forced the sha256.h from u-boot to be used
>> > for tools instead of the host version. This is fragile though
>> > as it will also include the host version. Therefore move it
>> > to include/u-boot to join u-boot/md5.h etc which were renamed
>> > for the same reason.
>> >
>> > cc: Simon Glass <sjg@chromium.org>
>> > Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
>>
>> This seems like a much better solution. But I think you should keep
>> the sort order - so u-boot/xxx should go after asm/xxx in the
>> #includes I think.
>
> I considered it, but e.g. common/image.c contains this before this
> patch:
>
> #include <u-boot/md5.h>
> #include <sha1.h>
> #include <asm/errno.h>
> #include <asm/io.h>
>
> While I can rearrange them, I think it should be a separate patch,
> since it is not sorted in the first place. Furthermore if possible I
> would prefer this commit to go into the current release and hence want
> to keep it as short as possible. What I hadn't realized with the
> original patch is that we don't replace the header but include them all.

OK with me, will await the follow-up patch.

Acked-by: Simon Glass <sjg@chromium.org>

Also I built it for everything and saw no regressions.

./tools/buildman/buildman -b try-jer  -s
Summary of 2 commits for 1198 boards (32 threads, 1 job per thread)
01: Merge branch 'master' of git://git.denx.de/u-boot-mmc
  blackfin: +   bf609-ezkit
      m68k: +   M5249EVB M54418TWR_serial_rmii M5253DEMO TASREG
M5235EVB M54418TWR_nand_mii M54418TWR_nand_rmii_lowfreq
M54418TWR_nand_rmii M54418TWR M5253EVBE M5235EVB_Flash32
M54418TWR_serial_mii M5272C3
   powerpc: +   neo io dlvision-10g P1022DS_36BIT iocon kilauea
socrates O2DNT2_RAMBOOT rainier NSCU MPC832XEMDS_HOST_33
mcc200_highboot_SDRAM quantum
        sh: +   rsk7269 rsk7264 rsk7203
     nios2: +   nios2-generic PCI5441 PK1C20
microblaze: +   microblaze-generic
  openrisc: +   openrisc-generic
       arm: +   highbank lager_nor integratorcp_cm920t omap4_sdp4430
sama5d3_xplained_mmc mx53loco omap4_panda duovero Cubietruck lager
k2hk_evm koelsch_nor koelsch trats2
02: includes: move openssl headers to include/u-boot

Regards,
Simon
Tom Rini June 19, 2014, 3:22 p.m. UTC | #4
On Thu, Jun 12, 2014 at 10:27:12PM +0200, Jeroen Hofstee wrote:

> commit 18b06652cd "tools: include u-boot version of sha256.h"
> unconditionally forced the sha256.h from u-boot to be used
> for tools instead of the host version. This is fragile though
> as it will also include the host version. Therefore move it
> to include/u-boot to join u-boot/md5.h etc which were renamed
> for the same reason.
> 
> cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/board/gdsys/p1022/controlcenterd-id.c b/board/gdsys/p1022/controlcenterd-id.c
index 3fca3c5..7e13c90 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -30,7 +30,7 @@ 
 #include <i2c.h>
 #include <mmc.h>
 #include <tpm.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
 #include <pca9698.h>
diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c
index f90e809..267c001 100644
--- a/board/pcs440ep/pcs440ep.c
+++ b/board/pcs440ep/pcs440ep.c
@@ -13,7 +13,7 @@ 
 #include <asm/processor.h>
 #include <spd_sdram.h>
 #include <status_led.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/io.h>
 #include <net.h>
 #include <ata.h>
diff --git a/common/cmd_sha1sum.c b/common/cmd_sha1sum.c
index 644b9a0..783ea2e 100644
--- a/common/cmd_sha1sum.c
+++ b/common/cmd_sha1sum.c
@@ -11,7 +11,7 @@ 
 #include <common.h>
 #include <command.h>
 #include <hash.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 
 int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/common/hash.c b/common/hash.c
index 237bd04..4417f36 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -15,8 +15,8 @@ 
 #include <malloc.h>
 #include <hw_sha.h>
 #include <hash.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 
diff --git a/common/image-fit.c b/common/image-fit.c
index 732505a..75208c7 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -21,10 +21,10 @@  DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 
 #include <bootstage.h>
-#include <sha1.h>
-#include <sha256.h>
 #include <u-boot/crc.h>
 #include <u-boot/md5.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 /*****************************************************************************/
 /* New uImage format routines */
diff --git a/common/image-sig.c b/common/image-sig.c
index 72284eb..21d5e51 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -13,8 +13,8 @@ 
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 #include <image.h>
-#include <rsa.h>
-#include <rsa-checksum.h>
+#include <u-boot/rsa.h>
+#include <u-boot/rsa-checksum.h>
 
 #define IMAGE_MAX_HASHED_NODES		100
 
diff --git a/common/image.c b/common/image.c
index f33b175..e723944 100644
--- a/common/image.c
+++ b/common/image.c
@@ -34,7 +34,7 @@ 
 #endif
 
 #include <u-boot/md5.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/errno.h>
 #include <asm/io.h>
 
diff --git a/drivers/crypto/ace_sha.c b/drivers/crypto/ace_sha.c
index ed4f541..efef491 100644
--- a/drivers/crypto/ace_sha.c
+++ b/drivers/crypto/ace_sha.c
@@ -8,8 +8,8 @@ 
 #include "ace_sha.h"
 
 #ifdef CONFIG_SHA_HW_ACCEL
-#include <sha256.h>
-#include <sha1.h>
+#include <u-boot/sha256.h>
+#include <u-boot/sha1.h>
 #include <asm/errno.h>
 
 /* SHA1 value for the message of zero length */
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 4bb1d60..8a04af5 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -13,7 +13,7 @@ 
 #include <hash.h>
 #include <malloc.h>
 #include <os.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 #include <spi.h>
 #include <asm/state.h>
 #include <asm/sdl.h>
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
index 05936f5..9d0b8bc 100644
--- a/drivers/mmc/rpmb.c
+++ b/drivers/mmc/rpmb.c
@@ -11,7 +11,7 @@ 
 #include <config.h>
 #include <common.h>
 #include <mmc.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 #include "mmc_private.h"
 
 /* Request codes */
diff --git a/include/image.h b/include/image.h
index b71e4ba..8e8c72b 100644
--- a/include/image.h
+++ b/include/image.h
@@ -882,7 +882,7 @@  struct image_region {
 };
 
 #if IMAGE_ENABLE_VERIFY
-# include <rsa-checksum.h>
+# include <u-boot/rsa-checksum.h>
 #endif
 struct checksum_algo {
 	const char *name;
diff --git a/include/rsa-checksum.h b/include/u-boot/rsa-checksum.h
similarity index 91%
rename from include/rsa-checksum.h
rename to include/u-boot/rsa-checksum.h
index 612db85..c996fb3 100644
--- a/include/rsa-checksum.h
+++ b/include/u-boot/rsa-checksum.h
@@ -9,8 +9,8 @@ 
 
 #include <errno.h>
 #include <image.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 extern const uint8_t padding_sha256_rsa4096[];
 extern const uint8_t padding_sha256_rsa2048[];
diff --git a/include/rsa.h b/include/u-boot/rsa.h
similarity index 100%
rename from include/rsa.h
rename to include/u-boot/rsa.h
diff --git a/include/sha1.h b/include/u-boot/sha1.h
similarity index 100%
rename from include/sha1.h
rename to include/u-boot/sha1.h
diff --git a/include/sha256.h b/include/u-boot/sha256.h
similarity index 100%
rename from include/sha256.h
rename to include/u-boot/sha256.h
diff --git a/lib/rsa/rsa-checksum.c b/lib/rsa/rsa-checksum.c
index 32d6602..8d8b59f 100644
--- a/lib/rsa/rsa-checksum.c
+++ b/lib/rsa/rsa-checksum.c
@@ -13,9 +13,9 @@ 
 #else
 #include "fdt_host.h"
 #endif
-#include <rsa.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/rsa.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 /* PKCS 1.5 paddings as described in the RSA PKCS#1 v2.1 standard. */
 
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 587da5b..bcb9063 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -17,9 +17,9 @@ 
 #include "mkimage.h"
 #include <fdt_support.h>
 #endif
-#include <rsa.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/rsa.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 #define UINT64_MULT32(v, multby)  (((uint64_t)(v)) * ((uint32_t)(multby)))
 
diff --git a/lib/sha1.c b/lib/sha1.c
index a121224..0a5f688 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -36,7 +36,7 @@ 
 #include <string.h>
 #endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include "sha1.h"
+#include <u-boot/sha1.h>
 
 /*
  * 32-bit integer manipulation macros (big endian)
diff --git a/lib/sha256.c b/lib/sha256.c
index b1085ea..bb338ba 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -13,7 +13,7 @@ 
 #include <string.h>
 #endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 
 /*
  * 32-bit integer manipulation macros (big endian)
diff --git a/lib/tpm.c b/lib/tpm.c
index 967c8e6..d9789b0 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -7,7 +7,7 @@ 
 
 #include <common.h>
 #include <stdarg.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <tpm.h>
 #include <asm/unaligned.h>
 
diff --git a/tools/Makefile b/tools/Makefile
index 0088c1a..5235539 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -191,7 +191,6 @@  endif # !LOGO_BMP
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
 HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
-		-include $(srctree)/include/sha256.h \
 		$(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
 		-I$(srctree)/lib/libfdt \
 		-I$(srctree)/tools \
diff --git a/tools/dumpimage.h b/tools/dumpimage.h
index d78523d..e415f14 100644
--- a/tools/dumpimage.h
+++ b/tools/dumpimage.h
@@ -18,7 +18,7 @@ 
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 #include "imagetool.h"
 
diff --git a/tools/imagetool.h b/tools/imagetool.h
index c480687..c8af0e8 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -18,7 +18,7 @@ 
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 
 #define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
diff --git a/tools/mkimage.h b/tools/mkimage.h
index d5491b6..3f369b7 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -18,7 +18,7 @@ 
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 #include "imagetool.h"
 
diff --git a/tools/ubsha1.c b/tools/ubsha1.c
index 1041588..4a17246 100644
--- a/tools/ubsha1.c
+++ b/tools/ubsha1.c
@@ -13,7 +13,7 @@ 
 #include <errno.h>
 #include <string.h>
 #include <sys/stat.h>
-#include "sha1.h"
+#include <u-boot/sha1.h>
 
 int main (int argc, char **argv)
 {