Skip to content

Align CMS digest and signing algos with empty and NULL parameters - #315

Open
ericb-apple wants to merge 1 commit into
apple:mainfrom
ericb-apple:166139496_Match_CMS_algos_without_params
Open

ericb-apple wants to merge 1 commit into
apple:mainfrom
ericb-apple:166139496_Match_CMS_algos_without_params

Conversation

@ericb-apple

Copy link
Copy Markdown

Motivation

  • PKCS1v1.5 implementations treat having no parameters and NULL parameters as equivalent
  • Omit SHA2 optional parameters from AlgorithmIdentifiers (per RFC 5754 § 2) while accepting those with NULL parameters

X509/CryptographicMessageSyntax/CMSOperations.swift attempts direct equality check between signature algorithm and signer digest algorithm including the parameters, and failing in situations where:

  • ASN1Null and Swift nil parameters being considered not equivalent
  • SHA2 with parameters and ASN1Null or Swift nil parameters being considered not equivalent

Modifications

When verifying whether digest and signing algorithms match in CMS signature verification:

  • Treat ASN1Null and Swift nil parameters as equivalent
  • Correct internal representation of the signer digest algorithm to have Swift nil parameters for the equality check for SHA2

Result

CMS signature successfully verifies for PKCS1v1.5 payloads and usage of SHA2 parameters with mixture of empty, optional, and NULL parameters.

Motivation:

* PKCS1v1.5 implementations treat having no parameters and NULL parameters as equivalent
* Omit SHA2 optional parameters from AlgorithmIdentifiers (per RFC 5754 § 2) while accepting those with NULL parameters

X509/CryptographicMessageSyntax/CMSOperations.swift attempts direct equality check between signature algorithm and signer digest algorithm including the parameters, and failing in situations where:

* ASN1Null and Swift nil parameters being considered not equivalent
* SHA2 with parameters and ASN1Null or Swift nil parameters being considered not equivalent

Modifications:

When verifying whether digest and signing algorithms match in CMS signature verification:

* Treat ASN1Null and Swift nil parameters as equivalent
* Correct internal representation of the signer digest algorithm to have Swift nil parameters for the equality check for SHA2

Result:

CMS signature successfully verifies for PKCS1v1.5 payloads and usage of SHA2 parameters with mixture of empty, optional, and NULL parameters.
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