Keychain issue as of version 1.53 (follow up)

Yves Langisch <yves-iO7QwSo9/[email protected]> Mon, 26 Nov 2018 09:26:42 +0100
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
I’d like to follow up my thread [1] regarding an issue reading private keys from the Keychain.

Just tried to bump my BouncyCastle from 1.52 to 1.60 and I’m still hitting the following issue:

… 
Security.insertProviderAt(new BouncyCastleProvider(), 1)
...
store = KeyStore.getInstance("KeychainStore“, "Apple“); 
store.load(null, null) 
store.getKey("myClient", null) // password is not relevant to access Keychain 
… 

As of version 1.53 (1.52 works fine) I get the following exception: 

Caused by: javax.crypto.BadPaddingException: pad block corrupted
	at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$BufferedGenericBlockCipher.doFinal(Unknown Source)
	at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(Unknown Source)
	at javax.crypto.Cipher.doFinal(Cipher.java:2165)
	at apple.security.KeychainStore.engineGetKey(KeychainStore.java:215)
	... 26 more

Test key attached (pwd test).

[1] http://bouncy-castle.1462172.n4.nabble.com/Since-1-5-3-gt-org-bouncycastle-crypto-InvalidCipherTextException-pad-block-corrupted-td4658153.html

Thanks
Yves
myClient.p12 (application/x-pkcs12, 2.6 KB) - not displayed