Skip to content

Add lint to check encoding of SubjectPublicKeyInfo.AlgorithmIdentifier in S/MIME certificates#986

Closed
defacto64 wants to merge 44 commits intozmap:masterfrom
defacto64:smime_invalid_spki_algoid
Closed

Add lint to check encoding of SubjectPublicKeyInfo.AlgorithmIdentifier in S/MIME certificates#986
defacto64 wants to merge 44 commits intozmap:masterfrom
defacto64:smime_invalid_spki_algoid

Conversation

@defacto64
Copy link
Copy Markdown
Contributor

This lint checks that the DER encoding of the AlgorithmIdentifier (within SubjectPublicKeyInfo) is allowed, namely that it complies with section 7.1.3 of CABF SMIME BRs, also taking into account the allowance for PQC algorithms introduced on August 22 (see CABF SMIME BRs version 1.0.11).

defacto64 and others added 30 commits March 8, 2024 16:07
Added //nolint:all to comment block to avoid golangci-lint to complain about duplicate words in comment
Fine to me.

Co-authored-by: Christopher Henderson <[email protected]>
As per Chris Henderson's suggestion, to "improve readability".
As per Chris Henderson's suggestion.
Added CABFEV_Sec9_2_8_Date
Copy link
Copy Markdown
Member

@christopher-henderson christopher-henderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went down this whoooole rabbit hole about how we have another lint that checks for this, and how I can't find any reference to the Edward curves. and also where are you seeing ANY reference at all to the PQC algorithims...and...and....

Oh, this is the SMIME BRs 🫠

Thank you! I do have one request, though, to split the PQC algorithms into a separate lint as to avoid accidentally sunsetting them with the legacy algorithms.

}

// Let's now try with the PQC algorithms
if !c.NotBefore.Before(pqcEffectiveDate) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two efficacy dates within one lint hints to me that perhaps this should be two lints. It's a bit of a pain-in-the-butt, but would you mind splitting the PQC algorithms into a separate lint?

My reasoning is that if/when the legacy algorithms are marked Ineffective that we will cease to check for PCQ algorithms that were created after the sunsetting of the legacy algorithms.

It's tough to visualize, but this is what I mean,

  • PQC accidentally gets sunsetted along with the legacy algorithms.
          |------| 
legacy --> pqc --> ineffectiveLegacy ---> .....
  • As a separate lint, PQC keeps going after quantum computing and AGI makes this all a pointless as we are now either in a utopia or in the Matrix.
          |---------------------------------------------| 
legacy --> pqc --> ineffectiveLegacy ---> .....

Copy link
Copy Markdown
Contributor Author

@defacto64 defacto64 Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit puzzled. The logic behind this lint is to take the binary encoding (DER) of the SPKI algorithm and see if it appears in a list of allowed encodings (a white list). If I split the PQC algorithms into a separate lint, as you suggest, it's not clear to me how can I avoid to return an error — from this separate lint — if the algo's binary encoding doesn't appear in the relevant white list but nonetheless is legit (as in the case of a legacy algo). And similarly, in reverse, for the first lint, which is supposed to only handle legacy algos. In short, it's not clear to me how to do what you're asking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken a crack at what I am thinking in #989. The two lints in question are...

Legacy Algorithms Only

Effective: CABF/SMIME 1.0.0
Ineffective: CABF/SMIME 1.0.11

Checks for the presence of legacy algorithms only. PCQ algorithms were not yet allowed in this window, so PQC certs issued during this time should fail.

Legacy and PCQ Algorithms

Effective: CABF/SMIME 1.0.11

Allows for either legacy or PCQ algoids, but only for certs issued on-or-after 1.0.11.

@defacto64
Copy link
Copy Markdown
Contributor Author

OK. So, first, I've modified this lint to have the effective date of SMIME BR 1.0.11, which introduced the PQC algorithms, and thus removed the additional check for the certificate issuance date I'd previously added. I've also trimmed down the test data a bit, skipping some unnecessary tests, and at this point I think this lint meets your expectations for the current stage (post-SMIME BR 1.0.11 release). If you're okay with it, I'll later submit a PR for a second lint called "... _legacy" that will only address the algos that were allowed in the previous stage.

@defacto64
Copy link
Copy Markdown
Contributor Author

@christopher-henderson While I was updating this PR, I didn't realize you'd decided to take the initiative and edit my lint yourself (and then submit a separate PR). It's all the same to me; go ahead as you prefer. If you like, I'll close this PR.

@christopher-henderson
Copy link
Copy Markdown
Member

Thank you @defacto64! I've merged #989 so I'll close this one out.

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.

2 participants