1 /*
2 * Copyright 2014 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package io.netty5.handler.codec.http2;
17
18 import io.netty5.util.internal.UnstableApi;
19
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.List;
24
25 /**
26 * Provides utilities related to security requirements specific to HTTP/2.
27 */
28 @UnstableApi
29 public final class Http2SecurityUtil {
30 /**
31 * The following list is derived from <a
32 * href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html">SunJSSE Supported
33 * Ciphers</a> and <a
34 * href="https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility">Mozilla Modern Cipher
35 * Suites</a> in accordance with the <a
36 * href="https://tools.ietf.org/html/rfc7540#section-9.2.2">HTTP/2 Specification</a>.
37 *
38 * According to the <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html">
39 * JSSE documentation</a> "the names mentioned in the TLS RFCs prefixed with TLS_ are functionally equivalent
40 * to the JSSE cipher suites prefixed with SSL_".
41 * Both variants are used to support JVMs supporting the one or the other.
42 */
43 public static final List<String> CIPHERS;
44
45 /**
46 * <a href="https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28recommended.29"
47 * >Mozilla Modern Cipher Suites Intermediate compatibility</a> minus the following cipher suites that are black
48 * listed by the <a href="https://tools.ietf.org/html/rfc7540#appendix-A">HTTP/2 RFC</a>.
49 */
50 private static final List<String> CIPHERS_JAVA_MOZILLA_MODERN_SECURITY = Collections.unmodifiableList(Arrays
51 .asList(
52 /* openssl = ECDHE-ECDSA-AES128-GCM-SHA256 */
53 "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
54
55 /* REQUIRED BY HTTP/2 SPEC */
56 /* openssl = ECDHE-RSA-AES128-GCM-SHA256 */
57 "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
58 /* REQUIRED BY HTTP/2 SPEC */
59
60 /* openssl = ECDHE-ECDSA-AES256-GCM-SHA384 */
61 "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
62 /* openssl = ECDHE-RSA-AES256-GCM-SHA384 */
63 "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
64 /* openssl = ECDHE-ECDSA-CHACHA20-POLY1305 */
65 "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
66 /* openssl = ECDHE-RSA-CHACHA20-POLY1305 */
67 "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
68
69 /* TLS 1.3 ciphers */
70 "TLS_AES_128_GCM_SHA256",
71 "TLS_AES_256_GCM_SHA384",
72 "TLS_CHACHA20_POLY1305_SHA256"
73 ));
74
75 static {
76 CIPHERS = Collections.unmodifiableList(new ArrayList<>(CIPHERS_JAVA_MOZILLA_MODERN_SECURITY));
77 }
78
79 private Http2SecurityUtil() { }
80 }