473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Java CryptoAPI 3DES Key Compatibility

Hi,

A Java application is encrypting a block of text using 3DES ECB mode
and PKCS5 padding. I need to decrypt this text using C#. I've
extracted the 192 bit key using the getEncoded() method of the
SecretKey Java class. However when I use this key in .NET i cannot
decrypt the cipher text.

I am pretty sure that all my settings are correct, as far as setting
the ECB mode, PKCS5 padding and converting the cipher text to byte
arrays. I think it's the key that is giving me problems. Is there
anything that I must do to the exported java key before I use it in
..NET ?

Thanks
Michael Bebenita
Nov 15 '05 #1
3 7758
"Michael Bebenita" <th*******@sbcglobal.net> wrote in message
news:82**************************@posting.google.c om...

A Java application is encrypting a block of text using 3DES ECB mode
and PKCS5 padding. I need to decrypt this text using C#. I've
extracted the 192 bit key using the getEncoded() method of the
SecretKey Java class. However when I use this key in .NET i cannot
decrypt the cipher text.

I am pretty sure that all my settings are correct, as far as setting
the ECB mode, PKCS5 padding and converting the cipher text to byte
arrays. I think it's the key that is giving me problems. Is there
anything that I must do to the exported java key before I use it in
.NET ?


AFAIK, Java provides you with a 192-bit parity-adjusted key and .NET
requires a 168-bit non-parity-adjusted key. I don't think there is any
function in Java or .NET to remove the parity but it's simple enough to
implement (just a case of removing the LSB of each byte in the key).

You also need to ensure that your IV is shared between the two applications.

HTH

--
Gerard John Krupa BSc AMBCS
Purveyor of network management software
http://www.bogbrushzone.co.uk/
Nov 15 '05 #2
"Gerard Krupa" <ge****@spamfreebogbrush-zone.co.uk> wrote in message news:<dh*************@newsfep1-gui.server.ntli.net>...
"Michael Bebenita" <th*******@sbcglobal.net> wrote in message
news:82**************************@posting.google.c om...

A Java application is encrypting a block of text using 3DES ECB mode
and PKCS5 padding. I need to decrypt this text using C#. I've
extracted the 192 bit key using the getEncoded() method of the
SecretKey Java class. However when I use this key in .NET i cannot
decrypt the cipher text.

I am pretty sure that all my settings are correct, as far as setting
the ECB mode, PKCS5 padding and converting the cipher text to byte
arrays. I think it's the key that is giving me problems. Is there
anything that I must do to the exported java key before I use it in
.NET ?


AFAIK, Java provides you with a 192-bit parity-adjusted key and .NET
requires a 168-bit non-parity-adjusted key. I don't think there is any
function in Java or .NET to remove the parity but it's simple enough to
implement (just a case of removing the LSB of each byte in the key).

You also need to ensure that your IV is shared between the two applications.

HTH


Thanks for the reply,

I tired extracting the 168 bit key by removing the parity bit. However
now I get a "Specified key is not a valid size for this algorithm."
exception when i try to use the key. I remember reading somewhere that
..NET / Crypto API igonore the parity bit anyways.

Michael
Nov 15 '05 #3
th*******@sbcglobal.net (Michael Bebenita) wrote in message news:<82**************************@posting.google. com>...
"Gerard Krupa" <ge****@spamfreebogbrush-zone.co.uk> wrote in message news:<dh*************@newsfep1-gui.server.ntli.net>...
"Michael Bebenita" <th*******@sbcglobal.net> wrote in message
news:82**************************@posting.google.c om...

A Java application is encrypting a block of text using 3DES ECB mode
and PKCS5 padding. I need to decrypt this text using C#. I've
extracted the 192 bit key using the getEncoded() method of the
SecretKey Java class. However when I use this key in .NET i cannot
decrypt the cipher text.

I am pretty sure that all my settings are correct, as far as setting
the ECB mode, PKCS5 padding and converting the cipher text to byte
arrays. I think it's the key that is giving me problems. Is there
anything that I must do to the exported java key before I use it in
.NET ?


AFAIK, Java provides you with a 192-bit parity-adjusted key and .NET
requires a 168-bit non-parity-adjusted key. I don't think there is any
function in Java or .NET to remove the parity but it's simple enough to
implement (just a case of removing the LSB of each byte in the key).

You also need to ensure that your IV is shared between the two applications.

HTH


Thanks for the reply,

I tired extracting the 168 bit key by removing the parity bit. However
now I get a "Specified key is not a valid size for this algorithm."
exception when i try to use the key. I remember reading somewhere that
.NET / Crypto API igonore the parity bit anyways.

Michael


Forget all that, there was no compatibility problem. The error had to
do with something unrelated.
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jez Naisbitt | last post by:
Hi Guys, After a break of 2 years I'm now re-visiting the world of java. I recall on my last foray that I had to stick to java 1.1 so I could deploy applets from a server and obtain maximum...
1
by: underwmd | last post by:
Hello, My problem is two fold. 1) I must support a deployed legacy application written in VB6 SP5. I need to export data from a database, compress it and the encrypt the data using 3DES (to...
0
by: Kim HM | last post by:
I Have a .NET program sending mails using CDOEX. These mail I need to sign. I god a tip that i shoud use CAPICOM. That worked fine sending a mail with signature. BUT the problem is that I have...
3
by: Simang | last post by:
Hi, I am trying to encrypt viewstate in my ASP.NET web site. I put these items in the web.config.. <pages enableViewStateMac="true" /> <machineKey validation="3DES"/> However, when I tried...
4
by: Dave Bailey | last post by:
I have an application installed on a web server. When forst intalled it worked fine. The administrator rebooted the server and then when accessing the app the folowing error appears: CryptoAPI...
0
by: Frederic ESNOUF \(MVP-ISA\) | last post by:
Hi, My question is about 3des, ... in fact the difference between 3DES with Capicom (VB) and VB.net With VB6/capicom, encrypting data is simple : message.Content = "This is my bank account :...
1
by: Sathyaish | last post by:
I have the following scenario: Algorithm: 3DES Cipher Mode: CBC Key Size: 128-bit Block Size: 64 bit IV: 0x0000000000000000 (an eight byte array of zeros) The results I get using .NET with...
0
by: =?Utf-8?B?VmVuZWRpY3Q=?= | last post by:
Hi All, I have a program written in VB6 which utilize CryptoAPI to encrypt bitmap file. I'm writting a new program in C# 2005 to decrypt those encrypted bitmap file by adding the CryptoAPI...
1
by: tshad | last post by:
I am trying to use 3DES to encrypt my keys and am using VS 2003. I am confused with some code I have that seems to use a hash (MD5) in the 3DES. But a Hash is one way. You are not suppose to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.