Closed gnarea closed 3 years ago
For some reason, probably the wrong one, the algorithm parameters were been set to NULL. I couldn't find any reason for this in RFC 5652 so I've fixed it so that OriginatorPublicKey always reflects everything in the SubjectPublicKeyInfo of the key being used. The fix for this will appear in 169b04, which will appear on https://www.bouncycastle.org/betas in a few hours.
When I generate a CMS
EnvelopedData
containing aKeyAgreeRecipientInfo
, the recipient info will have anOriginatorPublicKey
whose key'sAlgorithmIdentifier
is missing the curve name -- Which must be set as the algorithm parameters per RFC 5480.Consider this CMS EnvelopedData generated with the code below:
Its
OriginatorPublicKey
has itsAlgorithmIdentifier
's parameters set toNULL
, which is illegal per RFC 5480:Note that the public key that gets passed to
JceKeyAgreeRecipientInfoGenerator()
does have the curve name included (as expected), so there must be something along the way that drops the algorithm identifier parameters. But I can't find the place where that's happening. Here's what I get if I encode thesenderKeyPair.public
above:I need the
namedCurve
to be present because my JVM code communicates with a JavaScript peer, which uses the WebCrypto API. And the WebCrypto API requires the curve name to be passed when decoding a public key.