SpongyCastle私钥提取非常慢

时间:2017-03-07 12:27:42

标签: android bouncycastle private-key pgp spongycastle

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

$cursor = $collection->findOne(
    [
        'username' => new \MongoDB\BSON\Regex(preg_quote($_POST['value']), 'i')
    ]
);
然而,最后一行代码在Android上运行速度非常慢(大约90秒)。如何从加密的密钥中提取PGPPrivateKey有更好的方法吗?也许我在从linux导出密钥时遇到了一些错误,但我不认为这是问题,因为我使用简单的命令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); } 。关于什么可能导致这个问题的任何想法?

1 个答案:

答案 0 :(得分:2)

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

性能下降是由Instant Run引起的。当取消激活“即时运行”时,解密需要约1秒钟。

相关问题