Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-57669

issues with pbmac1 pkcs12 files using at least 65B passwords

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • rhel-10.0.beta
    • rhel-10.0.beta
    • nss
    • nss-3.101.0-7.el10
    • No
    • None
    • 1
    • sst_security_crypto
    • ssg_security
    • 29
    • 30
    • 2
    • False
    • Hide

      None

      Show
      None
    • No
    • Crypto24Q3
    • Hide

      AC1) NSS can export pkcs12 files with passwords of sizes 1..150 Bytes, both openssl and gnutls can read such files.

       

      AC2) NSS can read and import pkcs12 files with passwords of sizes 1..150 Bytes exported by openssl or gnutls.

      Show
      AC1) NSS can export pkcs12 files with passwords of sizes 1..150 Bytes, both openssl and gnutls can read such files.   AC2) NSS can read and import pkcs12 files with passwords of sizes 1..150 Bytes exported by openssl or gnutls.
    • Pass
    • Enabled
    • Automated
    • Unspecified Release Note Type - Unknown
    • All
    • None

      What were you trying to do that didn't work?

      There are two issues:

      1. NSS fails to import a pkcs12 file with pbmac1 using at least 65B password
      2. When NSS exports pkcs12 file with pbmac1 using at least 65B password it cannot be used by openssl and gnutls (but NSS is able to read it correctly).

      Please provide the package NVR for which bug is seen:

      nss-3.101.0-6.el10

      How reproducible:

      100%

      Steps to reproduce and actual resulst

      1. Initialize empty nssdb and create key pair.

      # mkdir nssdb
      
      # certutil -N -d sql:nssdb --empty-password
      
      # openssl req -x509 -newkey rsa -keyout localhost.key -out localhost.crt -nodes -batch -subj /CN=localhost

      2. Use openssl to generate pkcs12 file with pbmac1 and use 65B password (or more), try to read it by openssl (work) and gnutls (works) and nss (fails to read and import).

      # openssl pkcs12 -export -passout pass:$(printf 'x%.0s' {1..64}) -out localhost.p12 -inkey localhost.key -in localhost.crt -pbmac1_pbkdf2
      
      # certtool --p12-info --infile localhost.p12 --inder --password $(printf 'x%.0s' {1..64}) >/dev/null; echo $?
      0
      
      # openssl pkcs12 -in localhost.p12 -password pass:$(printf 'x%.0s' {1..64}) -noenc -info >/dev/null; echo $?
      MAC: PBMAC1 using PBKDF2, Iteration 2048
      Key length: 32, Salt length: 8
      PBKDF2 PRF: hmacWithSHA256
      PKCS7 Encrypted data: PBES2, PBKDF2, AES-256-CBC, Iteration 2048, PRF hmacWithSHA256
      Certificate bag
      PKCS7 Data
      Shrouded Keybag: PBES2, PBKDF2, AES-256-CBC, Iteration 2048, PRF hmacWithSHA256
      0
      
      # pk12util $(printf 'x%.0s' {1.-i localhost.p12 -d sql:nssdb -W .64})
      pk12util: PKCS12 decode not verified: SEC_ERROR_BAD_PASSWORD: The security password entered is incorrect.
      pk12util: PKCS12 decode validate bags failed: SEC_ERROR_INVALID_ARGS: security library: invalid arguments.
      
      #  pk12util -l localhost.p12 -W $(printf 'x%.0s' {1..64})
      pk12util: PKCS12 decode not verified: SEC_ERROR_BAD_PASSWORD: The security password entered is incorrect.
      pk12util: PKCS12 decode iterate bags failed: SEC_ERROR_INVALID_ARGS: security library: invalid arguments.

      3. Use openssl to generate pkcs12 file with pbmac1 and use 64B password (or less), import it by nss (works).

      # openssl pkcs12 -export -passout pass:$(printf 'x%.0s' {1..63}) -out localhost.p12 -inkey localhost.key -in localhost.crt -pbmac1_pbkdf2
      
      # pk12util -i localhost.p12 -d sql:nssdb -W $(printf 'x%.0s' {1..63})
      pk12util: no nickname for cert in PKCS12 file.
      pk12util: using nickname: localhost
      pk12util: PKCS12 IMPORT SUCCESSFUL

      4. Now export it using pbmac1 with password of 65B or more and try to read it by openssl (fails), gnutls (fails) or nss (works).

      # pk12util -o localhost.p12 -n localhost -d sql:nssdb -W $(printf 'x%.0s' {1..64}) -M "HMAC SHA-256"
      pk12util: PKCS12 EXPORT SUCCESSFUL
      
      # openssl pkcs12 -in localhost.p12 -password pass:$(printf 'x%.0s' {1..64}) -noenc -info >/dev/null; echo $?
      MAC: PBMAC1 using PBKDF2, Iteration 600000
      Key length: 32, Salt length: 16
      PBKDF2 PRF: hmacWithSHA256
      Mac verify error: invalid password?
      1
      
      # certtool --p12-info --infile localhost.p12 --inder --password $(printf 'x%.0s' {1..64}) >/dev/null; echo $?
      verify_mac: The Message Authentication Code verification failed.
      There were errors parsing the structure
      1
      
      #  pk12util -l localhost.p12 -W $(printf 'x%.0s' {1..64}) >/dev/null; echo $?
      0

      Expected results

      It should be possible to work fine with pbmac1 pkcs12 files with password of size 65B or more.

      Additional Info

      This only happens when pbmac1 is used. All works fined when it is not used.

            rrelyea@redhat.com Robert Relyea
            omoris Ondrej Moris
            Robert Relyea Robert Relyea
            Ondrej Moris Ondrej Moris
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: