[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    RE: [dev-crypto] Issue: Unencrypted files created and left in /tmp while using SMIMEEnvelopedGenerat
From:       Serguei Izvoztchikov <serguei.izvoztchikov () ethoca ! com>
Date:       2014-01-28 22:28:15
Message-ID: F9910CCC550A7C43B9119CD3B03014D62F39B5A21D () AUSP01VMBX24 ! collaborationhost ! net
[Download RAW message or body]

David,

I have updated to latest 1.50 version. It does not change our situation. Files are \
still there with unencrypted content. Could it be issue in some of JDK's smime/jce \
related classes ?

________________________________
From: David Hook [mailto:dgh@cryptoworkshop.com]
Sent: January-27-14 6:20 PM
To: Serguei Izvoztchikov
Subject: Re: [dev-crypto] Issue: Unencrypted files created and left in /tmp while \
using SMIMEEnvelopedGeneratior


No SMIMESignedParser wouldn't be used for that, you'd need to be calling it \
explicitly.

I just noticed you said you were using 1.47. Would you try using the 1.50 release and \
see if you still have the problem? It's possible 1.47 made wider use of backing store \
(I thought we'd managed to sort this out quite a while ago, but then I guess 1.47 was \
quite a while ago...)

If you can send me the smallest functioning program you can write that causes it I \
might be able to suggest something for 1.47. I would strongly recommend moving to \
1.50 though.

Regards,

David

On 28/01/14 10:09, Serguei Izvoztchikov wrote:
I'm encrypting data. Is SMIMESignedParser used for that ? It seems to me that \
SMIMESignedParser would be used for verification of signed messages on decryption \
stage. If SMIMESignedParser is used for encryption as well, how can I pass my own \
instance to SMIMEEnvelopedGenerator ? Or would it needed to be passed to \
JceKeyTransRecipientInfoGenerator somehow ?

________________________________
From: David Hook [mailto:dgh@autochthonous.org]
Sent: January-27-14 5:55 PM
To: dev-crypto@bouncycastle.org<mailto:dev-crypto@bouncycastle.org>
Subject: Re: [dev-crypto] Issue: Unencrypted files created and left in /tmp while \
using SMIMEEnvelopedGeneratior


Okay, I'm pretty sure these are connected with the use of SMIMESignedParser. You'll \
need to use the constructor that allows  you to provide your own backing store.

Regards,

David

On 28/01/14 09:32, Serguei Izvoztchikov wrote:
Here is result from "ls" command

/tmp/bcMail9047992606681311688.mime
/tmp/bcMail9055372466100021498.mime
/tmp/bcMail9107283754375145903.mime
/tmp/bcMail9112762128458784123.mime
/tmp/bcMail9120469598884354191.mime

________________________________
From: David Hook [mailto:dgh@autochthonous.org]
Sent: January-27-14 5:14 PM
To: Serguei Izvoztchikov; \
                dev-crypto@bouncycastle.org<mailto:dev-crypto@bouncycastle.org>
Subject: Re: [dev-crypto] Issue: Unencrypted files created and left in /tmp while \
using SMIMEEnvelopedGeneratior


What are the files called? The SMIMESignedParser does need a backing file, but there \
is a constructor that allows you to pass in a defined one rather than letting the API \
do it for you. I don't think anything else uses them though (mind you it's been a \
while since I looked at it...) Can you tell me more about what your are seeing?

Regards,

David

On 28/01/14 08:42, Serguei Izvoztchikov wrote:
I have files left over in /tmp directory when I do stream encryption using \
SMIMEEnvelopedGeneratior. How can I prevent files with unencrypted content from being \
created and left over in /tmp directory ? If it is not possible, can I at least \
change location of those files to be a different directory ?

I'm using 1.47 version of Bouncy Castle library.

