Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Default Digest for Envelope Signing to SHA2-256 #44

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

manistal
Copy link

@manistal manistal commented Feb 12, 2025

Name of feature:

Default Digest Update

Pain or issue this feature alleviates:

SHA1 is no longer allowed for signature digests under FIPS 140-3 and FIPS 140-2 goes end of life in 2026. Most cryptographic backends no longer allow the use of SHA1 as a digest (for example Go doesn't even allow it, it requires the ENV Variable).

Allowing people to use and support SHA1 is fine, but it definitely should not be the default.

Why is this important to the project (if not answered above):

In the spirit of go - Defaults should be safe defaults.

Is there documentation on how to use this feature? If so, where?

No functional change

In what environments or workflows is this feature supported?

SCEP is my main familiarity with PKCS7, but any PKCS7 usage with a signed envelope

In what environments or workflows is this feature explicitly NOT supported (if any)?

Extremely legacy environments (i.e. pre-2003), however they can use the digest algorithm setter as documented.

Supporting links/other PRs/issues:

#27

Less configurable, but simpler approach than here:
https://github.com/smallstep/pkcs7/pull/29/files

💔Thank you!

Copy link

@nicopal nicopal left a comment

Choose a reason for hiding this comment

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

Some questions about the choice of default algorithms that need to be addressed.

DES must be deprecated.

defaults.go Outdated
// ContentEncryptionAlgorithm determines the algorithm used to encrypt the
// plaintext message. Change the value of this variable to change which
// algorithm is used in the Encrypt() function.
var ContentEncryptionAlgorithm = EncryptionAlgorithmAES256CBC
Copy link

Choose a reason for hiding this comment

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

The CBC mode is increasingly deprecated (e.g. dropped in TLS 1.3 and a number of other products). I suggest changing the default to EncryptionAlgorithmAES256GCM

Copy link
Member

@hslatman hslatman Feb 14, 2025

Choose a reason for hiding this comment

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

PKCS7 is often used in systems/environments that require compatibility with older systems. I've seen it fail with users trying to use SCEP with GCM, so defaulting to that (in this library, with existing systems relying on this default automatically) will likely be a good way to break things.

Using a different encryption algorithm is on the docket for v2.

defaults_fips.go Outdated
// ContentEncryptionAlgorithm determines the algorithm used to encrypt the
// plaintext message. Change the value of this variable to change which
// algorithm is used in the Encrypt() function.
var ContentEncryptionAlgorithm = EncryptionAlgorithmDESCBC
Copy link

Choose a reason for hiding this comment

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

DES is not secure under any mode of operation and should not be used. Consider alternatives such as AES256GCM

// plaintext message. Change the value of this variable to change which
// algorithm is used in the Encrypt() function.
var ContentEncryptionAlgorithm = EncryptionAlgorithmDESCBC

// ErrUnsupportedEncryptionAlgorithm is returned when attempting to encrypt
// content with an unsupported algorithm.
var ErrUnsupportedEncryptionAlgorithm = errors.New("pkcs7: cannot encrypt content: only DES-CBC, AES-CBC, and AES-GCM supported")
Copy link

Choose a reason for hiding this comment

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

In line with the comment above, DES-CBC must be deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

This is on the docket for v2.

defaults_fips.go Outdated
// SignatureAlgorithm determines the algorithm used to sign the message.
// Change the value of this variable to change which algorithm is used in
// the PKCS7 Envelope signing
var SignatureDigestAlgorithm = OIDDigestAlgorithmSHA1
Copy link

Choose a reason for hiding this comment

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

What is the reason to maintain SHA1 here? Consider using a different hashing algorithm, such as SHA256

Copy link
Member

@hslatman hslatman Feb 14, 2025

Choose a reason for hiding this comment

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

As discussed at length in #27, this is to maintain the existing behavior. A different default is considered for v2.

#29 has been merged, so you can now change the global default as a user of the package.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is the fips one. Yeah, that probably can be updated.

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.

3 participants