reliant-system/qubes-sflc/build.sh
2025-09-05 17:04:33 -04:00

41 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/bash
set -euo pipefail
# Download the submodules
echo "[INFO]: Updating git submodules..."
git submodule update --init --recursive
# Apply the Argon2 memory parameter patch
echo "[INFO]: Applying Argon2 memory patch to improve KDF resilience..."
# Change the working directory
OLD_PWD=$PWD
cd shufflecake-c
# Apply the patch
CRYPTO_H=shufflecake-userland/include/utils/crypto.h
git restore $CRYPTO_H
patch $CRYPTO_H "$OLD_PWD/crypto.h.patch"
# Return back to qubes-sflc
cd "$OLD_PWD"
# Notify user of a breaking change
echo "[WARN]: Your new Argon2 memory parameter is 2097152 KiB, INCOMPATIBLE with default Shufflecake."
# Ensure Docker is running
echo "[INFO]: Starting the Docker container..."
sudo systemctl start docker
# Build and execute the container
sudo docker build -t qubes-sflc .
sudo docker run --rm -v /usr/lib/modules:/usr/lib/modules:ro -v $PWD/shufflecake-c:/root/shufflecake-c qubes-sflc
# Copy artifacts
echo "[INFO]: Copying build artifacts..."
cp shufflecake-c/dm-sflc.ko "$PWD/dm-sflc.ko"
cp shufflecake-c/shufflecake "$PWD/shufflecake"
# Restore the original crypto.h to avoid interference with future updates
cd shufflecake-c
git restore $CRYPTO_H