Here is my code snippet

                    SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();

                    gen.addRecipientInfoGenerator(new \
JceKeyTransRecipientInfoGenerator(ourCertificate).setProvider("BC"));  if \
                (otherRecipientsCertificate != null) {
                              for(int i=0; i < otherRecipientsCertificate.size(); \
i++)  gen.addRecipientInfoGenerator(new \
JceKeyTransRecipientInfoGenerator((X509Certificate)otherRecipientsCertificate.get(i)).setProvider("BC"));
  }

                    MimeBodyPart msg = new MimeBodyPart();

                    msg.setDataHandler(new DataHandler(new \
                BinaryBatchDataSource(in)));
                    msg.setHeader("Content-Type", "application/octet-stream");
                    msg.setHeader("Content-Transfer-Encoding", "binary");

                    MimeBodyPart mp = gen.generate(msg, new \
JceCMSContentEncryptorBuilder(CMSAlgorithm.AES256_CBC, \
256).setProvider("BC").build());

                    Properties props = System.getProperties();
                    Session session = Session.getDefaultInstance(props, null);

                    MimeMessage body = new MimeMessage(session);
                    body.setContent(mp.getContent(), mp.getContentType());
                    body.saveChanges();

                    body.writeTo(os);


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:x="urn:schemas-microsoft-com:office:excel" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceType"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PlaceName"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Courier New \;color\:black";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Times New\000D\000A";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Times New\000D\000A                  Ro";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Courier New \;color\:\#2A00FF";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Courier\000D\000A Ne";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Courier New \;color\:\#0000C0";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Times New\000D\000A \;color\:windowtext";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Times New\000D\000A Ro";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Courier New\000D\000A";
	panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";
	color:black;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:Arial;
	color:windowtext;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle19
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-CA link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>David,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I have updated to latest 1.50 version. It
does not change our situation. Files are still there with unencrypted<br>
content. Could it be issue in some of JDK&#8217;s smime/jce related classes \
?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span lang=EN-US style='font-size:12.0pt;
color:windowtext'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
 size=2 color=black face=Tahoma><span lang=EN-US style='font-size:10.0pt;
font-family:Tahoma;color:windowtext'> David Hook
[mailto:dgh@cryptoworkshop.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> January-27-14 6:20 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Serguei Izvoztchikov<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [dev-crypto] Issue:
Unencrypted files created and left in /tmp while using \
SMIMEEnvelopedGeneratior</span></font><font color=black><span lang=EN-US \
style='color:windowtext'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><br>
No SMIMESignedParser wouldn't be used for that, you'd need to be calling it
explicitly.<br>
<br>
I just noticed you said you were using 1.47. Would you try using the 1.50
release and see if you still have the problem? It's possible 1.47 made wider
use of backing store (I thought we'd managed to sort this out quite a while
ago, but then I guess 1.47 was quite a while ago...)<br>
<br>
If you can send me the smallest functioning program you can write that causes
it I might be able to suggest something for 1.47. I would strongly recommend
moving to 1.50 though.<br>
<br>
Regards,<br>
<br>
David<br>
<br>
On 28/01/14 10:09, Serguei Izvoztchikov wrote:<o:p></o:p></span></font></p>

</div>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'
cite="mid:F9910CCC550A7C43B9119CD3B03014D62F39B59D72@AUSP01VMBX24.collaborationhost.net"
 type=cite><u1:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceType"><u1:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceName"><u1:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><!--[if gte mso 9]><xml>
    <u1:shapedefaults u2:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
    <u1:shapelayout u3:ext="edit">
     <u1:idmap u3:ext="edit" data="1"/>
    </u1:shapelayout>
</xml><![endif]-->I&#8217;m encrypting data. Is SMIMESignedParser used for that ? It
seems to me that SMIMESignedParser<br>
would be used for verification of signed messages on decryption stage. If
SMIMESignedParser is<br>
used for encryption as well, how can I pass my own instance to
SMIMEEnvelopedGenerator ? Or<br>
would it needed to be passed to JceKeyTransRecipientInfoGenerator somehow \
?<u1:p></u1:p></span></font><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New&#13;&#10;"><span lang=EN-US style='font-size:12.0pt;
font-family:"Times New\000D\000A";color:windowtext'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
 size=2 color=black face=Tahoma><span lang=EN-US style='font-size:10.0pt;
font-family:Tahoma;color:windowtext'> David Hook [<a
href="mailto:dgh@autochthonous.org">mailto:dgh@autochthonous.org</a>] <br>
<b><span style='font-weight:bold'>Sent:</span></b> January-27-14 5:55 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <a
href="mailto:dev-crypto@bouncycastle.org">dev-crypto@bouncycastle.org</a><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [dev-crypto] Issue: \
Unencrypted files created and left in /tmp while using \
SMIMEEnvelopedGeneratior</span></font><o:p></o:p></p>

