Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JSS doesn't support AES key unwrapping

17 views
Skip to first unread message

alex.a...@gmail.com

unread,
Dec 23, 2008, 5:59:38 AM12/23/08
to
When I try to unwrap AES key via JSS API, I get the following
exception:

cipher = Cipher.getInstance("RSA", jssProvider);
cipher.init(Cipher.UNWRAP_MODE, wrapKeyPair.getPrivate());
Key unwrappedKey = cipher.unwrap(wrappedData, "AES",
Cipher.SECRET_KEY);

org.mozilla.jss.util.AssertionException: assertion failure!
at org.mozilla.jss.util.Assert._assert(Assert.java:58)
at org.mozilla.jss.pkcs11.PK11KeyWrapper.algFromType
(PK11KeyWrapper.java:545)
at org.mozilla.jss.pkcs11.PK11KeyWrapper.unwrapSymmetric
(PK11KeyWrapper.java:518)
at org.mozilla.jss.pkcs11.PK11KeyWrapper.unwrapSymmetric
(PK11KeyWrapper.java:484)
at
org.mozilla.jss.provider.javax.crypto.JSSCipherSpi.engineUnwrapSecret
(JSSCipherSpi.java:484)
at org.mozilla.jss.provider.javax.crypto.JSSCipherSpi.engineUnwrap
(JSSCipherSpi.java:452)
at javax.crypto.Cipher.unwrap(DashoA13*..)
at EncryptionTest.main(EncryptionTest.java:86)

The exception comes from the following code (in PK11KeyWrapper) that
clearly misses AES case:

private static Algorithm
algFromType(SymmetricKey.Type type) {
if( type == SymmetricKey.DES ) {
return EncryptionAlgorithm.DES_ECB;
} else if( type == SymmetricKey.DES3 ) {
return EncryptionAlgorithm.DES3_ECB;
} else if( type == SymmetricKey.RC4 ) {
return EncryptionAlgorithm.RC4;
} else {
Assert._assert( type == SymmetricKey.RC2 );
return EncryptionAlgorithm.RC2_CBC;
}
}

I've seen other people complaining about a similar problem.
Is this done on purpose (lack of proper code in NSS/JSS)? Or is it
some minor bug in JSS that may be easily fixed?

Thank you in advance,
Alex

Nelson B Bolyard

unread,
Dec 23, 2008, 2:53:23 PM12/23/08
to mozilla's crypto code discussion list
alex.a...@gmail.com wrote, On 2008-12-23 02:59:
> When I try to unwrap AES key via JSS API, I get the following
> exception:
>
> cipher = Cipher.getInstance("RSA", jssProvider);
> cipher.init(Cipher.UNWRAP_MODE, wrapKeyPair.getPrivate());
> Key unwrappedKey = cipher.unwrap(wrappedData, "AES",
> Cipher.SECRET_KEY);
>
> org.mozilla.jss.util.AssertionException: assertion failure!
> at org.mozilla.jss.util.Assert._assert(Assert.java:58)
> at org.mozilla.jss.pkcs11.PK11KeyWrapper.algFromType(PK11KeyWrapper.java:545)
> at org.mozilla.jss.pkcs11.PK11KeyWrapper.unwrapSymmetric(PK11KeyWrapper.java:518)
> at org.mozilla.jss.pkcs11.PK11KeyWrapper.unwrapSymmetric(PK11KeyWrapper.java:484)
> at org.mozilla.jss.provider.javax.crypto.JSSCipherSpi.engineUnwrapSecret(JSSCipherSpi.java:484)
> at org.mozilla.jss.provider.javax.crypto.JSSCipherSpi.engineUnwrap(JSSCipherSpi.java:452)

> at javax.crypto.Cipher.unwrap(DashoA13*..)
> at EncryptionTest.main(EncryptionTest.java:86)
>
> The exception comes from the following code (in PK11KeyWrapper) that
> clearly misses AES case:
>
> private static Algorithm
> algFromType(SymmetricKey.Type type) {
> if( type == SymmetricKey.DES ) {
> return EncryptionAlgorithm.DES_ECB;
> } else if( type == SymmetricKey.DES3 ) {
> return EncryptionAlgorithm.DES3_ECB;
> } else if( type == SymmetricKey.RC4 ) {
> return EncryptionAlgorithm.RC4;
> } else {
> Assert._assert( type == SymmetricKey.RC2 );
> return EncryptionAlgorithm.RC2_CBC;
> }
> }

Please file a bug in bugzilla.mozilla.org, product JSS, and put all
the above information into that bug. If you prefer not to do that,
please let me know and I will file the bug.

> I've seen other people complaining about a similar problem.

oh? This is the first report of this problem that I recall seeing.

> Is this done on purpose (lack of proper code in NSS/JSS)? Or is it
> some minor bug in JSS that may be easily fixed?

It's just a bug. If my recollection is correct, and no one else has
reported this assertion failure before this, then it tells us that
this feature is largely unused. :(

Nelson B Bolyard

unread,
Dec 23, 2008, 8:52:25 PM12/23/08
to mozilla's crypto code discussion list
I wrote, On 2008-12-23 11:53:

> Please file a bug in bugzilla.mozilla.org, product JSS, and put all
> the above information into that bug.

Glen filed a bug based on this report. (Thanks, Glen)
See https://bugzilla.mozilla.org/show_bug.cgi?id=470982

alex.a...@gmail.com

unread,
Dec 24, 2008, 2:32:24 PM12/24/08
to
> oh?  This is the first report of this problem that I recall seeing.

Here is a similar report that I was referring to:
http://groups.google.com/group/mozilla.dev.tech.crypto/browse_thread/thread/01028c36412d94bf

Nelson B Bolyard

unread,
Dec 24, 2008, 6:16:30 PM12/24/08
to mozilla's crypto code discussion list

Hmm. That message never received any replies. Maybe our JSS guru was
on vacation that week. (?) Thanks for pointing that out.

alex.a...@gmail.com

unread,
Jan 13, 2009, 4:46:45 AM1/13/09
to
FYI - I submitted a patch that fixes the problem.
See https://bugzilla.mozilla.org/show_bug.cgi?id=470982 for details.

Glen Beasley

unread,
Jan 13, 2009, 1:21:50 PM1/13/09
to mozilla's crypto code discussion list
alex.a...@gmail.com wrote:
> FYI - I submitted a patch that fixes the problem.
> See https://bugzilla.mozilla.org/show_bug.cgi?id=470982 for details.
> _______________________________________________
> dev-tech-crypto mailing list
> dev-tec...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-crypto
>
thank you. I put myself as reviewer. Note once you have a created a bug
you can keep communication in the bug.

-glen

0 new messages