• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Error while encrypting the xml file using asymmetric cipher...pls help

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have to encrypt the xml file using asymmetric cyper....

in one class , i am generating private key and public key using "RSA" algorithm..using 1024 byte initialization...
it is generating properly...

and after that in second class i am encrypting the xml file using "DESede" algorithm and i am using public key of above class..
but i am getting exceptione :

java.security.InvalidKeyException: Invalid key length: 162 bytes
at com.sun.crypto.provider.DESedeCipher.engineGetKeySize(DashoA6275)
at javax.crypto.Cipher.init(DashoA6275)
at XmlEncryption.getEncryptedData(XmlEncryption.java:147)
at XmlEncryption.encryptCompleteXmlFile(XmlEncryption.java:123)
at demoXmlEncApp.simulateBookSellersEnd(demoXmlEncApp.java:72)
at demoXmlEncApp.main(demoXmlEncApp.java:29)

so, what is that ?

i want to use RSA algo for key generatiion and DESede for cipher initialization .

is there any site for where source code of xml file encryption using asymmetric cipher is available?

pls, help me.....
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused - are you trying to use an RSA key with a DES cipher? That wouldn't work. A full example of using JCE can be found here. It doesn't really matter whether you are encrypting XML or some other data.
 
sachin kataria
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have to encrypt and decrypt the xml file...
so, first i generate public and private key using RSA algo.
after that for xml file encryption, i initialize cipher with DESeds algo..
that is giving me exception..

and i think the code which is in link ("found here") wont work for xml file encryption, it is use for simple data encryption
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sachin, re-read and reconsider my first post: Using an RSA key with a DES cipher won't work (which is why you're getting the exception).

And for encryption it doesn't matter whether you're encrypting XML data or some other text. So I don't understand where you see a difference between "xml file encryption" and "simple data encryption" - they are the same. If you think otherwise, explain to us how you got to that opinion, and we'll try to get you going again.
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between "simple data" and "xml" its just bytes. and the Cipher just does not care where the bytes are comming from...

pascal
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sachin kataria:
i have to encrypt and decrypt the xml file...
so, first i generate public and private key using RSA algo.
after that for xml file encryption, i initialize cipher with DESeds algo..
that is giving me exception..

and i think the code which is in link ("found here") wont work for xml file encryption, it is use for simple data encryption



To use a triple DES cipher (DESede), you need a triple DES secret key. To use a RSA cipher, you need a RSA public and/or private key.

These are two different algorithms, you can't generate a key for one and use it in the other. Not only don't I think the keys are the same size, there may also be safety checks to prevent you from accidentally doing so.

Henry
 
sachin kataria
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now i generate keypairgenerator using RSA algo.
and for xml encryption initialize cipher using RSA algo.

and it is working successfully......

Thanks everybody for help........
 
This is my favorite tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic