Java encryption <--> .NET encryption : Java
This is a discussion on Java encryption <--> .NET encryption within the Java forums in Programming Languages category; 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...
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| 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 |
|
#2
| |||
| |||
| A bit of discussion and some sample code for this for 3DES case: http://www.jensign.com/JavaScience/dotnet/NetDESEncrypt - Mitch Gallant "gawel" <gawelek@gazetamoveitout.pl> wrote in message news:d1978h$mo0$1@nemesis.news.tpi.pl... > 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 |
|
#3
| |||
| |||
| Michel Gallant wrote: > 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 |
|
#4
| |||
| |||
| 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/...uide.html#AppA Can you explain me whre is the truth ![]() Gawel |
|
#5
| |||
| |||
| 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/...cements15.html - Mitch Gallant "gawel" <gawelek@gazetamoveitout.pl> wrote in message news:d19kov$82t$1@nemesis.news.tpi.pl... > 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/...uide.html#AppA > > > Can you explain me whre is the truth ![]() > > > Gawel |
|
#6
| |||
| |||
| http://www.jensign.com/JavaScience/dotnet/RSAEncrypt - Mitch "gawel" <gawelek@gazetamoveitout.pl> wrote in message news:d19ipe$nun$1@nemesis.news.tpi.pl... > Michel Gallant wrote: > > > 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 |
|
#7
| |||
| |||
| Michel Gallant wrote: > 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 |
|
#8
| |||
| |||
| Michel Gallant wrote: > 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 |
|
#9
| |||
| |||
| gawel wrote: > Michel Gallant wrote: > >> 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. 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 |
|
#10
| |||
| |||
| 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 "gawel" <gawelek@gazetamoveitout.pl> wrote in message news:d1eooe$e6s$1@nemesis.news.tpi.pl... > gawel wrote: > > > Michel Gallant wrote: > > > >> 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. > > 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 |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Encryption via C# Code vs. SQL Native Encryption | usenet | CSharp | 0 | 11-28-2007 05:09 PM |
| Rijndael encryption - can I supply my own encryption key? | usenet | DOTNET | 1 | 08-21-2007 05:49 PM |
| Java Stream Encryption | usenet | Java | 9 | 01-04-2007 03:41 AM |
| GPG and java encryption/decryption | usenet | Java | 0 | 09-12-2005 03:37 AM |
| RSA encryption with private key in Java | usenet | Java | 1 | 05-13-2005 04:28 PM |
All times are GMT -5. The time now is 12:42 PM.



