Skip to content

Commit 165f90a

Browse files
Merge remote-tracking branch 'github-tlaurion/reproducible_openssl_libtss2_tpm2'
PR #1630
2 parents b2629f8 + 60d9aa4 commit 165f90a

8 files changed

Lines changed: 118 additions & 52 deletions

File tree

.circleci/config.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
docker:
4646
- image: debian:11
4747
resource_class: large
48+
working_directory: ~/heads
4849
steps:
4950
- run:
5051
name: Install dependencies
@@ -53,7 +54,6 @@ jobs:
5354
apt update
5455
apt install -y build-essential zlib1g-dev uuid-dev libdigest-sha-perl libelf-dev bc bzip2 bison flex git gnupg gawk iasl m4 nasm patch python python2 python3 wget gnat cpio ccache pkg-config cmake libusb-1.0-0-dev autoconf texinfo ncurses-dev doxygen graphviz udev libudev1 libudev-dev automake libtool rsync innoextract sudo imagemagick libncurses5-dev
5556
- checkout
56-
5757
- run:
5858
name: git reset
5959
command: |
@@ -120,6 +120,7 @@ jobs:
120120
docker:
121121
- image: debian:11
122122
resource_class: large
123+
working_directory: ~/heads
123124
parameters:
124125
arch:
125126
type: string
@@ -138,15 +139,16 @@ jobs:
138139
- persist_to_workspace:
139140
root: ~/
140141
paths:
141-
- project/packages/<<parameters.arch>>
142-
- project/build/<<parameters.arch>>
143-
- project/crossgcc/<<parameters.arch>>
144-
- project/install/<<parameters.arch>>
142+
- heads/packages/<<parameters.arch>>
143+
- heads/build/<<parameters.arch>>
144+
- heads/crossgcc/<<parameters.arch>>
145+
- heads/install/<<parameters.arch>>
145146

146147
build:
147148
docker:
148149
- image: debian:11
149150
resource_class: large
151+
working_directory: ~/heads
150152
parameters:
151153
arch:
152154
type: string
@@ -167,6 +169,7 @@ jobs:
167169
docker:
168170
- image: debian:11
169171
resource_class: large
172+
working_directory: ~/heads
170173
steps:
171174
- attach_workspace:
172175
at: ~/
@@ -236,13 +239,12 @@ workflows:
236239
# since kernel is 6.x and coreboot is git is unshared
237240
# We use nitropad's coreboot's fork crossgcc
238241
# No need to wait further for other board's cache.
239-
# We reuse built modules from x230-hotp-maximized cache only
240242
- build_and_persist:
241243
name: nitropad-nv41
242244
target: nitropad-nv41
243245
subcommand: ""
244246
requires:
245-
- x230-hotp-maximized
247+
- prep_env
246248

247249
# coreboot-git Talos II (PPC)
248250
- build_and_persist:
@@ -527,3 +529,4 @@ workflows:
527529
# path: build/UNMAINTAINED_qemu-linuxboot/linuxboot.rom
528530
# - store-artifacts:
529531
# path: build/UNMAINTAINED_qemu-linuxboot/hashes.txt
532+

initrd/bin/tpmr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ tpm2_startsession() {
347347
--saved-session ||
348348
die "tpm2_flushcontext: unable to flush saved session"
349349
tpm2 readpublic -Q -c "$PRIMARY_HANDLE" -t "$PRIMARY_HANDLE_FILE"
350-
tpm2 startauthsession -Q -c "$PRIMARY_HANDLE_FILE" --hmac-session -S "$ENC_SESSION_FILE"
351-
tpm2 startauthsession -Q -c "$PRIMARY_HANDLE_FILE" --hmac-session -S "$DEC_SESSION_FILE"
350+
#TODO: do the right thing to not have to suppress "WARN: check public portion the tpmkey manually" see https://github.com/linuxboot/heads/pull/1630#issuecomment-2075120429
351+
tpm2 startauthsession -Q -c "$PRIMARY_HANDLE_FILE" --hmac-session -S "$ENC_SESSION_FILE" 2>&1 > /dev/null
352+
#TODO: do the right thing to not have to suppress "WARN: check public portion the tpmkey manually" see https://github.com/linuxboot/heads/pull/1630#issuecomment-2075120429
353+
tpm2 startauthsession -Q -c "$PRIMARY_HANDLE_FILE" --hmac-session -S "$DEC_SESSION_FILE" 2>&1 > /dev/null
352354
tpm2 sessionconfig -Q --disable-encrypt "$DEC_SESSION_FILE"
353355
}
354356

