Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.security.InvalidKeyException IOException algid parse error

45085Oct 10 2010 — edited Oct 12 2010
Hi

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 9 2010
Added on Oct 10 2010
8 comments
12,884 views