Something went wrong. Try again.
Sign git commits and tags with an OpenPGP key kept in Bitwarden.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#!/bin/sh# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT## Generates keys with GnuPG, signs with bwgpg's signer, and has GnuPG verify# the result. Run by `zig build interop`, which passes the signer's path.
set -eusigner=$1
work=$(mktemp -d)trap 'gpgconf --homedir "$work/gnupg" --kill all 2>/dev/null || true; rm -rf "$work"' EXITexport GNUPGHOME="$work/gnupg"mkdir -m 700 "$GNUPGHOME"
printf 'tree 4b825dc642cb6eb9a060e54bf8d69288fbe4904\nauthor A <a@example.org> 1767225600 +0000\n\nmessage\n' > "$work/data"
check() { name=$1 uid=$2 shift 2 gpg -q --batch --passphrase '' --quick-gen-key "$uid" "$@" 2>/dev/null fpr=$(gpg --with-colons --list-secret-keys "$uid" | awk -F: '/^fpr/ { print $10; exit }') gpg -q --batch --pinentry-mode loopback --passphrase '' --armor --export-secret-keys "$fpr" > "$work/$name.asc" "$signer" "$work/$name.asc" "$work/data" "$fpr" "$(date +%s)" > "$work/$name.sig" if gpg --batch --status-fd 1 --verify "$work/$name.sig" "$work/data" 2>/dev/null | grep -q '^\[GNUPG:\] GOODSIG'; then echo "ok $name" else echo "FAIL $name" gpg --batch --verify "$work/$name.sig" "$work/data" || true exit 1 fi}
check ed25519 'Interop Ed <ed@example.org>' ed25519 sign nevercheck rsa3072 'Interop RSA <rsa@example.org>' rsa3072 sign never
# An Ed25519 key with the Curve25519 encryption subkey GnuPG usually gives# one: bwgpg cannot use the subkey, and has to sign with the primary anyway.gpg -q --batch --passphrase '' --quick-gen-key 'Interop Enc <enc@example.org>' ed25519 sign never 2>/dev/nullfpr=$(gpg --with-colons --list-secret-keys enc@example.org 2>/dev/null | awk -F: '/^fpr/ { print $10; exit }')gpg -q --batch --passphrase '' --quick-add-key "$fpr" cv25519 encr never 2>/dev/nullgpg -q --batch --pinentry-mode loopback --passphrase '' --armor --export-secret-keys "$fpr" > "$work/enc.asc""$signer" "$work/enc.asc" "$work/data" "$fpr" "$(date +%s)" > "$work/enc.sig"if gpg --batch --status-fd 1 --verify "$work/enc.sig" "$work/data" 2>/dev/null | grep -q '^\[GNUPG:\] GOODSIG'; then echo "ok ed25519 with an encryption subkey"else echo "FAIL ed25519 with an encryption subkey" exit 1ficheck rsa4096 'Interop RSA4096 <rsa4096@example.org>' rsa4096 sign never
# A certify-only primary with a signing subkey: the selector names the# primary and the signature has to come from the subkey.gpg -q --batch --passphrase '' --quick-gen-key 'Interop Sub <sub@example.org>' ed25519 cert never 2>/dev/nullfpr=$(gpg --with-colons --list-secret-keys sub@example.org | awk -F: '/^fpr/ { print $10; exit }')gpg -q --batch --passphrase '' --quick-add-key "$fpr" ed25519 sign never 2>/dev/nullgpg -q --batch --pinentry-mode loopback --passphrase '' --armor --export-secret-keys "$fpr" > "$work/sub.asc""$signer" "$work/sub.asc" "$work/data" "$fpr" "$(date +%s)" > "$work/sub.sig"if gpg --batch --status-fd 1 --verify "$work/sub.sig" "$work/data" 2>/dev/null | grep -q '^\[GNUPG:\] GOODSIG'; then echo "ok subkey"else echo "FAIL subkey" exit 1fi