<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/gpg-interface.h, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2021-12-09T21:38:04Z</updated>
<entry>
<title>ssh signing: make verify-commit consider key lifetime</title>
<updated>2021-12-09T21:38:04Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-12-09T08:52:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=6393c956f4e7061d6b19981bd8cd28ef037b911e'/>
<id>urn:sha1:6393c956f4e7061d6b19981bd8cd28ef037b911e</id>
<content type='text'>
If valid-before/after dates are configured for this signatures key in the
allowedSigners file then the verification should check if the key was valid at
the time the commit was made. This allows for graceful key rollover and
revoking keys without invalidating all previous commits.
This feature needs openssh &gt; 8.8. Older ssh-keygen versions will simply
ignore this flag and use the current time.
Strictly speaking this feature is available in 8.7, but since 8.7 has a
bug that makes it unusable in another needed call we require 8.8.

Timestamp information is present on most invocations of check_signature.
However signer ident is not. We will need the signer email / name to be able
to implement "Trust on first use" functionality later.
Since the payload contains all necessary information we can parse it
from there. The caller only needs to provide us some info about the
payload by setting payload_type in the signature_check struct.

 - Add payload_type field &amp; enum and payload_timestamp to struct
   signature_check
 - Populate the timestamp when not already set if we know about the
   payload type
 - Pass -Overify-time={payload_timestamp} in the users timezone to all
   ssh-keygen verification calls
 - Set the payload type when verifying commits
 - Add tests for expired, not yet valid and keys having a commit date
   outside of key validity as well as within

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ssh signing: use sigc struct to pass payload</title>
<updated>2021-12-09T21:38:04Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-12-09T08:52:43Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=02769437e1421d837f6de27cfb5c14087cfec8dd'/>
<id>urn:sha1:02769437e1421d837f6de27cfb5c14087cfec8dd</id>
<content type='text'>
To be able to extend the payload metadata with things like its creation
timestamp or the creators ident we remove the payload parameters to
check_signature() and use the already existing sigc-&gt;payload field
instead, only adding the length field to the struct. This also allows
us to get rid of the xmemdupz() calls in the verify functions. Since
sigc is now used to input data as well as output the result move it to
the front of the function list.

 - Add payload_length to struct signature_check
 - Populate sigc.payload/payload_len on all call sites
 - Remove payload parameters to check_signature()
 - Remove payload parameters to internal verify_* functions and use sigc
   instead
 - Remove xmemdupz() used for verbose output since payload is now already
   populated.

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ssh signing: provide a textual signing_key_id</title>
<updated>2021-09-10T21:15:52Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-09-10T20:07:38Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4838f62c8caffbfe5d7d39cad4e8aeb2a2d57da8'/>
<id>urn:sha1:4838f62c8caffbfe5d7d39cad4e8aeb2a2d57da8</id>
<content type='text'>
For ssh the user.signingkey can be a filename/path or even a literal ssh pubkey.
In push certs and textual output we prefer the ssh fingerprint instead.

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ssh signing: preliminary refactoring and clean-up</title>
<updated>2021-09-10T21:15:51Z</updated>
<author>
<name>Fabian Stelzer</name>
<email>fs@gigacodes.de</email>
</author>
<published>2021-09-10T20:07:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=b5726a5d9cabba0bd8fb6c1b25a887bc7ea4650d'/>
<id>urn:sha1:b5726a5d9cabba0bd8fb6c1b25a887bc7ea4650d</id>
<content type='text'>
Openssh v8.2p1 added some new options to ssh-keygen for signature
creation and verification. These allow us to use ssh keys for git
signatures easily.

In our corporate environment we use PIV x509 Certs on Yubikeys for email
signing/encryption and ssh keys which I think is quite common
(at least for the email part). This way we can establish the correct
trust for the SSH Keys without setting up a separate GPG Infrastructure
(which is still quite painful for users) or implementing x509 signing
support for git (which lacks good forwarding mechanisms).
Using ssh agent forwarding makes this feature easily usable in todays
development environments where code is often checked out in remote VMs / containers.
In such a setup the keyring &amp; revocationKeyring can be centrally
generated from the x509 CA information and distributed to the users.

To be able to implement new signing formats this commit:
 - makes the sigc structure more generic by renaming "gpg_output" to
   "output"
 - introduces function pointers in the gpg_format structure to call
   format specific signing and verification functions
 - moves format detection from verify_signed_buffer into the check_signature
   api function and calls the format specific verify
 - renames and wraps sign_buffer to handle format specific signing logic
   as well

