CMS typed Data from InputStream

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CMS typed Data from InputStream

cryptoSad
Hello everyone,
usually I get a  CMSTypedData from a CMSProcessableByteArray(ArrayOfBytes), i was wondering if i could get a msg directly from a buffered input stream avoiding to pass a huge byte array.
Is there a feasible way?

Thanks a lot


Reply | Threaded
Open this post in threaded view
|

Re: CMS typed Data from InputStream

Lothar Kimmeringer-4


Am 28.04.2020 um 18:14 schrieb Emiliano Latini:
> Hello everyone,
> usually I get a  CMSTypedData from a CMSProcessableByteArray(ArrayOfBytes),
> i was wondering if i could get a msg directly from a buffered input stream
> avoiding to pass a huge byte array.

When entering CMST and press CTRL-Space on Eclipse, it shows me
CMSTypedStream in org.bouncycastle.cms.

> Is there a feasible way?

Maybe CMSTypedStream ;-)


Cheers, Lothar

Reply | Threaded
Open this post in threaded view
|

R: [dev-crypto] CMS typed Data from InputStream

cryptoSad
Shame on me I'd have to check better :-D
I've gone a bit further and moved too cmsEnvelopedDataStreamGenerator.
So, now my code looks like this i post the full method maybe it can help others:

         final InputStream bufferedInputStream = new BufferedInputStream(dataToEncryptInputStream, CHUNK_SIZE);
                       
        CMSEnvelopedDataStreamGenerator cmsEnvelopedDataStreamGenerator = new CMSEnvelopedDataStreamGenerator();
        JceKeyTransRecipientInfoGenerator jceKeyTransRecipientInfoGenerator = new JceKeyTransRecipientInfoGenerator(encryptionCertificate);
        cmsEnvelopedDataStreamGenerator.addRecipientInfoGenerator(jceKeyTransRecipientInfoGenerator);
       
        OutputEncryptor outputEncryptor = new JceCMSContentEncryptorBuilder(ENCRYPTION_ALGORITHM).setProvider(getSecurityProvider()).build();
                       
        final OutputStream envelopedOutputStream = cmsEnvelopedDataStreamGenerator.open(encryptedDataOutputStream, outputEncryptor);
                       
        FileUtil.copyToOutputStream(bufferedInputStream, envelopedOutputStream);

        envelopedOutputStream.close();
        bufferedInputStream.close();
cheers


-----Messaggio originale-----
Da: Lothar Kimmeringer [mailto:[hidden email]]
Inviato: martedì 28 aprile 2020 20:15
A: [hidden email]
Oggetto: Re: [dev-crypto] CMS typed Data from InputStream



Am 28.04.2020 um 18:14 schrieb Emiliano Latini:
> Hello everyone,
> usually I get a  CMSTypedData from a CMSProcessableByteArray(ArrayOfBytes),
> i was wondering if i could get a msg directly from a buffered input stream
> avoiding to pass a huge byte array.

When entering CMST and press CTRL-Space on Eclipse, it shows me
CMSTypedStream in org.bouncycastle.cms.

> Is there a feasible way?

Maybe CMSTypedStream ;-)


Cheers, Lothar