Private keys are stored by default in a PKCS-8 encrypted format, protected by a password.
The default algorithm is "pbeWithSHAAnd3-KeyTripleDES-CBC" from PKCS-5.
The approximate ranking for the encryption schemes in increasing order of security is
pbeWithMD2AndDES-CBC" pbeWithMD5AndDES-CBC" pbeWithSHA1AndDES-CBC" pbeWithSHAAnd3-KeyTripleDES-CBC" (default)pkcs5PBES2" + "des-EDE3-CBC" pkcs5PBES2" + "AES128-CBC" pkcs5PBES2" + "AES192-CBC" pkcs5PBES2" + "AES256-CBC"
The less-secure algorithms pbeWithxxxAndDES-CBC using single DES are provided just in case you need compatibility with
an older system. Do not use them unless you have to.
The PBES2 scheme uses the PKCS-5 PBKDF2 key derivation function with
hmacWithSHA1 as the default psuedo-random function (PRF). To use a stronger message digest function
from the SHA-2 family in the PRF, add one of the following options
hmacWithSHA224hmacWithSHA256hmacWithSHA384hmacWithSHA512So, for example, to specify using PBES2 with AES256-CBC-Pad as the block cipher and HMAC-with-SHA256 as the PRF, use
Dim nOptions As Long nOptions = PKI_PBE_PBES2 + PKI_BC_AES256 + PKI_HASH_SHA512
Remember that the security of all these schemes is limited by the strength of the password used. Also, other systems may not necessarily support all the alternatives provided here.