2017-03-07 38 views
0

我使用下面的方法來提取使用海綿城堡從密鑰私鑰:SpongyCastle私鑰提取很慢

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); 
} 

然而最後一行代碼的運行速度非常慢(aproximately 90秒)在Android上。有沒有更好的方法來從加密的密鑰中提取PGPPrivateKey?也許我在從linux中導出密鑰時犯了一些錯誤,但我不認爲這是問題,因爲我使用簡單的命令gpg --export-secret-keys > key.skr。任何想法都可能導致這個問題?

回答

2

我注意到在將Android Gradle插件從2.2.1升級到3.3.0後,PKCS8私鑰解密的性能相似。

性能下降是由即時運行造成的。當即時運行停用時,解密需要約1秒。