JSP RSA Encryption Issue

Iam able to run the same code successfully in generic java class but gives "No Such Provider for RSA" when the class method are called by JSP.

ecipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");

dcipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");

ecipher.init(Cipher.ENCRYPT_MODE, publicKey);

dcipher.init(Cipher.DECRYPT_MODE, privateKey);

Please provide any info on same.

[413 byte] By [anzaana] at [2007-11-27 7:58:13]
# 1
Why is a JSP - MVC view - running that code? Which JVM? Which server?Please provide any info on same. :p
CeciNEstPasUnProgrammeura at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 2
> Please provide any info on same.Your JSP is running with a JVM prior to 1.5 . Update it to 1.5 or later OR switch to using an alternative provider such as BouncyCastle..
sabre150a at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 3
Ya you are right.Its working in JDK1.5.I just verified it.Can one provide way to generate keys for RSA based on user input keys !Thx,Anjan
anzaana at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 4

> Ya you are right.Its working in JDK1.5.I just

> verified it.

Err.. - this does not compute!

>

> Can one provide way to generate keys for RSA based on

> user input keys !

>

You have not specified the format in which the user provides the keys.

sabre150a at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 5

BigInteger modulus = new BigInteger("966828d2e198fc5d3e6dc24843176e205bcee002930f2cef0d879018fde7cb5803ed3fbf41e44e"+

"5bdf2408180992ea709c32b8fe95dc84e3c2d820df8bd03ab06ee0b581c6d40fe8a2ec15b21686"+

"af7b6e30b594a0a539ecef58555b23822b5482042969283df1eb5da15c09eeb3e72fa366715d39"+

"39c4ef1076b8e35fc6065d", 16);

BigInteger privmodulus = new BigInteger ("33c24a722fb26efe43928fee40305af485c38e71345c5f91306dbb57ee608b2891c95e4b9a0850"+

"32eb7a41d2cbd0a41ef691b9f9da6695d0af67a3006ae3d09e084300d439f29d43d030c7fd9cfb"+

"e752ad6ed1edf297b4e8ee7310eac08a45817ec71d84dec9329e374dde208c828d4e9b87e7a27d"+

"da6cb6b20a7e733a17717d", 16);

RSAPrivateKeySpec PrivKey = new RSAPrivateKeySpec(modulus, privmodulus);

KeyFactory keyFactory_dec = KeyFactory.getInstance("RSA");

RSAPrivateKey Privkey = (RSAPrivateKey)keyFactory_dec.generatePrivate(PrivKey);

Cipher cipher_enc = Cipher.getInstance("RSA/ECB/PKCS1Padding");

cipher_enc.init(Cipher.ENCRYPT_MODE, Privkey);

anzaana at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 6
Err... so you have solved the key problem?
sabre150a at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 7
sir.. its fine like this.But i want to modify this program so as the user is able to give a password from which the public and private keys could be generated.I want to change the program as per user's password.
anzaana at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 8

From: SystemAdministrator@anzaan.com.bc

To: newUser@anzaan.com.bc

Subject: Your Password

Dir Sir,

We thank you for choosing Anzaan.

Your pasword is

rewt9tfgb9f=ds=g0fd9gdfs=g9bkcxvsqd;rtkwefdf9ds=-fgfdsg98cbjv;lakdsfgfdg9fdsgdfsgfagfdsgfds0g9fdgfsdgdsfgdalfgiw[5e9814352'kgf]-e2tkw

gkgkjrew[pewtirewtet.

Type carefully.

corlettka at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...
# 9

> sir.. its fine like this.But i want to modify this

> program so as the user is able to give a password

> from which the public and private keys could be

> generated.

>

> I want to change the program as per user's password.

You can't create an RSA key directly from a password. Generate a random RSA key using Java or openssl or any other means and store it in a key store, database or other key repository that is protected by a password.

sabre150a at 2007-7-12 19:40:07 > top of Java-index,Java Essentials,Java Programming...