@@ -7173,6 +7173,7 @@ Node * LibraryCallKit::field_address_from_object(Node * fromObj, const char * fi
71737173bool LibraryCallKit::inline_aescrypt_Block (vmIntrinsics::ID id) {
71747174 address stubAddr = nullptr ;
71757175 const char *stubName;
7176+ bool is_decrypt = false ;
71767177 assert (UseAES, " need AES instruction support" );
71777178
71787179 switch (id) {
@@ -7183,6 +7184,7 @@ bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) {
71837184 case vmIntrinsics::_aescrypt_decryptBlock:
71847185 stubAddr = StubRoutines::aescrypt_decryptBlock ();
71857186 stubName = " aescrypt_decryptBlock" ;
7187+ is_decrypt = true ;
71867188 break ;
71877189 default :
71887190 break ;
@@ -7216,7 +7218,7 @@ bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) {
72167218
72177219 // now need to get the start of its expanded key array
72187220 // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java
7219- Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object);
7221+ Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object, is_decrypt );
72207222 if (k_start == nullptr ) return false ;
72217223
72227224 // Call the stub.
@@ -7231,7 +7233,7 @@ bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) {
72317233bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt (vmIntrinsics::ID id) {
72327234 address stubAddr = nullptr ;
72337235 const char *stubName = nullptr ;
7234-
7236+ bool is_decrypt= false ;
72357237 assert (UseAES, " need AES instruction support" );
72367238
72377239 switch (id) {
@@ -7242,6 +7244,7 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) {
72427244 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
72437245 stubAddr = StubRoutines::cipherBlockChaining_decryptAESCrypt ();
72447246 stubName = " cipherBlockChaining_decryptAESCrypt" ;
7247+ is_decrypt = true ;
72457248 break ;
72467249 default :
72477250 break ;
@@ -7295,7 +7298,7 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) {
72957298 aescrypt_object = _gvn.transform (aescrypt_object);
72967299
72977300 // we need to get the start of the aescrypt_object's expanded key array
7298- Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object);
7301+ Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object, is_decrypt );
72997302 if (k_start == nullptr ) return false ;
73007303
73017304 // similarly, get the start address of the r vector
@@ -7319,7 +7322,7 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) {
73197322bool LibraryCallKit::inline_electronicCodeBook_AESCrypt (vmIntrinsics::ID id) {
73207323 address stubAddr = nullptr ;
73217324 const char *stubName = nullptr ;
7322-
7325+ bool is_decrypt = false ;
73237326 assert (UseAES, " need AES instruction support" );
73247327
73257328 switch (id) {
@@ -7330,6 +7333,7 @@ bool LibraryCallKit::inline_electronicCodeBook_AESCrypt(vmIntrinsics::ID id) {
73307333 case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
73317334 stubAddr = StubRoutines::electronicCodeBook_decryptAESCrypt ();
73327335 stubName = " electronicCodeBook_decryptAESCrypt" ;
7336+ is_decrypt = true ;
73337337 break ;
73347338 default :
73357339 break ;
@@ -7381,7 +7385,7 @@ bool LibraryCallKit::inline_electronicCodeBook_AESCrypt(vmIntrinsics::ID id) {
73817385 aescrypt_object = _gvn.transform (aescrypt_object);
73827386
73837387 // we need to get the start of the aescrypt_object's expanded key array
7384- Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object);
7388+ Node* k_start = get_key_start_from_aescrypt_object (aescrypt_object, is_decrypt );
73857389 if (k_start == nullptr ) return false ;
73867390
73877391 // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
@@ -7474,17 +7478,17 @@ bool LibraryCallKit::inline_counterMode_AESCrypt(vmIntrinsics::ID id) {
74747478}
74757479
74767480// ------------------------------get_key_start_from_aescrypt_object-----------------------
7477- Node* LibraryCallKit::get_key_start_from_aescrypt_object (Node* aescrypt_object) {
7481+ Node* LibraryCallKit::get_key_start_from_aescrypt_object (Node* aescrypt_object, bool is_decrypt ) {
74787482 // MixColumns for decryption can be reduced by preprocessing MixColumns with round keys.
74797483 // Intel's extension is based on this optimization and AESCrypt generates round keys by preprocessing MixColumns.
74807484 // However, ppc64 vncipher processes MixColumns and requires the same round keys with encryption.
74817485 // The following platform specific stubs of encryption and decryption use the same round keys.
74827486#if defined(PPC64) || defined(S390) || defined(RISCV64)
7483- const char * key_name = " sessionKe " ;
7487+ bool use_decryption_key = false ;
74847488#else
7485- const char * key_name = " K " ;
7489+ bool use_decryption_key = is_decrypt ;
74867490#endif
7487- Node* objAESCryptKey = load_field_from_object (aescrypt_object, key_name , " [I" );
7491+ Node* objAESCryptKey = load_field_from_object (aescrypt_object, use_decryption_key ? " sessionKd " : " sessionKe " , " [I" );
74887492 assert (objAESCryptKey != nullptr , " wrong version of com.sun.crypto.provider.AES_Crypt" );
74897493 if (objAESCryptKey == nullptr ) return (Node *) nullptr ;
74907494
0 commit comments