Skip to content

Commit 3439512

Browse files
committed
8374317: Change GCM IV size to 12 bytes when encrypting/decrypting TLS session ticket
Reviewed-by: djelinski, mpowers, ascarpino
1 parent efb79dc commit 3439512

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -178,6 +178,7 @@ static StatelessKey getCurrentKey(HandshakeContext hc) {
178178
*/
179179
static final class SessionTicketSpec implements SSLExtensionSpec {
180180
private static final int GCM_TAG_LEN = 128;
181+
private static final int GCM_IV_LEN = 12;
181182
ByteBuffer data;
182183
static final ByteBuffer zero = ByteBuffer.wrap(new byte[0]);
183184

@@ -215,7 +216,7 @@ byte[] encrypt(HandshakeContext hc, SSLSessionImpl session) {
215216

216217
try {
217218
StatelessKey key = KeyState.getCurrentKey(hc);
218-
byte[] iv = new byte[16];
219+
byte[] iv = new byte[GCM_IV_LEN];
219220

220221
SecureRandom random = hc.sslContext.getSecureRandom();
221222
random.nextBytes(iv);
@@ -269,7 +270,7 @@ ByteBuffer decrypt(HandshakeContext hc) {
269270
return null;
270271
}
271272

272-
iv = new byte[16];
273+
iv = new byte[GCM_IV_LEN];
273274
data.get(iv);
274275
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
275276
c.init(Cipher.DECRYPT_MODE, key.key,

0 commit comments

Comments
 (0)