Hello I am trying to decrypt a file that is encrypted with RSA public key. I have a 3072-bit RSA private key corresponding to pubkey. The file contains the raw bytes of a PKCS8 encoding of the key. which i have in a byte array rsa_priv.
public void decrypt()
{
try
{
SecretKeySpec sk=new SecretKeySpec(rsa_priv,"RSA/EBC/PKCS8");
Cipher dec = Cipher.getInstance("RSA");
dec.init(Cipher.DECRYPT_MODE, sk,new IvParameterSpec(iv));
//OAEPWithSHA-512AndMGF1Padding
byte temp[];
temp=dec.doFinal(sess);
String t=temp.toString();
System.out.println("Session key is:"+ t);
//session=dec(sess,rsa_priv);OAEPWithSHA-256AndMGF1Padding
}
catch (Exception e)
{
System.out.println("Exception occured:"+ e);
}
}
when i run this code i get the following
Exception occured:java.security.InvalidKeyException: No installed provider
supports this key: javax.crypto.spec.SecretKeySpec
I have imported these
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.KeyGenerator;
import java.security.*;
import javax.crypto.SecretKey;
import javax.crypto.spec.OAEPParameterSpec;
someone please help me