473,782 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7785
"Michael Bebenita" <th*******@sbcg lobal.net> wrote in message
news:82******** *************** ***@posting.goo gle.com...

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****@spamfre ebogbrush-zone.co.uk> wrote in message news:<dh******* ******@newsfep1-gui.server.ntli .net>...
"Michael Bebenita" <th*******@sbcg lobal.net> wrote in message
news:82******** *************** ***@posting.goo gle.com...

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*******@sbcgl obal.net (Michael Bebenita) wrote in message news:<82******* *************** ****@posting.go ogle.com>...
"Gerard Krupa" <ge****@spamfre ebogbrush-zone.co.uk> wrote in message news:<dh******* ******@newsfep1-gui.server.ntli .net>...
"Michael Bebenita" <th*******@sbcg lobal.net> wrote in message
news:82******** *************** ***@posting.goo gle.com...

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
3017
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 compatibility with the standard browsers, supplied on all platforms: We live in the pre-press industry where folk use diverse platforms such as Sparc, Mac, PC (mnimum Win2K, or XP), using Netscape and Internet Explorer, etc.
1
766
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 prevent tampering) data gets transmitted at night to the home office of my company. Rewriting this application in .NET is not an option as the application was 5 years in development.
0
1903
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 to type the password for my certificate every time my program signs a mail :o( My program is a windows service running on a server so typing passwords is bad.
3
5094
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 to access the .NET pages, I encountered the ff error:
4
6462
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 cryptographic service provider (CSP) for this implementation could not be acquired. I am using DPAPI(Machine Store) to encrypt a connection string. The decryption code is as follows: private string GetConnectionString() { DataProtector dp...
0
1462
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 : Azerty007" message.SetSecret "MyPassword' message.Algorithm.KeyLength = CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_3DES
1
8040
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 the following routine are:
0
3247
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 reference in my C# project. Everything seem fine, i have no problem when execute the program. But when I click the button to decrypt the bitmap file, there is an error
1
1578
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 able to decrypt it. The only thing I can figure is that it is using the hash only on the key. Also, the ***************************************************** Public Shared Function TripleDESEncode(ByVal value As String, ByVal
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.