Closed taoliult closed 2 months ago
Also please include a fixes
link within the above commit and PR text to issue https://github.com/IBM/OpenJCEPlus/issues/100 such that this update gets linked to the issue being fixed.
I had a couple questions on this code.
Looking through the code I was concerned that
this.key
was not set to the same key value ask
and vice versa at various points in time. I couldn't exactly find a case / path where this would occur but it does seem a bit fragile keeping slightly different copies of the similar values.
@jasonkatonica Checked the XDHPrivateKeyImpl
from SunEC
codes. From JDK17 and after version, the raw k
object in XDHPrivateKeyImpl
is different with the key
object in PKCS8Key
(code links below). So, I am thinking, follow the similar way as SunEC
did. And also, run the TestAll
tests and all the 3926 tests passed.
This PR fixes the XDH Private Key and Public Key encoding formats issues.
According to the PKCS#8 Private-Key Specification, the new format privateKey is an octet string whose contents are the value of the private key. So, adding the octet string before the private key when passing the private key object to its parent class PKCS8Key key object for 17 and after version.
According to Sun old versions, 11 and before, the new XDH format is not supported. So, adding a DER "null" value on the OID sequence only for 11 and before versions.