The object has to hold on to the symmetric session key which is output
at the end of the generation cycle. Re-using like this will result in
one of the session keys getting lost.
On 28/01/18 00:09, Maria Sigal wrote:
> I use the same key when i encrypt several times but it looks like that i
> need to create
> JceKeyTransRecipientInfoGenerator infoGenerator = new
> recipient = infoGenerator;
> as the number of times i encapsulate EnvelopedData , otherwise something
> gets wrongs with the key , with the encryption and when i decrypt the
> message i get an error
> java.lang.IllegalArgumentException: failed to construct sequence from
> byte: DER length more than 4 bytes: 14.
> Why doesn't it work to pass each time the same
> JceKeyTransRecipientInfoGenerator object to the
> CMSEnvelopedDataStreamGenerate when creating encapsulated EnvelopedData if
> the certificate is the same .
> Sent from: http://bouncy-castle.1462172.n4.nabble.com/Bouncy-Castle-Dev-f1462173.html >