modules/tpm2-tools

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,30 @@ ifeq "$(CONFIG_TPM2_TOOLS)" "y"
88
export CONFIG_TPM=y
99
endif
1010

11-
tpm2-tools_version := 5.2
12-
#tpm2-tools_version := 78a7681
13-
#tpm2-tools_repo := https://github.com/tpm2-software/tpm2-tools.git
11+
tpm2-tools_version := 5.6
1412

1513
tpm2-tools_dir := tpm2-tools-$(tpm2-tools_version)
1614
tpm2-tools_tar := tpm2-tools-$(tpm2-tools_version).tar.gz
1715
tpm2-tools_url := https://github.com/tpm2-software/tpm2-tools/releases/download/$(tpm2-tools_version)/$(tpm2-tools_tar)
18-
tpm2-tools_hash := c0b402f6a7b3456e8eb2445211e2d41c46c7e769e05fe4d8909ff64119f7a630
16+
tpm2-tools_hash := 52c8bcbaadca082abfe5eb7ee4967d2d632d84b1677675f2f071b6d2ec22cec3
1917

20-
# we have ESYS 3.0, but it doesn't figure that out on its own
21-
tpm2-tools_configure := ./bootstrap && ./configure \
18+
#tpm2-tools 5.6 adds release version based on git, while tarball downloaded doesn't include any .git
19+
# the patch comments out git output to ./VERSION, and we fill it here based on this Makefile's version
20+
#tpm2-tools doesn't play nice with reproducible builds, hardcoding lib paths without providing a configure option to remove rpaths
21+
# We make sure no hardcoding of libdir flags exist in configure script prior of calling the script with sed call
22+
# We pass additional remapping of prefix-map from $INSTALL to local dir
23+
#
24+
# TODO: remove all patches and uniformize with similar sed calls.
25+
tpm2-tools_configure := \
26+
echo "$(tpm2-tools_version)" > ./VERSION \
27+
&& ./bootstrap \
28+
&& sed -i 's/hardcode_libdir_flag_spec=.*/hardcode_libdir_flag_spec=" "/' configure \
29+
&& ./configure \
2230
$(CROSS_TOOLS) \
2331
--host $(MUSL_ARCH)-elf-linux \
2432
--prefix "/" \
2533
--disable-fapi \
26-
TSS2_ESYS_3_0_CFLAGS="-I$(INSTALL)/include" \
27-
TSS2_ESYS_3_0_LIBS="-ltss2-esys" \
34+
CFLAGS="-fdebug-prefix-map=$(INSTALL)=." \
2835

2936
tpm2-tools_target := $(MAKE_JOBS) \
3037
DESTDIR="$(INSTALL)" \

modules/tpm2-tss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# TPM2 TSS library
22
modules-$(CONFIG_TPM2_TSS) += tpm2-tss
33

4-
tpm2-tss_version := 3.2.0
4+
tpm2-tss_version := 3.2.2
55
tpm2-tss_dir := tpm2-tss-$(tpm2-tss_version)
66
tpm2-tss_tar := tpm2-tss-$(tpm2-tss_version).tar.gz
77
tpm2-tss_url := https://github.com/tpm2-software/tpm2-tss/releases/download/$(tpm2-tss_version)/$(tpm2-tss_tar)
8-
tpm2-tss_hash := 48305e4144dcf6d10f3b25b7bccf0189fd2d1186feafd8cd68c6b17ecf0d7912
8+
tpm2-tss_hash := ba9e52117f254f357ff502e7d60fce652b3bfb26327d236bbf5ab634235e40f1
99

10+
#Repro checks:
11+
# find build/x86/tpm2-tss-3.2.2/src/*/.libs/libtss2-*so* | while read file; do echo "library $file:"; strings $file|grep heads; done
12+
# Should not return any result
13+
14+
#NEEDED otherwise output on previous command
15+
#sed -i 's/hardcode_into_libs=yes/hardcode_into_libs=no/g' configure
16+
# needed otherwise library build/x86/tpm2-tss-3.2.2/src/tss2-tcti/.libs/libtss2-tcti-pcap.so.0.0.0:
17+
# contains: /home/user/heads/build/x86/tpm2-tss-3.2.2/src/tss2-tcti/.libs:/home/user/heads/build/x86/tpm2-tss-3.2.2/src/tss2-mu/.libs://lib
1018
tpm2-tss_configure := aclocal && automake --add-missing && autoreconf -fi \
19+
&& sed -i 's/hardcode_into_libs=yes/hardcode_into_libs=no/g' configure \
1120
&& ./configure \
1221
$(CROSS_TOOLS) \
1322
--host $(MUSL_ARCH)-elf-linux \
@@ -17,6 +26,7 @@ tpm2-tss_configure := aclocal && automake --add-missing && autoreconf -fi \
1726
--disable-doxygen-rtf \
1827
--disable-doxygen-html \
1928
--disable-fapi \
29+
--disable-static \
2030