Signed-off-by: Fabian Stelzer &lt;fs@gigacodes.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: improve interface for parsing tags</title>
<updated>2021-02-11T07:35:42Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2021-02-11T02:08:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=482c119186987110bfccf705a5ac75d399b08766'/>
<id>urn:sha1:482c119186987110bfccf705a5ac75d399b08766</id>
<content type='text'>
We have a function which parses a buffer with a signature at the end,
parse_signature, and this function is used for signed tags.  However,
we'll need to store values for multiple algorithms, and we'll do this by
using a header for the non-default algorithm.

Adjust the parse_signature interface to store the parsed data in two
strbufs and turn the existing function into parse_signed_buffer.  The
latter is still used in places where we know we always have a signed
buffer, such as push certs.

Adjust all the callers to deal with this new interface.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>gpg-interface: prefer check_signature() for GPG verification</title>
<updated>2020-03-15T16:46:28Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2020-03-04T11:48:04Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=67948981983b336eab2fa7e6a0e125d529391dfc'/>
<id>urn:sha1:67948981983b336eab2fa7e6a0e125d529391dfc</id>
<content type='text'>
This commit refactors the use of verify_signed_buffer() outside of
gpg-interface.c to use check_signature() instead.  It also turns
verify_signed_buffer() into a file-local function since it's now only
invoked internally by check_signature().

There were previously two globally scoped functions used in different
parts of Git to perform GPG signature verification:
verify_signed_buffer() and check_signature().  Now only
check_signature() is used.

The verify_signed_buffer() function doesn't guard against duplicate
signatures as described by Michał Górny [1].  Instead it only ensures a
non-erroneous exit code from GPG and the presence of at least one
GOODSIG status field.  This stands in contrast with check_signature()
that returns an error if more than one signature is encountered.

The lower degree of verification makes the use of verify_signed_buffer()
problematic if callers don't parse and validate the various parts of the
GPG status message themselves.  And processing these messages seems like
a task that should be reserved to gpg-interface.c with the function
check_signature().

Furthermore, the use of verify_signed_buffer() makes it difficult to
introduce new functionality that relies on the content of the GPG status
lines.

Now all operations that does signature verification share a single entry
point to gpg-interface.c.  This makes it easier to propagate changed or
additional functionality in GPG signature verification to all parts of
Git, without having odd edge-cases that don't perform the same degree of
verification.

[1] https://dev.gentoo.org/~mgorny/articles/attack-on-git-signature-verification.html

Signed-off-by: Hans Jerry Illikainen &lt;hji@dyntopia.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'hi/gpg-use-check-signature'</title>
<updated>2020-03-05T18:43:05Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-03-05T18:43:05Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e63cefb024895fcff4b692cad84cb33ac4c81dcc'/>
<id>urn:sha1:e63cefb024895fcff4b692cad84cb33ac4c81dcc</id>
<content type='text'>
"git merge signed-tag" while lacking the public key started to say
"No signature", which was utterly wrong.  This regression has been
reverted.

* hi/gpg-use-check-signature:
  Revert "gpg-interface: prefer check_signature() for GPG verification"
</content>
</entry>
<entry>
<title>Revert "gpg-interface: prefer check_signature() for GPG verification"</title>
<updated>2020-02-28T17:43:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-02-28T17:43:17Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=0106b1d4be166fd4f7bcf0b901d50940c9f539e2'/>
<id>urn:sha1:0106b1d4be166fd4f7bcf0b901d50940c9f539e2</id>
<content type='text'>
This reverts commit 72b006f4bfd30b7c5037c163efaf279ab65bea9c, which
breaks the end-user experience when merging a signed tag without
having the public key.  We should report "can't check because we
have no public key", but the code with this change claimed that
there was no signature.
</content>
</entry>
<entry>
<title>Merge branch 'hi/gpg-mintrustlevel'</title>
<updated>2020-01-30T22:17:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-01-30T22:17:08Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=11ad30b887e2512df1c7703913048827080601e1'/>
<id>urn:sha1:11ad30b887e2512df1c7703913048827080601e1</id>
<content type='text'>
gpg.minTrustLevel configuration variable has been introduced to
tell various signature verification codepaths the required minimum
trust level.

* hi/gpg-mintrustlevel:
  gpg-interface: add minTrustLevel as a configuration option
