As the title says, I can't find any resources on which encryption algorithm is used in *.pfx/PKCS 12 certificates that are password protected.
All the specs for the PKCS#12 format are defined in RFC7292.
The short summary is that a
.p12 file (and I assume also Microsoft's older
PFX format, but I've never worked with them) is just a container format that specifies the structure of this file, but says nothing about what kind of data should go into it.
To use a very bad analogy, the spec for Microsoft Excel's
.xlsx format specifies the structure of an Excel save file, but does not tell you anything about what data or formulas it is allowed to contain; that is controlled by which version of Excel you're running.
If you were to pop open a
.p12 in a hex editor, you would find that one of the fields in the header is
AlgorithmIdentifier: _____ where the program that created the
.p12 records A) which encryption algorithm was used to encrypt the data, and B) which hash algorithm was use to turn the password into a key. As far as I know, there is no definitive list of what is allowed here; the program creating the
.p12 can use any
AlgorithmIdentifier it wants, including making up one.
For example, if I was writing software to read and write password-protected
.p12 files, I could set
AlgorithmIdentifier: AES256WithPBKDF2 and that would be fine. But I could also set
AlgorithmIdentifier: MikesCipherWithCatDoodles, and as long the software at the other end known what to do with that, it's still fine.
TL;DR: The PKCS#12 format only specifies the structure of the file, it does not list which algorithms are legal, so the actual encryption algorithm used will depend on which software was used to create the
If you want to know which algorithms are used to protect your
.p12 files, look up documentation on the software you are using to read / write them.
If you have a specific .pfx file that you wish to check, you can determine what encryption methods have been used using openssl:
openssl pkcs12 -info -in cert.pfx -noout
This might give you:
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048 Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048
This requires that you know the password of the .pfx file. If you don't know the password, you can still find the outermost encryption method using:
openssl pkcs12 -info -in cert.pfx -nomacver -noout -passin pass:unknown
This gives, for example:
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
This particular certificate file was generated by openssl with default parameters, and looks like it has:
- An outer encryption layer using 40-bit RC2 with SHA-1. The outer encryption layer contains the certificate.
- An inner encryption layer using 3DES with SHA-1. The inner encryption layer contains the private key.
I think this is insecure because an attacker can break the outermost encryption with an easy brute force (40-bit encryption plus RC2 has various vulnerabilities), and then use the same password on the inner encryption layer. However, this probably warrants additional investigation.
As mentioned before,
the PKCS#12 format only specifies the structure of the file
So it may be encrypted with any of the following algorithms, by the standard:
- 128 bit RC4 with SHA1
- 40 bit RC4 with SHA1
- 3 key 3DES with SHA1 (168 bit)
- 2 key 3DES with SHA1 (112 bit)
- 128 bit RC2 with SHA1
- 40 bit RC2 with SHA1
But, as Mike Ounsworth mentioned before, it can be any custom algorithm as well.