Skip to content

Include signature type in GpgSig, to support SSH, x509, etc.#72

Open
Warbo wants to merge 1 commit intoipfs:masterfrom
Warbo:master
Open

Include signature type in GpgSig, to support SSH, x509, etc.#72
Warbo wants to merge 1 commit intoipfs:masterfrom
Warbo:master

Conversation

@Warbo
Copy link

@Warbo Warbo commented Mar 4, 2026

The existing commit parser/printer were hard-coded for PGP signatures, and stripped off their BEGIN/END lines. That threw an error for commits signed with other schemes like SSH or x509 ("expected first line of sig to be a single space or version"), and it loses information about what type of signature was present; which is bad for those inspecting the IPLD DAG, and it prevents the codec from correctly encoding commit objects.

This change generalises the signature parsing, to accept any -----BEGIN and -----END markers. It also includes those markers in the GpgSig value, so signed commits can roundtrip the codec, and the DAG will show what the signature type is.

Note that this changes the contents of the signature field exposed to IPLD! Here's what a PGP-signed commit used to look like:

$ ipfs dag get baf4bcfastgjlbc4cb4pwvazfmxrs6duxojydbsq | jq .
{
  "author": {
    "date": "1772632573",
    "email": "chriswarbo@gmail.com",
    "name": "Chris Warburton",
    "timezone": "+0000"
  },
  "committer": {
    "date": "1772632573",
    "email": "chriswarbo@gmail.com",
    "name": "Chris Warburton",
    "timezone": "+0000"
  },
  "encoding": null,
  "mergetag": [],
  "message": "Signed commit for testing\n",
  "other": [],
  "parents": [
    {
      "/": "baf4bcfafx5b5ehckbgrxs3w5vw4p3l6jnwchxri"
    }
  ],
  "signature": " \n iQEzBAABCgAdFiEEL4FPY3Lp/jQ0Jiq+seTexiNfLroFAmmoOf0ACgkQseTexiNf\n Lrp3QAf9Ee+oNHjHT9aKCRkUyaRn5ZUV9OxmxskD5hDOz7iLnZ84DIx4WNl7QT+x\n kw15VPyrryr16ES/J4HBb9aaMLDb9ns98vmrPUJ6YPKYWoD+0750GM/+RBe9HLsJ\n woTaADmn9ocSym53b32t6tTLvt2ow8J2UbfjijLqsEkqTH+E+T0qzxwlscZ6xWT8\n z40y88lbvIjuyxV8SirnoJtNra91QPuWKmkJCDE7OM4WGA/tU62Za5z4J8q4WZ9A\n +9K0poBMrEpsBRazx8XKNY1w/4v66vKEvY+q8kcH0zGKbX6uYnxsG/kr6bfLIQMU\n 7KdD0xv+QsGw5uhjhD7WLK8ziJ/x0w==\n =vyj/\n",
  "tree": {
    "/": "baf4bcfcthputu4uf5w5m66gfj4szgbazp5agqjy"
  }
}

With this change, the signature field will become:

  "signature": " -----BEGIN PGP SIGNATURE-----\n iQEzBAABCgAdFiEEL4FPY3Lp/jQ0Jiq+seTexiNfLroFAmmoOf0ACgkQseTexiNf\n Lrp3QAf9Ee+oNHjHT9aKCRkUyaRn5ZUV9OxmxskD5hDOz7iLnZ84DIx4WNl7QT+x\n kw15VPyrryr16ES/J4HBb9aaMLDb9ns98vmrPUJ6YPKYWoD+0750GM/+RBe9HLsJ\n woTaADmn9ocSym53b32t6tTLvt2ow8J2UbfjijLqsEkqTH+E+T0qzxwlscZ6xWT8\n z40y88lbvIjuyxV8SirnoJtNra91QPuWKmkJCDE7OM4WGA/tU62Za5z4J8q4WZ9A\n +9K0poBMrEpsBRazx8XKNY1w/4v66vKEvY+q8kcH0zGKbX6uYnxsG/kr6bfLIQMU\n 7KdD0xv+QsGw5uhjhD7WLK8ziJ/x0w==\n =vyj/\n -----END PGP SIGNATURE-----",