</content>
</entry>
<entry>
<title>gpg-interface: add minTrustLevel as a configuration option</title>
<updated>2020-01-15T22:06:06Z</updated>
<author>
<name>Hans Jerry Illikainen</name>
<email>hji@dyntopia.com</email>
</author>
<published>2019-12-27T13:55:57Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=54887b46890582e60fcb8ee1f287f62870c2ac0f'/>
<id>urn:sha1:54887b46890582e60fcb8ee1f287f62870c2ac0f</id>
<content type='text'>
Previously, signature verification for merge and pull operations checked
if the key had a trust-level of either TRUST_NEVER or TRUST_UNDEFINED in
verify_merge_signature().  If that was the case, the process die()d.

The other code paths that did signature verification relied entirely on
the return code from check_commit_signature().  And signatures made with
a good key, irregardless of its trust level, was considered valid by
check_commit_signature().

This difference in behavior might induce users to erroneously assume
that the trust level of a key in their keyring is always considered by
Git, even for operations where it is not (e.g. during a verify-commit or
verify-tag).

The way it worked was by gpg-interface.c storing the result from the
key/signature status *and* the lowest-two trust levels in the `result`
member of the signature_check structure (the last of these status lines
that were encountered got written to `result`).  These are documented in
GPG under the subsection `General status codes` and `Key related`,
respectively [1].

The GPG documentation says the following on the TRUST_ status codes [1]:

    """
    These are several similar status codes:

    - TRUST_UNDEFINED &lt;error_token&gt;
    - TRUST_NEVER     &lt;error_token&gt;
    - TRUST_MARGINAL  [0  [&lt;validation_model&gt;]]
    - TRUST_FULLY     [0  [&lt;validation_model&gt;]]
    - TRUST_ULTIMATE  [0  [&lt;validation_model&gt;]]

    For good signatures one of these status lines are emitted to
    indicate the validity of the key used to create the signature.
    The error token values are currently only emitted by gpgsm.
    """

My interpretation is that the trust level is conceptionally different
from the validity of the key and/or signature.  That seems to also have
been the assumption of the old code in check_signature() where a result
of 'G' (as in GOODSIG) and 'U' (as in TRUST_NEVER or TRUST_UNDEFINED)
were both considered a success.

The two cases where a result of 'U' had special meaning were in
verify_merge_signature() (where this caused git to die()) and in
format_commit_one() (where it affected the output of the %G? format
specifier).

I think it makes sense to refactor the processing of TRUST_ status lines
such that users can configure a minimum trust level that is enforced
globally, rather than have individual parts of git (e.g. merge) do it
themselves (except for a grace period with backward compatibility).

I also think it makes sense to not store the trust level in the same
struct member as the key/signature status.  While the presence of a
TRUST_ status code does imply that the signature is good (see the first
paragraph in the included snippet above), as far as I can tell, the
order of the status lines from GPG isn't well-defined; thus it would
seem plausible that the trust level could be overwritten with the
key/signature status if they were stored in the same member of the
signature_check structure.

This patch introduces a new configuration option: gpg.minTrustLevel.  It
consolidates trust-level verification to gpg-interface.c and adds a new
`trust_level` member to the signature_check structure.

Backward-compatibility is maintained by introducing a special case in
verify_merge_signature() such that if no user-configurable
gpg.minTrustLevel is set, then the old behavior of rejecting
TRUST_UNDEFINED and TRUST_NEVER is enforced.  If, on the other hand,
gpg.minTrustLevel is set, then that value overrides the old behavior.

Similarly, the %G? format specifier will continue show 'U' for
signatures made with a key that has a trust level of TRUST_UNDEFINED or
TRUST_NEVER, even though the 'U' character no longer exist in the
`result` member of the signature_check structure.  A new format
specifier, %GT, is also introduced for users that want to show all
possible trust levels for a signature.

Another approach would have been to simply drop the trust-level
requirement in verify_merge_signature().  This would also have made the
behavior consistent with other parts of git that perform signature
verification.  However, requiring a minimum trust level for signing keys
does seem to have a real-world use-case.  For example, the build system
used by the Qubes OS project currently parses the raw output from
verify-tag in order to assert a minimum trust level for keys used to
sign git tags [2].

[1] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/doc/DETAILS;h=bd00006e933ac56719b1edd2478ecd79273eae72;hb=refs/heads/master
[2] https://github.com/QubesOS/qubes-builder/blob/9674c1991deef45b1a1b1c71fddfab14ba50dccf/scripts/verify-git-tag#L43

Signed-off-by: Hans Jerry Illikainen &lt;hji@dyntopia.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
