Re: OutofMemory with CMSEnvelopedData from fileInputStream
Massimiliano Ziccardi <[email protected]> Wed, 25 Sep 2019 18:46:14 +0200
| Newsgroups | gmane.comp.encryption.bouncy-castle.devel |
|---|---|
| Message-ID | <CAPwY8YAZfHB6743Boju-_Zv6+TGp4hmj2SYqfDZX7QRmrppzbg@mail.gmail.com> |
--000000000000c5ea4505936364f3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Is your LunaSA a network attached device or a PCI device? If it is a network one, bear in mind that the whole file will be sent to the HSM and back, thus slowing you down. If it is a PCI device, then definitely the HSM shouldn't be a bottleneck. Il giorno mer 25 set 2019 alle ore 18:14 Emiliano Latini < [email protected]> ha scritto: > I=E2=80=99ve solved the issue extracting directly the recipient : > > > > RecipientInformation recipient =3D recipients.get(new > JceKeyTransRecipientId((java.security.cert.X509Certificate)jcaProvider.ge= tKeystore().getCertificate(alias))); > > > > > > > > The problem is the operation is very slow even with a 130mb file. I=E2=80= =99ve > tried with the size of inputstream used for the CMSEnvelopedDataParser: > > > > CMSEnvelopedDataParser envelopedData =3D new > CMSEnvelopedDataParser(new BufferedInputStream(encEnvelopedData,parsBuf))= ; > > > > > > And with the buffer used in IOUtils.copylarge used for copying the > decripted file: > > > > IOUtils.copyLarge(decryptedStream, os, buf); > > > > > > Below some execution times: > > > > copytime:00:06:24.178 With parsebuf:8192 and copybuf:1024 > > copytime:00:06:46.668 With parsebuf:8192 and copybuf:8192 > > copytime:00:06:45.187 With parsebuf:16384 and copybuf:16384 > > copytime:00:06:39.961 With parsebuf:524288 and copybuf:524288 > > > > > > could be the HSM the bottleneck? > --000000000000c5ea4505936364f3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Is your LunaSA a network attached device or a PCI device?<= div>If it is a network one, bear in mind that the whole file will be sent t= o the HSM and back, thus slowing you down.</div><div><br></div><div>If it i= s a PCI device, then definitely the HSM shouldn't be a bottleneck.</div= ></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr"= >Il giorno mer 25 set 2019 alle ore 18:14 Emiliano Latini <<a href=3D"ma= ilto:[email protected]">[email protected]</a>> ha scritto:<br>= </div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b= order-left:1px solid rgb(204,204,204);padding-left:1ex"> <div lang=3D"IT"> <div class=3D"gmail-m_-6114767514269406480WordSection1"> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">I=E2=80=99ve solved the issue extracting= directly the recipient :<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue">RecipientIn= formation recipient =3D recipients.get(new JceKeyTransRecipientId((java.sec= urity.cert.X509Certificate)jcaProvider.getKeystore().getCertificate(alias))= );<u></u><u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">The problem is the operation is very slo= w even with a 130mb file. I=E2=80=99ve tried with the size of inputstream u= sed for the CMSEnvelopedDataParser:<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">=C2=A0 CMSEnvelopedDataParser=C2=A0=C2= =A0=C2=A0=C2=A0 envelopedData =3D new CMSEnvelopedDataParser(new BufferedIn= putStream(encEnvelopedData,parsBuf));<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">And with the buffer used in IOUtils.copy= large used for copying the decripted file:<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue">IOUtils.cop= yLarge(decryptedStream, os, buf);<u></u><u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">Below some execution times:<u></u><u></u= ></span></p> <p class=3D"MsoNormal" style=3D"text-indent:35.4pt"><span lang=3D"EN-US" st= yle=3D"font-size:10pt;font-family:Tahoma,sans-serif;color:blue"><u></u>=C2= =A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">copytime:00:06:24.178 With parsebuf:8192= and copybuf:1024<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">copytime:00:06:46.668 With parsebuf:8192= and copybuf:8192<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">copytime:00:06:45.187 With parsebuf:1638= 4 and copybuf:16384<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">copytime:00:06:39.961 With parsebuf:5242= 88 and copybuf:524288<u></u><u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10pt;font-fa= mily:Tahoma,sans-serif;color:blue">could be the HSM the bottleneck?<u></u><= u></u></span></p> </div> </div> </blockquote></div> --000000000000c5ea4505936364f3--