Add Signature.IssuerKeyVersion field#310
Conversation
|
Thanks for the PR! However I wouldn't put exposing a new field in the category of "minor fixes" 😅 Also, if we set a new field when reading signature packets, we should also set it when creating them, such as here: Line 913 in 681b4e5 And, we should also take it into account when writing the signature here, so that it roundtrips correctly: go-crypto/openpgp/packet/signature.go Line 1395 in 681b4e5 And finally we could then remove the go-crypto/openpgp/packet/signature.go Line 1257 in 681b4e5 |
|
It would be nice if there was a "versioned fingerprint" type that we could use instead of having separate fields, but that would either require a breaking api change, or even more redundancy... |
|
Thanks! After looking at the code again I think |
I don't have that option, it's only available in personal branches, not org branches. If you want to PR into my branch, or just take my branch and mangle it, feel free :-) |
|
Scratch the above, I've given you write access to my fork. |
Signature.IssuerKeyVersion field
|
That also works, thanks! I've pushed the change, lmk if it still looks reasonable to you and then I'll merge. |
| PubKeyAlgo: ops.PubKeyAlgo, | ||
| IssuerKeyId: ops.KeyId, | ||
| Salt: ops.Salt, | ||
| IssuerKeyVersion: uint8(ops.Version), |
There was a problem hiding this comment.
Actually, re-reading this, this part is not correct because it assumes the signing key version matches the one-pass signature version, which is unfortunately not necessarily the case: https://www.rfc-editor.org/rfc/rfc9580.html#signed-message-versions
I'm somewhat wondering whether we need this field in SignatureCandidate or should drop it for now, since we don't have this information here. Do you have an opinion?
There was a problem hiding this comment.
Oof, good catch. I'm inclined to say that if we don't have the info, we should just drop it. Will need to remove the corresponding check further down... leave it with me.
There was a problem hiding this comment.
The implicit logic elsewhere is that if IssuerFingerprint is nil, IssuerKeyVersion is 0 - so maybe the most self-consistent (and future-proof) thing to do is set this to ops.Version IFF ops.Version is >= 6, and 0 otherwise?
There was a problem hiding this comment.
I've made the IFF change now, as it mirrors the equivalent logic in newSignatureCandidateFromSignature. I've also made a couple of driveby fixes to SignatureCandidate.validate().
There was a problem hiding this comment.
I'm not sure if it's guaranteed to be future proof because if we define key version 7 without defining one-pass signature version 7; we would have an issuer fingerprint without a known issuer key version (which arguably is not ideal and so we should have included an issuer key version field). Arguably we should then not do that but.. that's to be decided in the future 🙃
There was a problem hiding this comment.
Well, the definition of ops v6 assumes the fingerprint length is fixed, so we're already taking that risk... 😁 I think lockstep version bumps of key, sig and ops should be standard practice in future, even if there are no wire format changes in some of the packets (we did the same thing in v2->v3)
There was a problem hiding this comment.
Yeah, that's true. However, in the absence of a field on the wire, what are we actually checking with this field here?
We're setting the issuer key version to 6 if the OPS version is 6, and then later we're checking the OPS version against the signature version and the (assumed) OPS issuer key version against the signature's issuer key version. So, in a very roundabout way, we're checking that if the OPS version is 6, the signature version and issuer key version field must also be 6. However, we're still not actually checking the issuer key version field against the verification key version.
I think it would be more straightforward to just check the signature's issuer key version field against the verification key version, and also check that the signature version and signing key version correspond properly as per Table 27 (i.e. #309). Then we don't have to carry this extra field around based on various assumptions.
There was a problem hiding this comment.
Fair enough, I've reverted this (and also simplified some of the test logic further)
(closes #296)