Skip to content

pkcs8: getrandom feature#2311

Merged
tarcieri merged 1 commit intomasterfrom
pkcs8/getrandom-feature
Apr 27, 2026
Merged

pkcs8: getrandom feature#2311
tarcieri merged 1 commit intomasterfrom
pkcs8/getrandom-feature

Conversation

@tarcieri
Copy link
Copy Markdown
Member

This crate needs randomness for PKCS#5 salt/IVs whenever encrypting a plaintext private key.

This renames the encryption methods that take an explict RNG from encrypt => encrypt_with_rng e.g. PrivateKeyInfo::encrypt_with_rng and adds a new e.g. PrivateKeyInfo::encrypt method which uses getrandom to obtain randomness.

The trait methods EncodePrivateKey::to_pkcs8_encrypted_der and ::to_pkcs8_encrypted_pem have likewise been updated to require the getrandom feature.

This crate needs randomness for PKCS#5 salt/IVs whenever encrypting a
plaintext private key.

This renames the encryption methods that take an explict RNG from
`encrypt` => `encrypt_with_rng` e.g. `PrivateKeyInfo::encrypt_with_rng`
and adds a new e.g. `PrivateKeyInfo::encrypt` method which uses
`getrandom` to obtain randomness.

The trait methods `EncodePrivateKey::to_pkcs8_encrypted_der` and
`::to_pkcs8_encrypted_pem` have likewise been updated to require the
`getrandom` feature.
@tarcieri tarcieri force-pushed the pkcs8/getrandom-feature branch from 0d01b9f to 750be25 Compare April 27, 2026 14:52
@tarcieri tarcieri merged commit 7d69c45 into master Apr 27, 2026
191 of 196 checks passed
@tarcieri tarcieri deleted the pkcs8/getrandom-feature branch April 27, 2026 15:20
@tarcieri tarcieri mentioned this pull request Apr 27, 2026
tarcieri added a commit that referenced this pull request Apr 27, 2026
## Added
- Custom error types support to the Decode and DecodeValue traits (#1055)
- PrivateKeyInfoRef / PrivateKeyInfoOwned type aliases (#1483)
- Implement core::error::Error trait for Error (#2302)
- Implement DecodePrivateKey/EncodePrivateKey traits for PrivateKeyInfoOwned (#2306)
- KeyError enum (#2305)
- ctutils feature (#2308)
- getrandom feature (#2311)

## Changed
- Eagerly decode PEM labels for better error messages (#1163)
- Use pbes2::Parameters::generate_recommended (#1430, #2296)
- Make PrivateKeyInfo generic around its backing storage (#1483)
- Bump rand_core to 0.9 (#1658)
- Use 2024 edition; bump MSRV to 1.85 (#1670)
- Bump rand_core to v0.10 (#2198)
- Error::KeyMalformed now wraps an inner KeyError for providing more detail (#2305)
- Use TryCryptoRng instead of CryptoRng (#2309)

## Removed
- subtle feature (#2308)
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