Top Description Fields Constructors Methods
io.netty5.handler.ssl

public final Class CipherSuiteConverter

extends Object
Class Inheritance
Annotations
@UnstableApi
Imports
io.netty5.util.internal.UnstableApi, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.Collections, .HashMap, .Map, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.regex.Matcher, .Pattern

Converts a Java cipher suite string to an OpenSSL cipher suite string and vice versa.
See Also
Wikipedia page about cipher suite

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<String, String>
j2o

Java-to-OpenSSL cipher suite conversion map Note that the Java cipher suite has the protocol prefix (TLS_, SSL_)

private static final Map<String, String>
private static final Pattern
private static final Pattern
private static final Pattern
JAVA_CIPHERSUITE_PATTERN

A_B_WITH_C_D, where: A - TLS or SSL (protocol) B - handshake algorithm (key exchange and authentication algorithms to be precise) C - bulk cipher D - HMAC algorithm This regular expression assumes that: 1) A is always TLS or SSL, and 2) D is always a single word.

private static final InternalLogger
private static final ConcurrentMap<String, Map<String, String>>
o2j

OpenSSL-to-Java cipher suite conversion map.

private static final Map<String, Map<String, String>>
private static final Pattern
private static final Pattern
private static final Pattern
OPENSSL_CIPHERSUITE_PATTERN

A-B-C, where: A - handshake algorithm (key exchange and authentication algorithms to be precise) B - bulk cipher C - HMAC algorithm This regular expression assumes that: 1) A has some deterministic pattern as shown below, and 2) C is always a single word

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
cacheFromJava(String javaCipherSuite, boolean boringSSL)

private static Map<String, String>
cacheFromOpenSsl(String openSslCipherSuite)

pack-priv static void
clearCache()

Clears the cache for testing purpose.

pack-priv static void
convertToCipherStrings(Iterable<String> cipherSuites, StringBuilder cipherBuilder, StringBuilder cipherTLSv13Builder, boolean boringSSL)

Convert the given ciphers if needed to OpenSSL format and append them to the correct StringBuilder depending on if its a TLSv1.3 cipher or not.

pack-priv static boolean
isJ2OCached(String key, String value)

Tests if the specified key-value pair has been cached in Java-to-OpenSSL cache.

pack-priv static boolean
isO2JCached(String key, String protocol, String value)

Tests if the specified key-value pair has been cached in OpenSSL-to-Java cache.

public static String

Returns:

The translated cipher suite name according to java conventions. This will not be null.
toJava
(String
An OpenSSL cipher suite name.
openSslCipherSuite
,
String
The cryptographic protocol (i.e. SSL, TLS, ...).
protocol
)

Convert from OpenSSL cipher suite name convention to java cipher suite name convention.

private static String
toJavaBulkCipher(String bulkCipher, boolean export)

private static String
toJavaHandshakeAlgo(String handshakeAlgo, boolean export)

private static String
pack-priv static String
toJavaUncached(String openSslCipherSuite)

private static String
toJavaUncached0(String openSslCipherSuite, boolean checkTls13)

public static String

Returns:

null if the conversion has failed
toOpenSsl
(String javaCipherSuite, boolean boringSSL)

Converts the specified Java cipher suite to its corresponding OpenSSL cipher suite name.

private static String
private static String
private static String
pack-priv static String
toOpenSslUncached(String javaCipherSuite, boolean boringSSL)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

j2oback to summary
private static final ConcurrentMap<String, String> j2o

Java-to-OpenSSL cipher suite conversion map Note that the Java cipher suite has the protocol prefix (TLS_, SSL_)

j2oTls13back to summary
private static final Map<String, String> j2oTls13
JAVA_AES_CBC_PATTERNback to summary
private static final Pattern JAVA_AES_CBC_PATTERN
JAVA_AES_PATTERNback to summary
private static final Pattern JAVA_AES_PATTERN
JAVA_CIPHERSUITE_PATTERNback to summary
private static final Pattern JAVA_CIPHERSUITE_PATTERN

