As far as I understand this whole if-mess in createPemObject the Exception throw should only happen if the passed Object is instanceof org.bouncycastle.asn1.pkcs.PrivateKeyInfo - wich com.sun.crypto.provider.DHPrivateKey obviously isn't. Am I don't getting the right path and get trolled by indentation?
So, I re-indented the code with the missing parenthesis after each else - this is what I came up with:
Is this the real truth table - or am I mis-understanding "else if" and this should better be placed in beginners forum?
As far as I understand blocks with optional parenthesis:
As the last statement line is also another if - it cascades down to:
Am I right with this - or is it here why I think the line "unknown object passed - can't encode." should be thrown? Or did someone at BouncyCastle missed some parenthesis somewhere so the flow is different from what the dev might thought it would be?
Also: THAT'S the reason why one should never omit parenthesis even if it's allowed.
I just don't understand how the flow ends in "Cannot identify private key" when, as far as I understand it, to end up there Object needs to be instanceof PrivateKeyInfo.
I also had it run through de-compiler - here's the output:
So, to get to the Exception "Cannot identify private key" Object indeed has to be instanceof PrivateKeyInfo - wich com.sun.crypto.provider.DHPrivateKey neither is nor could - I'm not seeing it ...