java.security.InvalidKeyException IOException algid parse error
45085Oct 10 2010 — edited Oct 12 2010Hi
i am trying to encrypt message using private key (RSA), when i try to get the private key, for the given key spec, I get error (java.security.InvalidKeyException: IOException : algid parse error, not a sequence
)
below is he code snippet, error occurs at line no 4
KeyFactory keyFactory;
keyFactory = KeyFactory.getInstance(RSA);
PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(encryptionKeyBytes);
privKey = (RSAPrivateKey) keyFactory.generatePrivate(privSpec);
cf = Cipher.getInstance(RSA);
cf.init(Cipher.ENCRYPT_MODE, privKey);
let me know if i am missing something, the key is provide by 3rd party,
Thanks in advance