Skip to content

Commit fcab35b

Browse files
committed
guix-attest: Produce and sign normalized documents
That way we can easily combine the document and detached signature to produce cleartext signature files for upload during the release process. See subsequent commits which modify doc/release-process.md for more details.
1 parent c2541fd commit fcab35b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

contrib/guix/guix-attest

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ Hint: You may wish to remove the existing attestations and their signatures by
159159
EOF
160160
}
161161

162+
# Given a document with unix line endings (just <LF>) in stdin, make all lines
163+
# end in <CR><LF> and make sure there's no trailing <LF> at the end of the file.
164+
#
165+
# This is necessary as cleartext signatures are calculated on text after their
166+
# line endings are canonicalized.
167+
#
168+
# For more information:
169+
# 1. https://security.stackexchange.com/a/104261
170+
# 2. https://datatracker.ietf.org/doc/html/rfc4880#section-7.1
171+
#
172+
rfc4880_normalize_document() {
173+
sed 's/$/\r/' | head -c -2
174+
}
175+
162176
echo "Attesting to build outputs for version: '${VERSION}'"
163177
echo ""
164178

@@ -174,7 +188,8 @@ mkdir -p "$outsigdir"
174188
cat "${noncodesigned_fragments[@]}" \
175189
| sort -u \
176190
| sort -k2 \
177-
> "$temp_noncodesigned"
191+
| rfc4880_normalize_document \
192+
> "$temp_noncodesigned"
178193
if [ -e noncodesigned.SHA256SUMS ]; then
179194
# The SHA256SUMS already exists, make sure it's exactly what we
180195
# expect, error out if not
@@ -201,7 +216,9 @@ mkdir -p "$outsigdir"
201216
cat "${sha256sum_fragments[@]}" \
202217
| sort -u \
203218
| sort -k2 \
204-
> "$temp_codesigned"
219+
| sed 's/$/\r/' \
220+
| rfc4880_normalize_document \
221+
> "$temp_codesigned"
205222
if [ -e codesigned.SHA256SUMS ]; then
206223
# The SHA256SUMS already exists, make sure it's exactly what we
207224
# expect, error out if not
@@ -226,6 +243,7 @@ mkdir -p "$outsigdir"
226243
for i in *.SHA256SUMS; do
227244
if [ ! -e "$i".asc ]; then
228245
gpg --detach-sign \
246+
--digest-algo sha256 \
229247
--local-user "$gpg_key_name" \
230248
--armor \
231249
--output "$i".asc "$i"

0 commit comments

Comments
 (0)