From: Junio C Hamano <hidden> Date: 2016-06-15 22:49:42
Michael J Gruber [off-list ref] writes:
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's faling to verify it's own
signed tags.
Be more lenient and take "-----BEGIN PGP " as the indicator.
Thanks, but it bothers me that the patch is a bit inconsistently lenient.
How many variants of PGP implementations are there? For example, I'd ask
these without doing my own research because I am lazy:
1. Does everybody place five dashes at the beginning (IOW, is there an
odd variant that puts four or six)?
2. Does everybody follow the dashes immediately with "BEGIN" (IOW, is
there an odd variant that puts a SP between them)?
3. Does everybody spell "BEGIN PGP " the same way, in all uppercase?
4. Does everybody place five dashes at the end (IOW, is there an odd
variant that puts four or six)?
5. Does everybody follow the "BEGIN PGP SOMETHING" immediately with
dashes without SP?
Your patch seem to answer <yes, yes, yes, no, no> to the above question.
I'd find it saner if the patched code at least checked that the line ends
with 5 dashes.
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:42
Junio C Hamano venit, vidit, dixit 05.10.2010 22:28:
Michael J Gruber [off-list ref] writes:
quoted
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's faling to verify it's own
signed tags.
Be more lenient and take "-----BEGIN PGP " as the indicator.
Thanks, but it bothers me that the patch is a bit inconsistently lenient.
How many variants of PGP implementations are there? For example, I'd ask
these without doing my own research because I am lazy:
1. Does everybody place five dashes at the beginning (IOW, is there an
odd variant that puts four or six)?
2. Does everybody follow the dashes immediately with "BEGIN" (IOW, is
there an odd variant that puts a SP between them)?
3. Does everybody spell "BEGIN PGP " the same way, in all uppercase?
4. Does everybody place five dashes at the end (IOW, is there an odd
variant that puts four or six)?
5. Does everybody follow the "BEGIN PGP SOMETHING" immediately with
dashes without SP?
Your patch seem to answer <yes, yes, yes, no, no> to the above question.
On 4,5, my patch only implies that I (suggest we) don't care.
I'd find it saner if the patched code at least checked that the line ends
with 5 dashes.
Alternatively, we can just say we support gnupg/openpg but not pgp 2.0,
and running gpg with pgp 2.0 options is discouraged even by gpg's man page.
The main issue here is that we create a detached signature (rather than
a clear text signature) but then lump it together with the content (the
tag object sans sig). The boundary mark between the two is not
controlled by us but by gpg (and its options).
In order to verify the sig, *we* have to split the lump again but we
don't really know the boundary mark. It's insane by design. We should
have used a non-volatile boundary mark.
I'll check whether we can somehow feed the whole lump to gpg and make it
recognize the attached-detached signature. That way we'd be as
compatible as gpg.
Michael
From: Stephan Hugel <hidden> Date: 2016-06-15 22:49:42
On 5 October 2010 21:42, Michael J Gruber [off-list ref] wrote:
Junio C Hamano venit, vidit, dixit 05.10.2010 22:28:
quoted
Michael J Gruber [off-list ref] writes:
quoted
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's faling to verify it's own
signed tags.
Be more lenient and take "-----BEGIN PGP " as the indicator.
Thanks, but it bothers me that the patch is a bit inconsistently lenient.
How many variants of PGP implementations are there? For example, I'd ask
these without doing my own research because I am lazy:
1. Does everybody place five dashes at the beginning (IOW, is there an
odd variant that puts four or six)?
2. Does everybody follow the dashes immediately with "BEGIN" (IOW, is
there an odd variant that puts a SP between them)?
3. Does everybody spell "BEGIN PGP " the same way, in all uppercase?
4. Does everybody place five dashes at the end (IOW, is there an odd
variant that puts four or six)?
5. Does everybody follow the "BEGIN PGP SOMETHING" immediately with
dashes without SP?
Your patch seem to answer <yes, yes, yes, no, no> to the above question.
On 4,5, my patch only implies that I (suggest we) don't care.
quoted
I'd find it saner if the patched code at least checked that the line ends
with 5 dashes.
Alternatively, we can just say we support gnupg/openpg but not pgp 2.0,
and running gpg with pgp 2.0 options is discouraged even by gpg's man page.
The main issue here is that we create a detached signature (rather than
a clear text signature) but then lump it together with the content (the
tag object sans sig). The boundary mark between the two is not
controlled by us but by gpg (and its options).
In order to verify the sig, *we* have to split the lump again but we
don't really know the boundary mark. It's insane by design. We should
have used a non-volatile boundary mark.
I'll check whether we can somehow feed the whole lump to gpg and make it
recognize the attached-detached signature. That way we'd be as
compatible as gpg.
Michael
5 dashes + BEGIN [other stuff] and
5 dashes + END
was part of RFC1991:
http://tools.ietf.org/html/rfc1991#section-2.4.1
Which was obsoleted by RFC4880 :
http://tools.ietf.org/html/rfc4880#section-6.2
5 dashes + BEGIN [some different stuff]
5 dashes + END
Aside from the above considerations, 5 dashes + BEGIN
would appear to conform to both the old and the current spec. Since
the current implementation of GnuPG only offers the rfc1991
compatibility options, complying with both covers all (i.e. both)
possibilties, no?
--
steph
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:42
Stephan Hugel venit, vidit, dixit 05.10.2010 22:51:
On 5 October 2010 21:42, Michael J Gruber [off-list ref] wrote:
quoted
Junio C Hamano venit, vidit, dixit 05.10.2010 22:28:
quoted
Michael J Gruber [off-list ref] writes:
quoted
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's faling to verify it's own
signed tags.
Be more lenient and take "-----BEGIN PGP " as the indicator.
Thanks, but it bothers me that the patch is a bit inconsistently lenient.
How many variants of PGP implementations are there? For example, I'd ask
these without doing my own research because I am lazy:
1. Does everybody place five dashes at the beginning (IOW, is there an
odd variant that puts four or six)?
2. Does everybody follow the dashes immediately with "BEGIN" (IOW, is
there an odd variant that puts a SP between them)?
3. Does everybody spell "BEGIN PGP " the same way, in all uppercase?
4. Does everybody place five dashes at the end (IOW, is there an odd
variant that puts four or six)?
5. Does everybody follow the "BEGIN PGP SOMETHING" immediately with
dashes without SP?
Your patch seem to answer <yes, yes, yes, no, no> to the above question.
On 4,5, my patch only implies that I (suggest we) don't care.
quoted
I'd find it saner if the patched code at least checked that the line ends
with 5 dashes.
Alternatively, we can just say we support gnupg/openpg but not pgp 2.0,
and running gpg with pgp 2.0 options is discouraged even by gpg's man page.
The main issue here is that we create a detached signature (rather than
a clear text signature) but then lump it together with the content (the
tag object sans sig). The boundary mark between the two is not
controlled by us but by gpg (and its options).
In order to verify the sig, *we* have to split the lump again but we
don't really know the boundary mark. It's insane by design. We should
have used a non-volatile boundary mark.
I'll check whether we can somehow feed the whole lump to gpg and make it
recognize the attached-detached signature. That way we'd be as
compatible as gpg.
Michael
5 dashes + BEGIN [other stuff] and
5 dashes + END
was part of RFC1991:
http://tools.ietf.org/html/rfc1991#section-2.4.1
Which was obsoleted by RFC4880 :
http://tools.ietf.org/html/rfc4880#section-6.2
5 dashes + BEGIN [some different stuff]
5 dashes + END
Aside from the above considerations, 5 dashes + BEGIN
would appear to conform to both the old and the current spec. Since
the current implementation of GnuPG only offers the rfc1991
compatibility options, complying with both covers all (i.e. both)
possibilties, no?
So, we (c|sh)ould really check for the two variants rather than being
lenient, right? I'll bite the v2 apple.
Michael
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:59
Use the factored out code for sig detection when displaying tags.
Signed-off-by: Michael J Gruber <redacted>
---
builtin/tag.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
@@ -68,9 +68,9 @@ static int show_reference(const char *refname, const unsigned char *sha1,return0;}/* only take up to "lines" lines, and strip the signature */+size=parse_signature(buf,size);for(i=0,sp+=2;-i<filter->lines&&sp<buf+size&&-prefixcmp(sp,PGP_SIGNATURE"\n");+i<filter->lines&&sp<buf+size;i++){if(i)printf("\n ");
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:59
This mini-series fixes the handling of signed tags for users
with "rfc1991" in their gpg config. In fact, the refactoring
done in the middle three patches would be worthwhile even
without the side effect of having to fix the handling in
one place only rather than three...
Michael J Gruber (5):
t/t7004-tag: test handling of rfc1991 signatures
verify-tag: factor out signature detection
tag: factor out sig detection for body edits
tag: factor out sig detection for tag display
tag: recognize rfc1991 signatures
builtin/tag.c | 16 ++++------------
builtin/verify-tag.c | 10 ++--------
t/t7004-tag.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
tag.c | 12 ++++++++++++
tag.h | 4 ++++
5 files changed, 65 insertions(+), 20 deletions(-)
--
1.7.3.2.193.g78bbb
@@ -37,11 +35,7 @@ static int run_gpg_verify(const char *buf, unsigned long size, int verbose)close(fd);/* find the length without signature */-len=0;-while(len<size&&prefixcmp(buf+len,PGP_SIGNATURE)){-eol=memchr(buf+len,'\n',size-len);-len+=eol?eol-(buf+len)+1:size-len;-}+len=parse_signature(buf,size);if(verbose)write_in_full(1,buf,len);
@@ -133,3 +133,14 @@ int parse_tag(struct tag *item)free(data);returnret;}++size_tparse_signature(constchar*buf,unsignedlongsize)+{+char*eol;+size_tlen=0;+while(len<size&&prefixcmp(buf+len,PGP_SIGNATURE)){+eol=memchr(buf+len,'\n',size-len);+len+=eol?eol-(buf+len)+1:size-len;+}+returnlen;+}
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:59
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's failing to verify it's own
signed tags, among other problems.
Add tests for all code paths (tag -v, tag -l -n largenumber, tag -f
without -m) where signature detection matters.
Reported-by: Stephan Hugel <redacted>
Signed-off-by: Michael J Gruber <redacted>
---
t/t7004-tag.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
@@ -1030,6 +1030,49 @@ test_expect_success GPG \test_cmpexpectactual'+# usage with rfc1991 signatures+echo"rfc1991">gpghome/gpg.conf+get_tag_headerrfc1991-signed-tag$commitcommit$time>expect+echo"RFC1991 signed tag">>expect+echo'-----BEGIN PGP MESSAGE-----'>>expect+test_expect_successGPG\+'creating a signed tag with rfc1991''+gittag-s-m"RFC1991 signed tag"rfc1991-signed-tag$commit&&+get_tag_msgrfc1991-signed-tag>actual&&+test_cmpexpectactual+'++cat>fakeeditor<<'EOF'+#!/bin/sh+cp"$1"actual+EOF+chmod+xfakeeditor++test_expect_failureGPG\+'reediting a signed tag body omits signature''+echo"RFC1991 signed tag">expect&&+GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&+test_cmpexpectactual+'++test_expect_failureGPG\+'verifying rfc1991 signature''+gittag-vrfc1991-signed-tag+'++test_expect_failureGPG\+'list tag with rfc1991 signature''+echo"rfc1991-signed-tag RFC1991 signed tag">expect&&+gittag-l-n1rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n2rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n999rfc1991-signed-tag>actual&&+test_cmpexpectactual+'++rm-fgpghome/gpg.conf+# try to sign with bad user.signingkey gitconfiguser.signingkeyBobTheMouse test_expect_successGPG\
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:59
Use the factored out code for sig detection when editing existing
tag bodies (tag -a -f without -m).
Signed-off-by: Michael J Gruber <redacted>
---
builtin/tag.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)
From: Michael J Gruber <hidden> Date: 2016-06-15 22:49:59
We have always been creating rfc1991 signatures for users with "rfc1991"
in their gpg config but failed to recognize them (tag -l -n largenumber)
and verify them (tag -v, verify-tag).
Make good use of the refactored signature detection and let us recognize
and verify those signatures also.
Signed-off-by: Michael J Gruber <redacted>
---
t/t7004-tag.sh | 6 +++---
tag.c | 3 ++-
tag.h | 1 +
3 files changed, 6 insertions(+), 4 deletions(-)
@@ -1048,19 +1048,19 @@ cp "$1" actual EOF chmod+xfakeeditor-test_expect_failureGPG\+test_expect_successGPG\'reediting a signed tag body omits signature''echo"RFC1991 signed tag">expect&&GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&test_cmpexpectactual'-test_expect_failureGPG\+test_expect_successGPG\'verifying rfc1991 signature''gittag-vrfc1991-signed-tag'-test_expect_failureGPG\+test_expect_successGPG\'list tag with rfc1991 signature''echo"rfc1991-signed-tag RFC1991 signed tag">expect&&gittag-l-n1rfc1991-signed-tag>actual&&
From: Michael J Gruber <hidden> Date: 2016-06-15 22:50:00
This mini-series fixes the handling of signed tags for users
with "rfc1991" in their gpg config. In fact, the refactoring
done in the middle three patches would be worthwhile even
without the side effect of having to fix the handling in
one place only rather than three...
v2 has these changes:
* additional tests for dealing with rfc1991 sigs without the rfc1991 option set (1/5)
* macros in tag.c rather than tag.h since they are used only in tag.c (2/5)
* logical && at eol for continued logical expression in C (5/5)
Michael J Gruber (5):
t/t7004-tag: test handling of rfc1991 signatures
verify-tag: factor out signature detection
tag: factor out sig detection for body edits
tag: factor out sig detection for tag display
tag: recognize rfc1991 signatures
builtin/tag.c | 16 +++---------
builtin/verify-tag.c | 10 +------
t/t7004-tag.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
tag.c | 15 +++++++++++
tag.h | 1 +
5 files changed, 88 insertions(+), 20 deletions(-)
--
1.7.3.2.193.g78bbb
From: Michael J Gruber <hidden> Date: 2016-06-15 22:50:00
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's failing to verify it's own
signed tags, among other problems.
Add tests for all code paths (tag -v, tag -l -n largenumber, tag -f
without -m) where signature detection matters.
Reported-by: Stephan Hugel <redacted>
Signed-off-by: Michael J Gruber <redacted>
---
t/t7004-tag.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
@@ -1030,6 +1030,72 @@ test_expect_success GPG \test_cmpexpectactual'+# usage with rfc1991 signatures+echo"rfc1991">gpghome/gpg.conf+get_tag_headerrfc1991-signed-tag$commitcommit$time>expect+echo"RFC1991 signed tag">>expect+echo'-----BEGIN PGP MESSAGE-----'>>expect+test_expect_successGPG\+'creating a signed tag with rfc1991''+gittag-s-m"RFC1991 signed tag"rfc1991-signed-tag$commit&&+get_tag_msgrfc1991-signed-tag>actual&&+test_cmpexpectactual+'++cat>fakeeditor<<'EOF'+#!/bin/sh+cp"$1"actual+EOF+chmod+xfakeeditor++test_expect_failureGPG\+'reediting a signed tag body omits signature''+echo"RFC1991 signed tag">expect&&+GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&+test_cmpexpectactual+'++test_expect_failureGPG\+'verifying rfc1991 signature''+gittag-vrfc1991-signed-tag+'++test_expect_failureGPG\+'list tag with rfc1991 signature''+echo"rfc1991-signed-tag RFC1991 signed tag">expect&&+gittag-l-n1rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n2rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n999rfc1991-signed-tag>actual&&+test_cmpexpectactual+'++rm-fgpghome/gpg.conf++test_expect_failureGPG\+'verifying rfc1991 signature without --rfc1991''+gittag-vrfc1991-signed-tag+'++test_expect_failureGPG\+'list tag with rfc1991 signature without --rfc1991''+echo"rfc1991-signed-tag RFC1991 signed tag">expect&&+gittag-l-n1rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n2rfc1991-signed-tag>actual&&+test_cmpexpectactual&&+gittag-l-n999rfc1991-signed-tag>actual&&+test_cmpexpectactual+'++test_expect_failureGPG\+'reediting a signed tag body omits signature''+echo"RFC1991 signed tag">expect&&+GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&+test_cmpexpectactual+'+# try to sign with bad user.signingkey gitconfiguser.signingkeyBobTheMouse test_expect_successGPG\
@@ -37,11 +35,7 @@ static int run_gpg_verify(const char *buf, unsigned long size, int verbose)close(fd);/* find the length without signature */-len=0;-while(len<size&&prefixcmp(buf+len,PGP_SIGNATURE)){-eol=memchr(buf+len,'\n',size-len);-len+=eol?eol-(buf+len)+1:size-len;-}+len=parse_signature(buf,size);if(verbose)write_in_full(1,buf,len);
@@ -133,3 +135,14 @@ int parse_tag(struct tag *item)free(data);returnret;}++size_tparse_signature(constchar*buf,unsignedlongsize)+{+char*eol;+size_tlen=0;+while(len<size&&prefixcmp(buf+len,PGP_SIGNATURE)){+eol=memchr(buf+len,'\n',size-len);+len+=eol?eol-(buf+len)+1:size-len;+}+returnlen;+}
From: Michael J Gruber <hidden> Date: 2016-06-15 22:50:00
Use the factored out code for sig detection when editing existing
tag bodies (tag -a -f without -m).
Signed-off-by: Michael J Gruber <redacted>
---
builtin/tag.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)
From: Michael J Gruber <hidden> Date: 2016-06-15 22:50:00
Use the factored out code for sig detection when displaying tags.
Signed-off-by: Michael J Gruber <redacted>
---
builtin/tag.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
@@ -68,9 +68,9 @@ static int show_reference(const char *refname, const unsigned char *sha1,return0;}/* only take up to "lines" lines, and strip the signature */+size=parse_signature(buf,size);for(i=0,sp+=2;-i<filter->lines&&sp<buf+size&&-prefixcmp(sp,PGP_SIGNATURE"\n");+i<filter->lines&&sp<buf+size;i++){if(i)printf("\n ");
From: Michael J Gruber <hidden> Date: 2016-06-15 22:50:00
We have always been creating rfc1991 signatures for users with "rfc1991"
in their gpg config but failed to recognize them (tag -l -n largenumber)
and verify them (tag -v, verify-tag).
Make good use of the refactored signature detection and let us recognize
and verify those signatures also.
Signed-off-by: Michael J Gruber <redacted>
---
t/t7004-tag.sh | 12 ++++++------
tag.c | 4 +++-
2 files changed, 9 insertions(+), 7 deletions(-)
@@ -1048,19 +1048,19 @@ cp "$1" actual EOF chmod+xfakeeditor-test_expect_failureGPG\+test_expect_successGPG\'reediting a signed tag body omits signature''echo"RFC1991 signed tag">expect&&GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&test_cmpexpectactual'-test_expect_failureGPG\+test_expect_successGPG\'verifying rfc1991 signature''gittag-vrfc1991-signed-tag'-test_expect_failureGPG\+test_expect_successGPG\'list tag with rfc1991 signature''echo"rfc1991-signed-tag RFC1991 signed tag">expect&&gittag-l-n1rfc1991-signed-tag>actual&&
@@ -1073,12 +1073,12 @@ test_expect_failure GPG \ rm-fgpghome/gpg.conf-test_expect_failureGPG\+test_expect_successGPG\'verifying rfc1991 signature without --rfc1991''gittag-vrfc1991-signed-tag'-test_expect_failureGPG\+test_expect_successGPG\'list tag with rfc1991 signature without --rfc1991''echo"rfc1991-signed-tag RFC1991 signed tag">expect&&gittag-l-n1rfc1991-signed-tag>actual&&
@@ -1089,7 +1089,7 @@ test_expect_failure GPG \test_cmpexpectactual'-test_expect_failureGPG\+test_expect_successGPG\'reediting a signed tag body omits signature''echo"RFC1991 signed tag">expect&&GIT_EDITOR=./fakeeditorgittag-f-srfc1991-signed-tag$commit&&