Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qubes.PESign #475

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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