【问题标题】:SpongyCastle private key extraction very slowSpongyCastle 私钥提取非常慢
【发布时间】:2017-03-07 12:27:42
【问题描述】:

我正在使用以下方法使用 Spongy Castle 从密钥中提取私钥:

public static PGPPrivateKey findPrivateKey(PGPSecretKey pgpSecKey, char[] pass)
        throws PGPException {
    if (pgpSecKey == null) return null;
    
    PBESecretKeyDecryptor decryptor = new BcPBESecretKeyDecryptorBuilder(
            new BcPGPDigestCalculatorProvider()).build(pass);
    return pgpSecKey.extractPrivateKey(decryptor);
}

但最后一行代码在 Android 上运行速度非常慢(大约 90 秒)。关于如何从加密的密钥中提取 PGPPrivateKey 有没有更好的方法?也许我在从 linux 导出密钥时犯了一些错误,但我认为这不是问题,因为我使用了简单的命令gpg --export-secret-keys > key.skr。关于可能导致此问题的任何想法?

【问题讨论】:

    标签: android bouncycastle private-key pgp spongycastle


    【解决方案1】:

    在将 Android Gradle 插件从 2.2.1 升级到 3.3.0 后,我注意到 PKCS8 私钥解密的性能类似缓慢。

    性能缓慢是由 Instant Run 引起的。停用 Instant Run 后,解密需要约 1 秒。

    【讨论】:

      猜你喜欢
      • 2014-05-20
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多