</div>

<u1:p></u1:p>

<p class=MsoNormal><font size=3 color=black
face="Times New&#13;&#10;                  Ro"><span style='font-size:12.0pt;
font-family:"Times New\000D\000A                  \
Ro"'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

<div>

<p class=MsoNormal><font size=3 color=black face="Times New&#13;&#10;"><span
style='font-size:12.0pt;font-family:"Times New\000D\000A"'><br>
Okay, I'm pretty sure these are connected with the use of SMIMESignedParser.
You'll need to use the constructor that allows&nbsp; you to provide your own
backing store.<br>
<br>
Regards,<br>
<br>
David<br>
<br>
On 28/01/14 09:32, Serguei Izvoztchikov \
wrote:<u1:p></u1:p></span></font><o:p></o:p></p>

</div>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'
cite="mid:F9910CCC550A7C43B9119CD3B03014D62F39B59D41@AUSP01VMBX24.collaborationhost.net"
 type=cite><u4:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceType"><u4:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceName"><u4:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><!--[if gte mso 9]><xml>
       <u4:shapedefaults u2:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
       <u4:shapelayout u3:ext="edit">
        <u4:idmap u3:ext="edit" data="1"/>
       </u4:shapelayout>
</xml><![endif]-->Here is result from &#8220;ls&#8221; \
command<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u4:p>&nbsp;</u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>/tmp/bcMail9047992606681311688.mime<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>/tmp/bcMail9055372466100021498.mime<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>/tmp/bcMail9107283754375145903.mime<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>/tmp/bcMail9112762128458784123.mime<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>/tmp/bcMail9120469598884354191.mime<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u4:p>&nbsp;</u4:p></span></font><u1:p></u1:p><o:p></o:p></p>


<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New&#13;&#10; ;color:windowtext"><span lang=EN-US
style='font-size:12.0pt;font-family:"Times New\000D\000A \;color\:windowtext"'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
 size=2 color=black face=Tahoma><span lang=EN-US style='font-size:10.0pt;
font-family:Tahoma;color:windowtext'> David Hook [<a
href="mailto:dgh@autochthonous.org" \
moz-do-not-send=true>mailto:dgh@autochthonous.org</a>] <br>
<b><span style='font-weight:bold'>Sent:</span></b> January-27-14 5:14 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Serguei Izvoztchikov; <a
href="mailto:dev-crypto@bouncycastle.org" \
moz-do-not-send=true>dev-crypto@bouncycastle.org</a><br> <b><span \
style='font-weight:bold'>Subject:</span></b> Re: [dev-crypto] Issue: Unencrypted \
files created and left in /tmp while using \
SMIMEEnvelopedGeneratior</span></font><u1:p></u1:p><o:p></o:p></p>

</div>

<u4:p></u4:p>

<p class=MsoNormal><font size=3 color=black face="Times New&#13;&#10; Ro"><span
style='font-size:12.0pt;font-family:"Times New\000D\000A \
Ro"'><u4:p>&nbsp;</u4:p></span></font><u1:p></u1:p><o:p></o:p></p>

<div>