A_B_WITH_C_D, where: A - TLS or SSL (protocol) B - handshake algorithm (key exchange and authentication algorithms to be precise) C - bulk cipher D - HMAC algorithm This regular expression assumes that: 1) A is always TLS or SSL, and 2) D is always a single word.

loggerback to summary
private static final InternalLogger logger
o2jback to summary
private static final ConcurrentMap<String, Map<String, String>> o2j

OpenSSL-to-Java cipher suite conversion map. Note that one OpenSSL cipher suite can be converted to more than one Java cipher suites because a Java cipher suite has the protocol name prefix (TLS_, SSL_)

o2jTls13back to summary
private static final Map<String, Map<String, String>> o2jTls13
OPENSSL_AES_CBC_PATTERNback to summary
private static final Pattern OPENSSL_AES_CBC_PATTERN
OPENSSL_AES_PATTERNback to summary
private static final Pattern OPENSSL_AES_PATTERN
OPENSSL_CIPHERSUITE_PATTERNback to summary
private static final Pattern OPENSSL_CIPHERSUITE_PATTERN

A-B-C, where: A - handshake algorithm (key exchange and authentication algorithms to be precise) B - bulk cipher C - HMAC algorithm This regular expression assumes that: 1) A has some deterministic pattern as shown below, and 2) C is always a single word

Constructor Detail

CipherSuiteConverterback to summary
private CipherSuiteConverter()

Method Detail

cacheFromJavaback to summary
private static String cacheFromJava(String javaCipherSuite, boolean boringSSL)
cacheFromOpenSslback to summary
private static Map<String, String> cacheFromOpenSsl(String openSslCipherSuite)
clearCacheback to summary
pack-priv static void clearCache()

Clears the cache for testing purpose.

convertToCipherStringsback to summary
pack-priv static void convertToCipherStrings(Iterable<String> cipherSuites, StringBuilder cipherBuilder, StringBuilder cipherTLSv13Builder, boolean boringSSL)

Convert the given ciphers if needed to OpenSSL format and append them to the correct StringBuilder depending on if its a TLSv1.3 cipher or not. If this methods returns without throwing an exception its guaranteed that at least one of the StringBuilders contain some ciphers that can be used to configure OpenSSL.

isJ2OCachedback to summary
pack-priv static boolean isJ2OCached(String key, String value)

Tests if the specified key-value pair has been cached in Java-to-OpenSSL cache.

isO2JCachedback to summary
pack-priv static boolean isO2JCached(String key, String protocol, String value)

Tests if the specified key-value pair has been cached in OpenSSL-to-Java cache.

toJavaback to summary
public static String toJava(String openSslCipherSuite, String protocol)

Convert from OpenSSL cipher suite name convention to java cipher suite name convention.

Parameters
openSslCipherSuite:String

An OpenSSL cipher suite name.

protocol:String

The cryptographic protocol (i.e. SSL, TLS, ...).

Returns:String

The translated cipher suite name according to java conventions. This will not be null.

toJavaBulkCipherback to summary
private static String toJavaBulkCipher(String bulkCipher, boolean export)
toJavaHandshakeAlgoback to summary
private static String toJavaHandshakeAlgo(String handshakeAlgo, boolean export)
toJavaHmacAlgoback to summary
private static String toJavaHmacAlgo(String hmacAlgo)
toJavaUncachedback to summary
pack-priv static String toJavaUncached(String openSslCipherSuite)
toJavaUncached0back to summary
private static String toJavaUncached0(String openSslCipherSuite, boolean checkTls13)
toOpenSslback to summary
public static String toOpenSsl(String javaCipherSuite, boolean boringSSL)

Converts the specified Java cipher suite to its corresponding OpenSSL cipher suite name.

Returns:String

null if the conversion has failed

toOpenSslBulkCipherback to summary
private static String toOpenSslBulkCipher(String bulkCipher)
toOpenSslHandshakeAlgoback to summary
private static String toOpenSslHandshakeAlgo(String handshakeAlgo)
toOpenSslHmacAlgoback to summary
private static String toOpenSslHmacAlgo(String hmacAlgo)
toOpenSslUncachedback to summary
pack-priv static String toOpenSslUncached(String javaCipherSuite, boolean boringSSL)