Update on init
.
Tried building init
explicitly with the flake using the below snippet which works. The commit is the last one which still has a Makefile.
init = pkgs.stdenv.mkDerivation {
name = "eif-init";
src = (pkgs.fetchFromGitHub {
owner = "aws";
repo = "aws-nitro-enclaves-sdk-bootstrap";
rev = "62dd55c";
sha256 = "sha256-OzLTHLX7pnrmldJJHx9xrb48ZOWawpMwrVL4gsGDlN8=";
}) + "/init"; # we just need the subfolder of this repo
nativeBuildInputs = [ pkgs.gcc pkgs.glibc.static ];
buildPhase = "make";
installPhase = "cp -r ./init $out";
};
Built using gcc explicitly instead of make
which also works.
init = pkgs.stdenv.mkDerivation {
name = "eif-init";
src = (pkgs.fetchFromGitHub {
owner = "aws";
repo = "aws-nitro-enclaves-sdk-bootstrap";
rev = "62dd55c";
sha256 = "sha256-OzLTHLX7pnrmldJJHx9xrb48ZOWawpMwrVL4gsGDlN8=";
}) + "/init"; # we just need the subfolder of this repo
nativeBuildInputs = [ pkgs.gcc pkgs.glibc.static ];
buildPhase = "gcc -Wall -Wextra -Werror -O2 -o init init.c -static -static-libgcc -flto && strip --strip-all init";
installPhase = "cp -r ./init $out";
};
Both of the above methods produce the same PCRs so they should be identical. Which makes sense since the gcc command is from the Makefile.
Switching to the latest commit, which also works!!
init = pkgs.stdenv.mkDerivation {
name = "eif-init";
src = (pkgs.fetchFromGitHub {
owner = "aws";
repo = "aws-nitro-enclaves-sdk-bootstrap";
rev = "7614f19";
sha256 = "sha256-jcdxssY3m/YAMIZSscZtnbPeAdFT5on2evD58YNwyxE=";
}) + "/init"; # we just need the subfolder of this repo
nativeBuildInputs = [ pkgs.gcc pkgs.glibc.static ];
buildPhase = "gcc -Wall -Wextra -Werror -O2 -o init init.c -static -static-libgcc -flto && strip --strip-all init";
installPhase = "cp -r ./init $out";
};
And produces the same enclave image as before with the following PCRs:
enclave> {
enclave> "HashAlgorithm": "Sha384 { ... }",
enclave> "PCR0": "f2fc4cdb0f563103998d6283e9b18e01fa6ac8e5f0625372d9ff36ef18da9bc1da89c266e2db517bbf0ce79670dab1bd",
enclave> "PCR1": "187d678b9f1988ae987d42a113d67da3bb8ab07a19d46ca2c7dee6e04e47c4280b01d696e575e0400349a78545edde46",
enclave> "PCR2": "1dc9cd9945ea55fec6095a609e9a3df1ea8a3b988664b1fb8c234bd5b1fdd0daaecf87b9c0d98378977063fc2001c2ba"
enclave> }
This indicates that the problem is not with the init per se.
Weirdly, the PCRs are different from when I use the init from the artifacts:
enclave> {
enclave> "HashAlgorithm": "Sha384 { ... }",
enclave> "PCR0": "c7fa718d1c7480a01cd2eb21b110405ce9253168555aaaed656187cd53ffc537547ce736060b0fa1aeb4fac3e026b81a",
enclave> "PCR1": "f53390d050384663e092ae7c8d12249d7c24869e1f925b0a1c6e7e4e10ef44747441e4cb585bce7b3d5c4a528987e067",
enclave> "PCR2": "1dc9cd9945ea55fec6095a609e9a3df1ea8a3b988664b1fb8c234bd5b1fdd0daaecf87b9c0d98378977063fc2001c2ba"
enclave> }
which indicates that both inits are not the same, which is surprising for builds that should be reproducible. The gcc command is the exact same as in init
’s nix file. Investigating the build pipeline for any issues.