Skip to content

Commit 06da4a7

Browse files
committed
Correct padding of streaming cipher for Java 14
Update groovy version (uses an ASM version that supports java 14) Pre Java 14 "AES/GCM/PKCS5Padding" was basically an alias to "AES/GCM/NoPadding" this is no longer the case https://www.oracle.com/java/technologies/javase/14-relnote-issues.html#JDK-8180392 back-port: #231
1 parent b49d64a commit 06da4a7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crypto/cipher/src/main/java/org/apache/shiro/crypto/AesCipherService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ public class AesCipherService extends DefaultBlockCipherService {
8989
* <b>**</b>Since {@code GCM} is a stream cipher, padding is implemented in the operation mode and an external padding scheme
9090
* cannot be used in conjunction with {@code GCM}. In fact, {@code AES/GCM/PKCS5Padding} is just an alias in most JVM for
9191
* {@code AES/GCM/NoPadding}.
92+
* <p/>
93+
* <b>NOTE:</b> As of Java 14, setting a streaming padding for the above example will throw a NoSuchAlgorithmException
94+
* @see <a href="https://www.oracle.com/java/technologies/javase/14-relnote-issues.html#JDK-8180392">JDK-8180392</a>
9295
*/
9396
public AesCipherService() {
9497
super(ALGORITHM_NAME);
9598
setMode(OperationMode.GCM);
9699
setStreamingMode(OperationMode.GCM);
97100
setPaddingScheme(PaddingScheme.NONE);
101+
setStreamingPaddingScheme(PaddingScheme.NONE);
98102
}
99103

100104
@Override

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<!-- Test 3rd-party dependencies: -->
111111
<easymock.version>4.1</easymock.version>
112112
<gmaven.version>1.8.0</gmaven.version>
113-
<groovy.version>2.5.8</groovy.version>
113+
<groovy.version>2.5.14</groovy.version>
114114
<junit.version>4.12</junit.version>
115115
<junit.server.jetty.version>0.11.0</junit.server.jetty.version>
116116
<hibernate.version>5.4.3.Final</hibernate.version>

0 commit comments

Comments
 (0)