<p class=MsoNormal><font size=3 color=black face="Times New&#13;&#10;"><span
style='font-size:12.0pt;font-family:"Times New\000D\000A"'><br>
What are the files called? The SMIMESignedParser does need a backing file, but
there is a constructor that allows you to pass in a defined one rather than
letting the API do it for you. I don't think anything else uses them though
(mind you it's been a while since I looked at it...) Can you tell me more about
what your are seeing?<br>
<br>
Regards,<br>
<br>
David<br>
<br>
On 28/01/14 08:42, Serguei Izvoztchikov \
wrote:<u4:p></u4:p></span></font><u1:p></u1:p><o:p></o:p></p>

</div>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'
cite="mid:F9910CCC550A7C43B9119CD3B03014D62F39B59CE7@AUSP01VMBX24.collaborationhost.net"
 type=cite><u5:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceType"><u5:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" \
name="PlaceName"><u5:smarttagtype \
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I have files left over in /tmp directory when I do
stream encryption using \
SMIMEEnvelopedGeneratior.<u5:p></u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>How can I prevent files with unencrypted content from
being created and left over in /tmp directory \
?<u5:p></u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>If it is not possible, can I at least change location
of those files to be a different directory \
?<u5:p></u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>I&#8217;m using 1.47 version of <st1:place \
u2:st="on"><st1:placename u2:st="on"><st1:place u6:st="on"><st1:placename \
u6:st="on"><st1:place u7:st="on"><st1:placename u7:st="on"><st1:place \
w:st="on"><st1:PlaceName \
w:st="on">Bouncy</st1:placename></st1:place></st1:placename></st1:place></st1:placename></st1:PlaceName>
  <st1:placetype u2:st="on"><st1:placetype u6:st="on"><st1:placetype \
u8:st="on"><st1:PlaceType  \
w:st="on">Castle</st1:placetype></st1:placetype></st1:placetype></st1:place></st1:PlaceType></st1:place>
 library.<u5:p></u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Here is my code \
snippet<u5:p></u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SMIMEEnvelopedGenerator gen = \
</span></font><b><font size=2 color="#7f0055" face="Courier New"><span \
style='font-size:10.0pt; font-family:"Courier \
New";color:#7F0055;font-weight:bold'>new</span></font></b><font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'> \
SMIMEEnvelopedGenerator();</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
gen.addRecipientInfoGenerator(</span></font><b><font size=2 color="#7f0055" \
face="Courier New"><span style='font-size:10.0pt; font-family:"Courier \
New";color:#7F0055;font-weight:bold'>new</span></font></b><font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'> \
JceKeyTransRecipientInfoGenerator(</span></font><font size=2 color="#0000c0" \
face="Courier New ;color:#0000C0"><span style='#0000C0'><span style='font-size: \
10.0pt;font-family:"Courier New \
\;color\:\#0000C0";color:#0000C0'>ourCertificate</span></span></font><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'>).setProvider(</span></font><font size=2 color="#2a00ff" face="Courier \
New&#13;&#10;"><span style='font-size: 10.0pt;font-family:"Courier \
New\000D\000A";color:#2A00FF'>&quot;BC&quot;</span></font><font size=2 face="Courier \
New"><span style='black'><span style='font-size:10.0pt; font-family:"Courier \
New"'>));</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span></font><b><font size=2 color="#7f0055" face="Courier&#13;&#10; Ne"><span
style='bold'><span style='font-size:10.0pt;font-family:"Courier\000D\000A Ne";
color:#7F0055;font-weight:bold'>if</span></span></font></b><font size=2
face="Courier New ;color:black"><span style='font-size:10.0pt;font-family:"Courier \
New \;color\:black"'> (</span></font><font size=2 color="#0000c0" face="Courier New \
;color:#0000C0"><span style='font-size:10.0pt;font-family:"Courier New \
\;color\:\#0000C0";color:#0000C0'>otherRecipientsCertificate</span></font><font \
                size=2 face="Courier New"><span \
                style='font-size:10.0pt;font-family:"Courier New"'>
!= </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='#7F0055'><span style='#7F0055'><span style='font-size:10.0pt;font-family:
"Courier New";color:#7F0055;font-weight:bold'>null</span></span></span></font></b><font
 size=2 face="Courier New"><span style='black'><span style='font-size:10.0pt;
font-family:"Courier New"'>) \
{</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span></font><b><font size=2 color="#7f0055" face="Courier&#13;&#10; Ne"><span
style='bold'><span style='font-size:10.0pt;font-family:"Courier\000D\000A Ne";
color:#7F0055;font-weight:bold'>for</span></span></font></b><font size=2
face="Courier New ;color:black"><span style='font-size:10.0pt;font-family:"Courier \
New \;color\:black"'>(</span></font><b><font size=2 color="#7f0055" face="Courier \
New"><span style='font-size:10.0pt; font-family:"Courier \
New";color:#7F0055;font-weight:bold'>int</span></font></b><font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'> i=0; i &lt; \
</span></font><font size=2 color="#0000c0" face="Courier New&#13;&#10;"><span \
style='font-size:10.0pt;font-family:"Courier \
New\000D\000A";color:#0000C0'>otherRecipientsCertificate</span></font><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>.size(); \
i++)</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb \
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 gen.addRecipientInfoGenerator(</span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='#7F0055'><span style='font-size:10.0pt;
font-family:"Courier \
New";color:#7F0055;font-weight:bold'>new</span></span></font></b><font size=2 \
face="Courier New"><span style='black'><span style='font-size:10.0pt; \
font-family:"Courier New"'> \
JceKeyTransRecipientInfoGenerator((X509Certificate)</span></span></font><font size=2 \
color="#0000c0" face="Courier New&#13;&#10;"><span style='font-size: \
10.0pt;font-family:"Courier \
New\000D\000A";color:#0000C0'>otherRecipientsCertificate</span></font><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'>.get(i)).setProvider(</span></font><font size=2 color="#2a00ff" face="Courier \
New&#13;&#10;"><span style='font-size: 10.0pt;font-family:"Courier \
New\000D\000A";color:#2A00FF'>&quot;BC&quot;</span></font><font size=2 face="Courier \
New"><span style='black'><span style='font-size:10.0pt; font-family:"Courier \
New"'>));</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 }</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MimeBodyPart msg = </span></font><b><font \
size=2 color="#7f0055" face="Courier New"><span style='font-size:10.0pt; \
font-family:"Courier New";color:#7F0055;font-weight:bold'>new</span></font></b><font \
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'> \
MimeBodyPart();</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg.setDataHandler(</span></font><b><font \
size=2 color="#7f0055" face="Courier New"><span style='font-size:10.0pt; \
font-family:"Courier New";color:#7F0055;font-weight:bold'>new</span></font></b><font \
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'> \
DataHandler(</span></font><b><font size=2 color="#7f0055" face="Courier New"><span \
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight: \
bold'>new</span></font></b><font size=2 face="Courier New"><span \
style='font-size:10.0pt;font-family:"Courier New"'> \
BinaryBatchDataSource(</span></font><font size=2 color="#0000c0" face="Courier \
New&#13;&#10;"><span style='font-size: 10.0pt;font-family:"Courier \
New\000D\000A";color:#0000C0'>in</span></font><font size=2 face="Courier New"><span \
style='black'><span style='font-size:10.0pt; font-family:"Courier \
New"'>)));</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg.setHeader(</span></font><font size=2 \
color="#2a00ff" face="Courier New&#13;&#10;"><span style='font-size: \
10.0pt;font-family:"Courier \
New\000D\000A";color:#2A00FF'>&quot;Content-Type&quot;</span></font><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>, \
</span></font><font size=2 color="#2a00ff" face="Courier New ;color:#2A00FF"><span \
style='#2A00FF'><span style='#2A00FF'><span style='font-size:10.0pt;font-family: \
"Courier New \;color\:\#2A00FF";color:#2A00FF'>&quot;application/octet-stream&quot;</span></span></span></font><font
 size=2 face="Courier New"><span style='black'><span style='font-size:10.0pt;
font-family:"Courier \
New"'>);</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg.setHeader(</span></font><font size=2 \
color="#2a00ff" face="Courier New&#13;&#10;"><span style='font-size: \
10.0pt;font-family:"Courier \
New\000D\000A";color:#2A00FF'>&quot;Content-Transfer-Encoding&quot;</span></font><font
 size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>,
</span></font><font size=2 color="#2a00ff" face="Courier New ;color:#2A00FF"><span
style='#2A00FF'><span style='#2A00FF'><span style='font-size:10.0pt;font-family:
"Courier New \;color\:\#2A00FF";color:#2A00FF'>&quot;binary&quot;</span></span></span></font><font
 size=2 face="Courier New"><span style='black'><span style='font-size:10.0pt;
font-family:"Courier \
New"'>);</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MimeBodyPart mp = gen.generate(msg, \
</span></font><b><font size=2 color="#7f0055" face="Courier New"><span \
style='font-size:10.0pt; font-family:"Courier \
New";color:#7F0055;font-weight:bold'>new</span></font></b><font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'> <span \
style='background:silver'>JceCMSContentEncryptorBuilder</span>(CMSAlgorithm.</span></font><i><font
 size=2 color="#0000c0" face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier \
New";color:#0000C0;font-style:italic'>AES256_CBC</span></font></i><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>, \
256).setProvider(</span></font><font size=2 color="#2a00ff" face="Courier \
New&#13;&#10;"><span style='font-size:10.0pt;font-family:"Courier \
New\000D\000A";color:#2A00FF'>&quot;BC&quot;</span></font><font size=2 face="Courier \
New"><span style='black'><span style='font-size:10.0pt; font-family:"Courier \
New"'>).build());</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Properties props = System.<i><span \
style='font-style:italic'>getProperties</span></i>();</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Session session = Session.<i><span \
style='font-style:italic'>getDefaultInstance</span></i>(props, </span></font><b><font \
size=2 color="#7f0055" face="Courier&#13;&#10; Ne"><span style='#7F0055'><span \
style='bold'><span style='font-size:10.0pt;font-family:"Courier\000D\000A Ne"; \
color:#7F0055;font-weight:bold'>null</span></span></span></font></b><font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'>);</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MimeMessage body = </span></font><b><font \
size=2 color="#7f0055" face="Courier New"><span style='font-size:10.0pt; \
font-family:"Courier New";color:#7F0055;font-weight:bold'>new</span></font></b><font \
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'> \
MimeMessage(session);</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; body.setContent(mp.getContent(), \
mp.getContentType());</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
body.saveChanges();</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face="Courier New ;color:black"><span
style='font-size:10.0pt;font-family:"Courier New \
\;color\:black"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; body.writeTo(</span></font><font size=2 \
color="#0000c0" face="Courier New&#13;&#10;"><span style='font-size: \
10.0pt;font-family:"Courier New\000D\000A";color:#0000C0'>os</span></font><font \
size=2 face="Courier New"><span style='black'><span style='font-size:10.0pt; \
font-family:"Courier \
New"'>);</span></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>

<u5:p></u5:p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial'><u5:p>&nbsp;</u5:p></span></font><u4:p></u4:p><u1:p></u1:p><o:p></o:p></p>


</blockquote>

</u5:smarttagtype></u5:smarttagtype></u5:smarttagtype>

<p class=MsoNormal><font size=3 color=black face="Times New&#13;&#10; Ro"><span
style='font-size:12.0pt;font-family:"Times New\000D\000A \
Ro"'><u4:p>&nbsp;</u4:p></span></font><u1:p></u1:p><o:p></o:p></p>

</blockquote>

</u4:smarttagtype></u4:smarttagtype></u4:smarttagtype>

<p class=MsoNormal><font size=3 color=black
face="Times New&#13;&#10;                  Ro"><span style='font-size:12.0pt;
font-family:"Times New\000D\000A                  \
Ro"'><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>

</blockquote>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</u1:smarttagtype></u1:smarttagtype></u1:smarttagtype></div>

</body>

</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic