Skip to content

Commit

Permalink
Add qubes.PESign
Browse files Browse the repository at this point in the history
  • Loading branch information
fepitre committed Dec 2, 2023
1 parent 5a29270 commit 1357370
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion qubes-rpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ install:
qubes.ShowInTerminal \
qubes.ConnectTCP \
qubes.TemplateSearch \
qubes.TemplateDownload
qubes.TemplateDownload \
qubes.PESign
$(LN) qubes.VMExec $(DESTDIR)$(QUBESRPCCMDDIR)/qubes.VMExecGUI
for config in *.config; do \
install -D -m 0644 "$$config" "$(DESTDIR)$(QUBESRPCCONFDIR)/$${config%.config}"; \
Expand Down
33 changes: 33 additions & 0 deletions qubes-rpc/qubes.PESign
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -x -e -o pipefail

CERTIFICATE="$1"
[[ -z "$CERTIFICATE" ]] && { echo "Please provide certificate name"; exit 1; };

PAYLOAD_DIR="$(mktemp -d)"

cleanup() {
local payload_dir="$1"
if [ -n "${payload_dir}" ]; then
rm -rf "${payload_dir}"
fi
}

trap "cleanup ${PAYLOAD_DIR}" EXIT

payload="${PAYLOAD_DIR}/payload"

# Limit stdin size
head --bytes=100MB > "$payload"

# We don't allow payload being at least 100MB
actual_size="$(wc -c < "$payload")"
if [ "$actual_size" -eq $((100 * 1024 * 1024)) ]; then
echo "Input size is at least 100MB. Aborting."
exit 1
fi

pesign -s -c "${CERTIFICATE//__/ }" -i "$payload" -o "$payload".signed

cat "$payload".signed

0 comments on commit 1357370

Please sign in to comment.