【问题标题】:PBE-SHA1-3DES uses 168 bit triple DES?PBE-SHA1-3DES 使用 168 位三重 DES?
【发布时间】:2014-09-18 15:39:17
【问题描述】:

我正在使用以下命令使用 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 吗?

【问题讨论】:

    标签: encryption openssl


    【解决方案1】:

    答案似乎是肯定的,当我从 Java 读取文件时(另见我的另一个 question),我可以得到算法即:

    1.2.840.113549.1.12.1.3 from algParams.getAlgorithm()

    谷歌搜索得到:pbeWithSHAAnd3-KeyTripleDES-CBC

    另见:http://www.oid-info.com/get/1.2.840.113549.1.12.1.3

    这是一个 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());
    

    【讨论】:

      猜你喜欢
      • 2013-07-02
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 2012-03-30
      相关资源
      最近更新 更多