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]

> 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.
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);
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.
> 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.