1

I am using following method to extract private key from secret key using 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);
}

However the last line of code runs very slow (aproximately 90 secs) on Android. Is there any better way on how to extract PGPPrivateKey from encrypted secret keys? Maybe I am doing some mistake when exporting secret key from linux but I dont think that this is the problem since I use simple command gpg --export-secret-keys > key.skr. Any ideas on what could be causing this problem?

Matt Ke
  • 3,599
  • 12
  • 30
  • 49
horin
  • 1,664
  • 6
  • 23
  • 52

1 Answers1

2

I noticed a similar slow performance at the PKCS8 private key decryption after upgrading the Android Gradle plugin from 2.2.1 to 3.3.0.

The slow performance is caused by Instant Run. When Instant Run is deactivated, the decryption needs ~1 second.

Matt Ke
  • 3,599
  • 12
  • 30
  • 49