|
3 | 3 |
|
4 | 4 | if defined?(OpenSSL) |
5 | 5 |
|
| 6 | +# OpenSSL::PKCS12.create calling the PKCS12_create() has the argument mac_iter |
| 7 | +# which uses a MAC key using PKCS12KDF which is not FIPS-approved. |
| 8 | +# OpenSSL::PKCS12.new with base64-encoded example calling PKCS12_parse() |
| 9 | +# verifies the MAC key using PKCS12KDF which is not FIPS-approved. |
| 10 | +# |
| 11 | +# PBE-SHA1-3DES uses PKCS12KDF which is not FIPS-approved according to the RFC |
| 12 | +# 7292 PKCS#12. |
| 13 | +# https://datatracker.ietf.org/doc/html/rfc7292#appendix-C |
| 14 | +# > The PBES1 encryption scheme defined in PKCS #5 provides a number of |
| 15 | +# > algorithm identifiers for deriving keys and IVs; here, we specify a |
| 16 | +# > few more, all of which use the procedure detailed in Appendices B.2 |
| 17 | +# > and B.3 to construct keys (and IVs, where needed). As is implied by |
| 18 | +# > their names, all of the object identifiers below use the hash |
| 19 | +# > function SHA-1. |
| 20 | +# > ... |
| 21 | +# > pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} |
| 22 | +# |
| 23 | +# Note that the pbeWithSHAAnd3-KeyTripleDES-CBC (pkcs12-pbeids 3) in the RFC |
| 24 | +# 7292 PKCS#12 means PBE-SHA1-3DES in OpenSSL. PKCS12KDF is used in PKCS#12. |
| 25 | +# https://oidref.com/1.2.840.113549.1.12.1.3 |
| 26 | +# https://github.com/openssl/openssl/blob/ed57d1e06dca28689190e00d9893e0fd7ecc67c1/crypto/objects/objects.txt#L385 |
| 27 | +return if OpenSSL.fips_mode |
| 28 | + |
6 | 29 | module OpenSSL |
7 | 30 | class TestPKCS12 < OpenSSL::TestCase |
8 | 31 | DEFAULT_PBE_PKEYS = "PBE-SHA1-3DES" |
@@ -210,8 +233,13 @@ def test_create_with_keytype |
210 | 233 | end |
211 | 234 |
|
212 | 235 | def test_new_with_no_keys |
213 | | - # generated with: |
214 | | - # openssl pkcs12 -certpbe PBE-SHA1-3DES -in <@mycert> -nokeys -export |
| 236 | + # Generated with the following steps: |
| 237 | + # Print the value of the @mycert such as by `puts @mycert.to_s` and |
| 238 | + # save the value as the file `mycert.pem`. |
| 239 | + # Run the following commands: |
| 240 | + # openssl pkcs12 -certpbe PBE-SHA1-3DES -in <(cat mycert.pem) \ |
| 241 | + # -nokeys -export -passout pass:abc123 -out /tmp/p12.out |
| 242 | + # base64 -w 60 /tmp/p12.out |
215 | 243 | str = <<~EOF.unpack1("m") |
216 | 244 | MIIGJAIBAzCCBeoGCSqGSIb3DQEHAaCCBdsEggXXMIIF0zCCBc8GCSqGSIb3 |
217 | 245 | DQEHBqCCBcAwggW8AgEAMIIFtQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQMw |
@@ -259,8 +287,10 @@ def test_new_with_no_keys |
259 | 287 | end |
260 | 288 |
|
261 | 289 | def test_new_with_no_certs |
262 | | - # generated with: |
263 | | - # openssl pkcs12 -inkey fixtures/openssl/pkey/rsa-1.pem -nocerts -export |
| 290 | + # Generated with the folowing steps: |
| 291 | + # openssl pkcs12 -inkey test/openssl/fixtures/pkey/rsa-1.pem \ |
| 292 | + # -nocerts -export -passout pass:abc123 -out /tmp/p12.out |
| 293 | + # base64 -w 60 /tmp/p12.out |
264 | 294 | str = <<~EOF.unpack1("m") |
265 | 295 | MIIJ7wIBAzCCCbUGCSqGSIb3DQEHAaCCCaYEggmiMIIJnjCCCZoGCSqGSIb3 |
266 | 296 | DQEHAaCCCYsEggmHMIIJgzCCCX8GCyqGSIb3DQEMCgECoIIJbjCCCWowHAYK |
|
0 commit comments