The existing commit parser/printer were hard-coded for PGP signatures, and
stripped off their BEGIN/END lines. That threw an error for commits signed with
other schemes like SSH or x509 ("expected first line of sig to be a single space
or version"), and it loses information about what type of signature was present;
which is bad for those inspecting the IPLD DAG, and it prevents the codec from
correctly encoding commit objects.

This change generalises the signature parsing, to accept any `-----BEGIN` and
`-----END` markers. It also includes those markers in the `GpgSig` value, so
signed commits can roundtrip the codec, and the DAG will show what the signature
type is.

Note that this changes the contents of the `signature` field exposed to IPLD!
Here's what a PGP-signed commit used to look like:

```
$ ipfs dag get baf4bcfastgjlbc4cb4pwvazfmxrs6duxojydbsq | jq .
{
  "author": {
    "date": "1772632573",
    "email": "chriswarbo@gmail.com",
    "name": "Chris Warburton",
    "timezone": "+0000"
  },
  "committer": {
    "date": "1772632573",
    "email": "chriswarbo@gmail.com",
    "name": "Chris Warburton",
    "timezone": "+0000"
  },
  "encoding": null,
  "mergetag": [],
  "message": "Signed commit for testing\n",
  "other": [],
  "parents": [
    {
      "/": "baf4bcfafx5b5ehckbgrxs3w5vw4p3l6jnwchxri"
    }
  ],
  "signature": " \n iQEzBAABCgAdFiEEL4FPY3Lp/jQ0Jiq+seTexiNfLroFAmmoOf0ACgkQseTexiNf\n Lrp3QAf9Ee+oNHjHT9aKCRkUyaRn5ZUV9OxmxskD5hDOz7iLnZ84DIx4WNl7QT+x\n kw15VPyrryr16ES/J4HBb9aaMLDb9ns98vmrPUJ6YPKYWoD+0750GM/+RBe9HLsJ\n woTaADmn9ocSym53b32t6tTLvt2ow8J2UbfjijLqsEkqTH+E+T0qzxwlscZ6xWT8\n z40y88lbvIjuyxV8SirnoJtNra91QPuWKmkJCDE7OM4WGA/tU62Za5z4J8q4WZ9A\n +9K0poBMrEpsBRazx8XKNY1w/4v66vKEvY+q8kcH0zGKbX6uYnxsG/kr6bfLIQMU\n 7KdD0xv+QsGw5uhjhD7WLK8ziJ/x0w==\n =vyj/\n",
  "tree": {
    "/": "baf4bcfcthputu4uf5w5m66gfj4szgbazp5agqjy"
  }
}
```

With this change, the `signature` field will become:

```
  "signature": " -----BEGIN PGP SIGNATURE-----\n iQEzBAABCgAdFiEEL4FPY3Lp/jQ0Jiq+seTexiNfLroFAmmoOf0ACgkQseTexiNf\n Lrp3QAf9Ee+oNHjHT9aKCRkUyaRn5ZUV9OxmxskD5hDOz7iLnZ84DIx4WNl7QT+x\n kw15VPyrryr16ES/J4HBb9aaMLDb9ns98vmrPUJ6YPKYWoD+0750GM/+RBe9HLsJ\n woTaADmn9ocSym53b32t6tTLvt2ow8J2UbfjijLqsEkqTH+E+T0qzxwlscZ6xWT8\n z40y88lbvIjuyxV8SirnoJtNra91QPuWKmkJCDE7OM4WGA/tU62Za5z4J8q4WZ9A\n +9K0poBMrEpsBRazx8XKNY1w/4v66vKEvY+q8kcH0zGKbX6uYnxsG/kr6bfLIQMU\n 7KdD0xv+QsGw5uhjhD7WLK8ziJ/x0w==\n =vyj/\n -----END PGP SIGNATURE-----",
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant