git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/6] ssh signing: extend check_signature to accept payload metadata

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 23, 2021, 23:13 UTC
Message-ID
<xmqqfssr8hd5.fsf@gitster.g>
In-Reply-To
<20211022150949.1754477-2-fs@gigacodes.de>
Fabian Stelzer <fs@gigacodes.de> writes:
> Adds two new parameters to the check_signature api and passes them to the
"Add". "pass".
> internal verification ssh/gpg methods.
> A payload timestamp that will be used to verify signatures at the time of their
> objects creation if the signing method supports it (only ssh for now).
OK.
> And a signer strbuf containing ident information about the signer that
> we will need for implementing "Trust on first use" in a future patch
> series.
OK.

It would flow better in our "git log" stream if you explain upfront what problem you are trying to solve, before starting to give orders to the codebase to pass these pieces of information. Something like:

    In order to implement the "trust on the first use of a key"
    behaviour in later steps, allow callers to optionally pass the
    timestamp of the payload and the identity of the signer to
    check_signature().

It is unclear what "payload timestamp" is without actually seeing how it is used, so if you cannot explain it in easy terms in the log message for this step, it may be an indication that it is not a such good idea to add these parameters in a separate step.

Show 6 quoted lines
>  int check_signature(const char *payload, size_t plen,
> -		    const char *signature, size_t slen,
> -		    struct signature_check *sigc);
> +		    timestamp_t payload_timestamp,
> +		    struct strbuf *payload_signer, const char *signature,
> +		    size_t slen, struct signature_check *sigc);

Funny line wrapping. Just like payload and plen form a pair (hence they sit next to each other on the same line), signature and slen should sit next to each other on the same line.

What's the reason why payload-signer MUST come in a strbuf? A caller that has only ptr and len must invent a new strbuf that is otherwise unused to call this function because of that calling convention, which looks suboptimal.

If the function accepts <ptr, len>, just like <payload, plen> or <signature, slen> are taken by the function, such a caller can just call the function without having to have an extra instance of strbuf, while a caller that happens to already have a strbuf can pass <buf.buf, buf.len> as two separate parameters.

What's the driving principle that decided where in the list of parameters these two new ones are added?

I would explain one possible order I may find "logical" using the level of detail I expect from an answer to "what's the guiding principle?" as an example here:

 - we should move 'sigc' to the beginning, because the convention
   used by many of our API functions that have some central
   structure to work with is to have such a structure as the first
   thing in the list of parameters;
 - we should then append 'payload_timestamp', 'payload_signer', and
   'payload_signer_len' at the end, as the function is about
   "validate <signature, slen> is valid for <payload, plen> and
   leave the result in <sigc>", and anything we add is auxiliary
   input to the process, which are of less significance than the
   existing ones.

Another possible direction to go might be to add these auxiliary input to the process to the signature_check structure. Then this step can disappear, or just flip the order of the parameter to move sigc to the beginning, and then the later stemp that does the "first use" thing can add the necessary members to the structure *and* use the members to do its thing, which helps readers better understand what is going on.

One possible downside is that sigc has been mostly output-only structure, and turning it into a structure that also has some input members might make it too confusing. I dunno.

Thanks.
Previous: Fabian StelzerNext: Fabian Stelzer
Message 3 of 14 in “ssh signing: verify key lifetime”
  1. 0/6 ssh signing: verify key lifetimeFabian Stelzer, Oct 22, 2021
  2. 1/6 ssh signing: extend check_signature to accept payload metadataFabian Stelzer, Oct 22, 2021
  3. Junio C HamanoOct 23, 2021
  4. Fabian StelzerOct 25, 2021
  5. Junio C HamanoOct 25, 2021
  6. 3/6 ssh signing: verify-commit/check_signature with commit dateFabian Stelzer, Oct 22, 2021
  7. Ævar Arnfjörð BjarmasonOct 22, 2021
  8. Fabian StelzerOct 25, 2021
  9. 4/6 ssh signing: git log/check_signature with commit dateFabian Stelzer, Oct 22, 2021
  10. 5/6 ssh signing: verify-tag/check_signature with tag dateFabian Stelzer, Oct 22, 2021
  11. 6/6 ssh signing: fmt-merge-msg/check_signature with tag dateFabian Stelzer, Oct 22, 2021
  12. Ævar Arnfjörð BjarmasonOct 22, 2021
  13. Fabian StelzerOct 25, 2021
  14. 2/6 ssh signing: add key lifetime test prereqsFabian Stelzer, Oct 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.