2131
# Run one build to generate the executables with the pre-defined
2232
# exec_prefix and datarootdir, then a second make to install the binaries

patches/openssl-3.0.8.patch

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--- ./util/mkbuildinf.pl.orig 2023-02-07 08:43:33.000000000 -0500
2+
+++ ./util/mkbuildinf.pl 2024-03-27 14:36:49.974651246 -0400
3+
@@ -12,7 +12,7 @@
4+
my ($cflags, $platform) = @ARGV;
5+
$cflags = "compiler: $cflags";
6+
7+
-my $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} || time()) . " UTC";
8+
+my $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} || '0') . " UTC";
9+
10+
print <<"END_OUTPUT";
11+
/*
12+
@@ -36,21 +36,7 @@
13+
* literal
14+
*/
15+
static const char compiler_flags[] = {
16+
-END_OUTPUT
17+
-
18+
-my $ctr = 0;
19+
-foreach my $c (split //, $cflags) {
20+
- $c =~ s|([\\'])|\\$1|;
21+
- # Max 16 characters per line
22+
- if (($ctr++ % 16) == 0) {
23+
- if ($ctr != 1) {
24+
- print "\n";
25+
- }
26+
- print " ";
27+
- }
28+
- print "'$c',";
29+
-}
30+
-print <<"END_OUTPUT";
31+
-'\\0'
32+
+ 'r','e','p','r','o','d','u','c','i','b','l','e',' ','b','u','i',
33+
+ 'l','d','\\0'
34+
};
35+
END_OUTPUT

patches/tpm2-tools-5.2.patch

Lines changed: 0 additions & 33 deletions
This file was deleted.

patches/tpm2-tools-5.6.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--- ./bootstrap.orig 2023-11-08 02:19:36.000000000 -0500
2+
+++ ./bootstrap 2024-04-03 12:18:46.722995465 -0400
3+
@@ -5,7 +5,7 @@
4+
5+
# Generate a VERSION file that is included in the dist tarball to avoid needed git
6+
# when calling autoreconf in a release tarball.
7+
-git describe --tags --always --dirty > VERSION
8+
+#git describe --tags --always --dirty > VERSION
9+
10+
# generate list of source files for use in Makefile.am
11+
# if you add new source files, you must run ./bootstrap again
12+
diff --git a/Makefile.am b/Makefile.am
13+
index 7132215..32e2193 100644
14+
--- a/Makefile.am
15+
+++ b/Makefile.am
16+
@@ -93,7 +93,7 @@ tss2_tools = \
17+
18+
# Bundle all the tools into a single program similar to busybox
19+
bin_PROGRAMS += tools/tpm2
20+
-tools_tpm2_LDADD = $(LDADD) $(CURL_LIBS)
21+
+tools_tpm2_LDADD = $(LDADD)
22+
tools_tpm2_CFLAGS = $(AM_CFLAGS) -DTPM2_TOOLS_MAX="$(words $(tpm2_tools))"
23+
tools_tpm2_SOURCES = \
24+
tools/tpm2_tool.c \
25+
@@ -127,7 +127,6 @@ tpm2_tools = \
26+
tools/tpm2_encryptdecrypt.c \
27+
tools/tpm2_evictcontrol.c \
28+
tools/tpm2_flushcontext.c \
29+
- tools/tpm2_getekcertificate.c \
30+
tools/tpm2_getrandom.c \
31+
tools/tpm2_gettime.c \
32+
tools/tpm2_hash.c \
33+
--- ./configure.ac.orig 2023-11-08 02:19:36.000000000 -0500
34+
+++ ./configure.ac 2024-04-02 12:05:00.270985575 -0400
35+
@@ -80,7 +80,6 @@
36+
AC_CHECK_LIB(crypto, [EVP_sm4_cfb128], [
37+
AC_DEFINE([HAVE_EVP_SM4_CFB], [1], [Support EVP_sm4_cfb in openssl])],
38+
[])
39+
-PKG_CHECK_MODULES([CURL], [libcurl])
40+
41+
# pretty print of devicepath if efivar library is present
42+
# auto detect if not specified via the --with-efivar option.

0 commit comments

Comments
 (0)