SslUtilsTest Class — netty Architecture
Architecture documentation for the SslUtilsTest class in SslUtilsTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 48820ee9_de8c_874d_12df_29f6fb10052e["SslUtilsTest"] 7e4b3958_bf49_4454_2a81_5f50c47356c3["SslUtilsTest.java"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|defined in| 7e4b3958_bf49_4454_2a81_5f50c47356c3 7678f0a6_ca17_7e40_9f9d_1ac88c7d206c["testPacketLength()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 7678f0a6_ca17_7e40_9f9d_1ac88c7d206c 78e0e68d_be99_1903_04c7_0b42fbf9ea0a["SSLEngine()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 78e0e68d_be99_1903_04c7_0b42fbf9ea0a fd555c44_923a_0763_aab6_d5a24450cd60["testIsTLSv13Cipher()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| fd555c44_923a_0763_aab6_d5a24450cd60 1f473e32_f187_3c6e_2956_d2ce68187530["shouldGetPacketLengthOfGmsslProtocolFromByteBuf()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 1f473e32_f187_3c6e_2956_d2ce68187530 2bd755a1_f628_179f_5f72_66168c19db10["shouldGetPacketLengthOfGmsslProtocolFromByteBuffer()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 2bd755a1_f628_179f_5f72_66168c19db10 85e7f3e5_f468_df42_7d22_c1ca898e6db9["shouldGetPacketLengthOfDtlsRecordFromByteBuf()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 85e7f3e5_f468_df42_7d22_c1ca898e6db9 36051a4c_95e4_a437_d1d7_93348bb3ce87["shouldGetPacketLengthOfFirstDtlsRecordFromByteBuf()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 36051a4c_95e4_a437_d1d7_93348bb3ce87 95a29074_972d_9ed1_7aaa_ddede67cfdc7["shouldSupportIncompletePackets()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 95a29074_972d_9ed1_7aaa_ddede67cfdc7 93596674_3d67_2f40_8b76_8943d94c7839["probeForSSLv2()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 93596674_3d67_2f40_8b76_8943d94c7839 75d9b8b2_d039_0a3b_a35e_fc6aee365c17["testValidHostNameForSni()"] 48820ee9_de8c_874d_12df_29f6fb10052e -->|method| 75d9b8b2_d039_0a3b_a35e_fc6aee365c17
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SslUtilsTest.java lines 42–191
public class SslUtilsTest {
@SuppressWarnings("deprecation")
@Test
public void testPacketLength() throws SSLException, NoSuchAlgorithmException {
SSLEngine engineLE = newEngine();
SSLEngine engineBE = newEngine();
ByteBuffer empty = ByteBuffer.allocate(0);
ByteBuffer cTOsLE = ByteBuffer.allocate(17 * 1024).order(ByteOrder.LITTLE_ENDIAN);
ByteBuffer cTOsBE = ByteBuffer.allocate(17 * 1024);
assertTrue(engineLE.wrap(empty, cTOsLE).bytesProduced() > 0);
cTOsLE.flip();
assertTrue(engineBE.wrap(empty, cTOsBE).bytesProduced() > 0);
cTOsBE.flip();
ByteBuf bufferLE = Unpooled.buffer().order(ByteOrder.LITTLE_ENDIAN).writeBytes(cTOsLE);
ByteBuf bufferBE = Unpooled.buffer().writeBytes(cTOsBE);
// Test that the packet-length for BE and LE is the same
assertEquals(getEncryptedPacketLength(bufferBE, 0, true),
getEncryptedPacketLength(bufferLE, 0, true));
assertEquals(getEncryptedPacketLength(new ByteBuffer[] { bufferBE.nioBuffer() }, 0),
getEncryptedPacketLength(new ByteBuffer[] { bufferLE.nioBuffer().order(ByteOrder.LITTLE_ENDIAN) }, 0));
}
private static SSLEngine newEngine() throws SSLException, NoSuchAlgorithmException {
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
engine.setUseClientMode(true);
engine.beginHandshake();
return engine;
}
@Test
public void testIsTLSv13Cipher() {
assertTrue(SslUtils.isTLSv13Cipher("TLS_AES_128_GCM_SHA256"));
assertTrue(SslUtils.isTLSv13Cipher("TLS_AES_256_GCM_SHA384"));
assertTrue(SslUtils.isTLSv13Cipher("TLS_CHACHA20_POLY1305_SHA256"));
assertTrue(SslUtils.isTLSv13Cipher("TLS_AES_128_CCM_SHA256"));
assertTrue(SslUtils.isTLSv13Cipher("TLS_AES_128_CCM_8_SHA256"));
assertFalse(SslUtils.isTLSv13Cipher("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"));
}
@Test
public void shouldGetPacketLengthOfGmsslProtocolFromByteBuf() {
int bodyLength = 65;
ByteBuf buf = Unpooled.buffer()
.writeByte(SslUtils.SSL_CONTENT_TYPE_HANDSHAKE)
.writeShort(SslUtils.GMSSL_PROTOCOL_VERSION)
.writeShort(bodyLength);
int packetLength = getEncryptedPacketLength(buf, 0, true);
assertEquals(bodyLength + SslUtils.SSL_RECORD_HEADER_LENGTH, packetLength);
buf.release();
}
@Test
public void shouldGetPacketLengthOfGmsslProtocolFromByteBuffer() {
int bodyLength = 65;
ByteBuf buf = Unpooled.buffer()
.writeByte(SslUtils.SSL_CONTENT_TYPE_HANDSHAKE)
.writeShort(SslUtils.GMSSL_PROTOCOL_VERSION)
.writeShort(bodyLength);
int packetLength = getEncryptedPacketLength(new ByteBuffer[] { buf.nioBuffer() }, 0);
assertEquals(bodyLength + SslUtils.SSL_RECORD_HEADER_LENGTH, packetLength);
buf.release();
}
@ParameterizedTest
@ValueSource(ints = {DTLS_1_0, DTLS_1_2, DTLS_1_3}) // six numbers
public void shouldGetPacketLengthOfDtlsRecordFromByteBuf(int dtlsVersion) {
int bodyLength = 65;
ByteBuf buf = Unpooled.buffer()
.writeByte(SslUtils.SSL_CONTENT_TYPE_HANDSHAKE)
.writeShort(dtlsVersion)
.writeShort(0) // epoch
.writeBytes(new byte[6]) // sequence number
.writeShort(bodyLength);
Source
Frequently Asked Questions
What is the SslUtilsTest class?
SslUtilsTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslUtilsTest.java.
Where is SslUtilsTest defined?
SslUtilsTest is defined in handler/src/test/java/io/netty/handler/ssl/SslUtilsTest.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free