diff options
| author | tb <> | 2025-05-24 02:35:25 +0000 |
|---|---|---|
| committer | tb <> | 2025-05-24 02:35:25 +0000 |
| commit | 106520eba95dd427fceddb90d7aade730c8b0d41 (patch) | |
| tree | 20d6fd3b1879ece6d8ea91a1c8ffb7259eb78f37 /src | |
| parent | c9703fda5ea94cf39d4ec7e101625abdbaefe979 (diff) | |
| download | openbsd-106520eba95dd427fceddb90d7aade730c8b0d41.tar.gz openbsd-106520eba95dd427fceddb90d7aade730c8b0d41.tar.bz2 openbsd-106520eba95dd427fceddb90d7aade730c8b0d41.zip | |
Switch default to PBES2 for openssl pkcs8 -topk8
We currently use the glorious default of NID_pbeWithMD5AndDES_CBC which
we inherited from OpenSSL. This could have been worse - there is also
NID_pbeWithMD2AndDES_CBC...
The way this diff works is that the undocumented PKCS8_encrypt() API
uses the PKCS#5v2 code path when it's passed a NID of -1 and requires
a cipher to succeed, otherwise it uses the PKCS#5v1.5 path. So pass in
a sensible cipher, namely AES-CBC-256, and let layers of muppetry
cascade to doing something resembling the right thing.
This still uses the default of hmacWithSHA1 and a somewhat short salt,
which will be improved in a subsequent commit.
https://github.com/pyca/cryptography/issues/12949
https://github.com/libressl/portable/issues/1168
ok kenjiro joshua jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/pkcs8.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/usr.bin/openssl/pkcs8.c b/src/usr.bin/openssl/pkcs8.c index 10fad7aed1..5d7c52f865 100644 --- a/src/usr.bin/openssl/pkcs8.c +++ b/src/usr.bin/openssl/pkcs8.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pkcs8.c,v 1.18 2025/01/02 12:31:44 tb Exp $ */ | 1 | /* $OpenBSD: pkcs8.c,v 1.19 2025/05/24 02:35:25 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 1999-2004. | 3 | * project 1999-2004. |
| 4 | */ | 4 | */ |
| @@ -224,8 +224,8 @@ pkcs8_main(int argc, char **argv) | |||
| 224 | BIO_printf(bio_err, "Error getting passwords\n"); | 224 | BIO_printf(bio_err, "Error getting passwords\n"); |
| 225 | goto end; | 225 | goto end; |
| 226 | } | 226 | } |
| 227 | if ((cfg.pbe_nid == -1) && !cfg.cipher) | 227 | if (cfg.pbe_nid == -1 && cfg.cipher == NULL) |
| 228 | cfg.pbe_nid = NID_pbeWithMD5AndDES_CBC; | 228 | cfg.cipher = EVP_aes_256_cbc(); |
| 229 | 229 | ||
| 230 | if (cfg.infile) { | 230 | if (cfg.infile) { |
| 231 | if (!(in = BIO_new_file(cfg.infile, "rb"))) { | 231 | if (!(in = BIO_new_file(cfg.infile, "rb"))) { |
