Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2005

Tip: Looking for answers? Try searching our database.

Java encryption <--> .NET encryption

Thread view: 
gawel - 16 Mar 2005 12:58 GMT
Hajo,
I need to exchange encypted data between
.NET and Java environments. The first
problem I encountered is that symmetric
ciphers in .NET needs initialization
vector and Java counterparts don't.

Can some one point me out the place
where I can find any practise and
patterns for encrypted communication
between Java and .NET ?

thanks for any info

Gawel
Michel Gallant - 16 Mar 2005 14:14 GMT
A bit of discussion and some sample code for this for 3DES case:
  http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt
- Mitch Gallant

> Hajo,
> I need to exchange encypted data between
[quoted text clipped - 11 lines]
>
> Gawel
gawel - 16 Mar 2005 16:15 GMT
> A bit of discussion and some sample code for this for 3DES case:
>    http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt

At first glance looks great. Thanks for it.
Did you do similar comparison with RSA ?

Gawel
Michel Gallant - 16 Mar 2005 20:38 GMT
http://www.jensign.com/JavaScience/dotnet/RSAEncrypt
- Mitch

> > A bit of discussion and some sample code for this for 3DES case:
> >    http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt
[quoted text clipped - 3 lines]
>
> Gawel
gawel - 18 Mar 2005 15:02 GMT
> http://www.jensign.com/JavaScience/dotnet/RSAEncrypt

Hajo,

have you ever exchange RSA public key using Base64 between
Java and .NET? I have no problem with exchanging of
symmertic key(AES, DES) but for RSA I got modulus can
not be negative exception. I think it is connected with bytes
order but I do not know what is going on.

regards

Gawel
gawel - 18 Mar 2005 15:27 GMT
>> http://www.jensign.com/JavaScience/dotnet/RSAEncrypt
>
[quoted text clipped - 5 lines]
> not be negative exception. I think it is connected with bytes
> order but I do not know what is going on.

I found the reason of problem.
I have 1024 bit RSA. Modulus in java
has 129 bits and privateExponnet has 129 bits
but in .NET modulus has 128 bits and private exponent
has 128 bits. Java adds leading 0 to modulus and privateExponent.
When you add this 0 all is ok. Can you explain it ?

regards

Gawel
Michel Gallant - 18 Mar 2005 16:43 GMT
Shouldn't be a problem .. after all Modulus is simply a number and
same with exponent. That extra 0 is a leading 0 in Big Endian number
so has no significance. If you are careless with interpreting your bits
in swapping from little to big Endian .. it could cause a problem.
I think that "artifact" is documented in some of my C# source code  :-)
- Mitch

> >> http://www.jensign.com/JavaScience/dotnet/RSAEncrypt
> >
[quoted text clipped - 16 lines]
>
> Gawel
gawel - 21 Mar 2005 11:24 GMT
Hajo,

> Shouldn't be a problem .. after all Modulus is simply a number and
> same with exponent. That extra 0 is a leading 0 in Big Endian number
> so has no significance.
if you encode base64 key then it has :)

>If you are careless with interpreting your bits
> in swapping from little to big Endian .. it could cause a problem.
> I think that "artifact" is documented in some of my C# source code  :-)

Exactlly but in context of .NET and CryptoAPI.

Gawel

wrote:

>>>>http://www.jensign.com/JavaScience/dotnet/RSAEncrypt
>>>
[quoted text clipped - 16 lines]
>>
>>Gawel
gawel - 16 Mar 2005 16:49 GMT
One more thing.
In this article you mentioned that RSA
is not in JCE. But here I see RSA:
http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html#AppA

Can you explain me whre is the truth :)

Gawel
Michel Gallant - 16 Mar 2005 20:38 GMT
Pre JSE 1.5  RSA was only available for digital signature (not for encryption/enveloping).
However, provider was updated in JSE 1.5 to include RSA encryption capability:
   http://java.sun.com/j2se/1.5.0/docs/guide/security/enhancements15.html

- Mitch Gallant

> One more thing.
> In this article you mentioned that RSA
[quoted text clipped - 4 lines]
>
> Gawel
gawel - 17 Mar 2005 15:39 GMT
> A bit of discussion and some sample code for this for 3DES case:
>    http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt

I implemented AES using your pattern and all works great
except 256 bit keys. In this case I got exception about
not supported key length and in documentation is written
that JCE implementation of AES suppoerts 128, 192 and
256 bit keys.

One more thing, you can add to your article that
decrypted .NET bytes needs to be converted into String in Java
using following statement:

string plainDotNetText = new String(decryptedBytes, "UTF-16LE");

thanks once again for help

Gawel


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.