JDK-8014374 : Cannot initialize "AES/GCM/NoPadding" on wrap/unseal on solaris with OracleUcrypto
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • Submitted: 2013-05-10
  • Updated: 2018-04-03
  • Resolved: 2013-10-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u191Fixed 8 b113Fixed
Description
The test code is attached with the bug.

Stack trace on Cipher.wrap:
com.oracle.security.ucrypto.UcryptoException: Cannot initialize Cipher
	at com.oracle.security.ucrypto.NativeCipher.ensureInitialized(NativeCipher.java:652)
	at com.oracle.security.ucrypto.NativeCipher.update(NativeCipher.java:683)
	at com.oracle.security.ucrypto.NativeCipher.engineDoFinal(NativeCipher.java:538)
	at com.oracle.security.ucrypto.NativeCipher.engineDoFinal(NativeCipher.java:520)
	at com.oracle.security.ucrypto.NativeCipher.engineWrap(NativeCipher.java:557)
	at javax.crypto.Cipher.wrap(Cipher.java:2427)
	at AEADKeyWrapperTest.execute(AEADKeyWrapperTest.java:70)
	at AEADKeyWrapperTest.main(AEADKeyWrapperTest.java:46)

Stack trace on SealedObject.unseal:
com.oracle.security.ucrypto.UcryptoException: Cannot initialize Cipher
	at com.oracle.security.ucrypto.NativeCipher.ensureInitialized(NativeCipher.java:652)
	at com.oracle.security.ucrypto.NativeCipher.update(NativeCipher.java:683)
	at com.oracle.security.ucrypto.NativeCipher.engineDoFinal(NativeCipher.java:538)
	at com.oracle.security.ucrypto.NativeCipher.engineDoFinal(NativeCipher.java:520)
	at javax.crypto.Cipher.doFinal(Cipher.java:2097)
	at javax.crypto.SealedObject.unseal(SealedObject.java:425)
	at javax.crypto.SealedObject.getObject(SealedObject.java:253)
	at AEAD_SO_Test.execute(AEAD_SO_Test.java:102)
	at AEAD_SO_Test.main(AEAD_SO_Test.java:44)

These failures are not observed on other platforms.


Comments
Inside the NativeCipher.init(...) impl, when no AAD is supplied for GCM mode, it returns w/o calling nativeInit(...) in an attempt to defer the nativeInit(...) call after AAD has been supplied. Thus, the native context never get initialized properly which leads to the test failure. Need to call nativeInit(...) regardless whether AAD is supplied or not.
27-09-2013

Shouldn't this one be targeted for JDK 8?
08-06-2013

This only happens for OracleUcrypto provider. When Cipher.getInstance(algo) is called without provider, OracleUcrypto is picked as default. Provider "SunJCE" works fine.
10-05-2013