CMSEnvelopedDataStreamGenerator Problem

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

CMSEnvelopedDataStreamGenerator Problem

Smith, Bill (Tridium)
I'm trying to create a CMSEnvelopedData object with
CMSEnvelopedDataStreamGenerator. I'm using a stream because the contents are
a large file. When I try the example in the java doc that uses
CMSAlgorithm.DES_EDE3_CBC, it works fine, but if I try and use anything else
like CMSAlgorithm.AES256_CVC), I get

java.security.NoSuchAlgorithmException: no such algorithm:
2.16.840.1.101.3.4.1.42 for provider BC

Can someone explain why this won't work or point me to an example?

Here is the snippet of code that I'm using.

    byte[] data =
"123456789012345678901234567890123456789012345678901234567890123456789012345
67890".getBytes();
    CMSAuthenticatedDataStreamGenerator adGen = new
CMSAuthenticatedDataStreamGenerator();
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    adGen.addRecipientInfoGenerator(new
JceKeyTransRecipientInfoGenerator(cert));

    OutputStream out = adGen.open(
      bOut, new
JceCMSMacCalculatorBuilder(CMSAlgorithm.AES256_CBC).setProvider("BC").build(
));
    out.write(data);

    out.close();


TIA.

William B. Smith
Senior Software Engineer, CSSLP
Tridium, Inc.
Direct: 804-474-5691
Mobile: 804-461-8107


smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: CMSEnvelopedDataStreamGenerator Problem

David Hook

At the moment, I think what you'd want to use here is
CMSAlgorithm.AES256_CCM - so CCM in a MAC mode where only the
associated data is fed into the cipher. Unfortunately support for that
hasn't made over from the FIPS project.

I'll try and put something together.

Regards,

David

On 23/08/16 06:25, Smith, Bill (Tridium) wrote:

> I'm trying to create a CMSEnvelopedData object with
> CMSEnvelopedDataStreamGenerator. I'm using a stream because the contents are
> a large file. When I try the example in the java doc that uses
> CMSAlgorithm.DES_EDE3_CBC, it works fine, but if I try and use anything else
> like CMSAlgorithm.AES256_CVC), I get
>
> java.security.NoSuchAlgorithmException: no such algorithm:
> 2.16.840.1.101.3.4.1.42 for provider BC
>
> Can someone explain why this won't work or point me to an example?
>
> Here is the snippet of code that I'm using.
>
>     byte[] data =
> "123456789012345678901234567890123456789012345678901234567890123456789012345
> 67890".getBytes();
>     CMSAuthenticatedDataStreamGenerator adGen = new
> CMSAuthenticatedDataStreamGenerator();
>     ByteArrayOutputStream bOut = new ByteArrayOutputStream();
>     adGen.addRecipientInfoGenerator(new
> JceKeyTransRecipientInfoGenerator(cert));
>
>     OutputStream out = adGen.open(
>       bOut, new
> JceCMSMacCalculatorBuilder(CMSAlgorithm.AES256_CBC).setProvider("BC").build(
> ));
>     out.write(data);
>
>     out.close();
>
>
> TIA.
>
> William B. Smith
> Senior Software Engineer, CSSLP
> Tridium, Inc.
> Direct: 804-474-5691
> Mobile: 804-461-8107
>