Skip to content

Commit dd3aa41

Browse files
FStelzergitster
authored andcommitted
ssh signing: make verify-tag consider key lifetime
Set the payload_type for check_signature() when calling verify-tag. Implements the same tests as for verify-commit. Signed-off-by: Fabian Stelzer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bbf378 commit dd3aa41

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

t/t7031-verify-tag-signed-ssh.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ test_expect_success GPGSSH 'create signed tags ssh' '
4848
git tag -u"${GPGSSH_KEY_UNTRUSTED}" -m eighth eighth-signed-alt
4949
'
5050

51+
test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed tags with keys having defined lifetimes' '
52+
test_when_finished "test_unconfig commit.gpgsign" &&
53+
test_config gpg.format ssh &&
54+
55+
echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
56+
git tag -s -u "${GPGSSH_KEY_EXPIRED}" -m expired-signed expired-signed &&
57+
58+
echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
59+
git tag -s -u "${GPGSSH_KEY_NOTYETVALID}" -m notyetvalid-signed notyetvalid-signed &&
60+
61+
echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
62+
git tag -s -u "${GPGSSH_KEY_TIMEBOXEDVALID}" -m timeboxedvalid-signed timeboxedvalid-signed &&
63+
64+
echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
65+
git tag -s -u "${GPGSSH_KEY_TIMEBOXEDINVALID}" -m timeboxedinvalid-signed timeboxedinvalid-signed
66+
'
67+
5168
test_expect_success GPGSSH 'verify and show ssh signatures' '
5269
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
5370
(
@@ -80,6 +97,31 @@ test_expect_success GPGSSH 'verify and show ssh signatures' '
8097
)
8198
'
8299

100+
test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'verify-tag exits failure on expired signature key' '
101+
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
102+
test_must_fail git verify-tag expired-signed 2>actual &&
103+
! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
104+
'
105+
106+
test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'verify-tag exits failure on not yet valid signature key' '
107+
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
108+
test_must_fail git verify-tag notyetvalid-signed 2>actual &&
109+
! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
110+
'
111+
112+
test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'verify-tag succeeds with tag date and key validity matching' '
113+
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
114+
git verify-tag timeboxedvalid-signed 2>actual &&
115+
grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
116+
! grep "${GPGSSH_BAD_SIGNATURE}" actual
117+
'
118+
119+
test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'verify-tag failes with tag date outside of key validity' '
120+
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
121+
test_must_fail git verify-tag timeboxedinvalid-signed 2>actual &&
122+
! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
123+
'
124+
83125
test_expect_success GPGSSH 'detect fudged ssh signature' '
84126
test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
85127
git cat-file tag seventh-signed >raw &&

tag.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
2525
return error("no signature found");
2626
}
2727

28+
sigc.payload_type = SIGNATURE_PAYLOAD_TAG;
2829
sigc.payload = strbuf_detach(&payload, &sigc.payload_len);
2930
ret = check_signature(&sigc, signature.buf, signature.len);
3031

0 commit comments

Comments
 (0)