Encryption PBE-SHA1-3DES使用168位三重DES?

Encryption PBE-SHA1-3DES使用168位三重DES?,encryption,openssl,Encryption,Openssl,我使用以下命令使用OpenSSL加密私钥文件: $ openssl pkcs8 -topk8 -inform PEM -outform DER -in private_key.pem -out private_key.der -v1 PBE-SHA1-3DES 文档中指出选项-v1 PBE-SHA1-3DES将使用三重DES进行加密,但没有提到它使用的是哪个键控选项。我可以假设它使用168位三重DES吗?答案似乎是肯定的,当我从Java读取文件时,我可以得到算法,即: 1.2.840.113

我使用以下命令使用OpenSSL加密私钥文件:

$ openssl pkcs8 -topk8 -inform PEM -outform DER -in private_key.pem -out private_key.der  -v1 PBE-SHA1-3DES

文档中指出选项-v1 PBE-SHA1-3DES将使用三重DES进行加密,但没有提到它使用的是哪个键控选项。我可以假设它使用168位三重DES吗?

答案似乎是肯定的,当我从Java读取文件时,我可以得到算法,即:

1.2.840.113549.1.12.1.3来自algParams.getAlgorithm

通过谷歌搜索这一结果可以得出:

另见:

这是一个3key三重DES,需要168位

public static byte[] decryptPrivateKey(byte[] key) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
    PBEKeySpec passKeySpec = new PBEKeySpec("p".toCharArray());

    EncryptedPrivateKeyInfo encryptedKey = new EncryptedPrivateKeyInfo(key);
    System.out.println(encryptedKey.getAlgName());
    System.out.println("key length: " + key.length);
    AlgorithmParameters algParams = encryptedKey.getAlgParameters();
    System.out.println(algParams.getAlgorithm());