Java + JSS - Cipher operation failed on token

Composer, ChatZilla and other Mozilla applications, along with Netscape, Galeon, K-Meleon and other products.
Posts: 2
Joined: May 14th, 2010, 4:36 am

Post Posted May 14th, 2010, 4:45 am

I am trying to use NSS+JSS as JCA in Java. I get the following exception:

Exception in thread "main" org.mozilla.jss.crypto.TokenRuntimeException: Cipher operation failed on token
at org.mozilla.jss.provider.javax.crypto.JSSCipherSpi.engineDoFinal(
at javax.crypto.Cipher.doFinal(DashoA12275)
at javax.crypto.CipherInputStream.close(DashoA12275)

I am on RHEL 5 with jdk 1.5.0_12

I have modified the file to include the following entry:


I am able to encrypt a file using the above combination but when I try to decrypt the same file, I get the exception.

Any pointers of how can I make NSS+JSS work in JCA mode with Java?

Posts: 2
Joined: May 14th, 2010, 4:36 am

Post Posted May 17th, 2010, 8:16 am

I was able to encrypt/decrypt files using NSS+JSS as JCA in Java.

Initially I was using CipherInputStream and CipherOutputStream as a wrapper over FileInputStream and FileOutputStream for encryption and decryption. It didn't work. I went through the example code for encryption and decryption posted on mozilla's site.

I based my solution on the same code and it worked very well. But now I am stuck with another problem. It worked only in non-FIPS mode.

When I enable the FIPS mode it starts giving error saying cannot 'unwrap the key'. This, as I understand, is basically because we need to wrap and unwrap keys before encryption/decryption according to FIPS specification. But I have not been able get this working properly.

What I would like to do is generate AES 128 bit key from a predefined text, use it to encrypt a file. Then later again generate the same key and decrypt the file. But then how to wrap/unwrap this key?

Posts: 2
Joined: August 1st, 2013, 6:31 am

Post Posted August 1st, 2013, 6:37 am

Hello Saurabhsule82,

I am working on doing encryption and decryption stuff using NSS+JSS using java application in FIPS mode. Looks like you got achieved and able to work with that. I have experience working with JCE provider but this is the first time i am using NSS.

need your help in working with that. Please respond with your suggestions.

Thank you,


User avatar
Posts: 38222
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Post Posted August 1st, 2013, 6:55 am

The last post was....."Posted Tue 18th May 2010."

I doubt whether anyone is still interested.

If you have a problem, start a new thread. Thank you.

Locking due to old age.
Ancient Amateur Astronomer
Win-7-HP/IntelĀ® DualCore-2.0GHz/500G HDD/4 Gig Ram/550Watt PSU/350WattUPS/Firefox-20.0-57.0/T-bird-
RadioYachting. (Always choose the "Custom" Install.)

Return to Other Applications and Distributions

Who is online

Users browsing this forum: No registered users and 2 guests