testExtractMasterkeyWorksCorrectly() — netty Function Reference
Architecture documentation for the testExtractMasterkeyWorksCorrectly() function in OpenSslEngineTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1f609819_e071_f33f_4b09_77f0808d4b07["testExtractMasterkeyWorksCorrectly()"] 08957e63_66e1_e2b4_c8aa_4f617c598a7d["OpenSslEngineTest"] 1f609819_e071_f33f_4b09_77f0808d4b07 -->|defined in| 08957e63_66e1_e2b4_c8aa_4f617c598a7d a0b1cb4b_c452_1ab1_598b_b75a1bce5b7c["runTasksIfNeeded()"] 1f609819_e071_f33f_4b09_77f0808d4b07 -->|calls| a0b1cb4b_c452_1ab1_598b_b75a1bce5b7c style 1f609819_e071_f33f_4b09_77f0808d4b07 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java lines 1187–1351
@MethodSource("newTestParams")
@ParameterizedTest
public void testExtractMasterkeyWorksCorrectly(SSLEngineTestParam param) throws Exception {
if (param.combo() != ProtocolCipherCombo.tlsv12()) {
return;
}
SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
serverSslCtx = wrapContext(param, SslContextBuilder.forServer(cert.key(), cert.cert())
.protocols(param.protocols())
.ciphers(param.ciphers())
.sslProvider(OPENSSL).build());
final SSLEngine serverEngine =
wrapEngine(serverSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
clientSslCtx = wrapContext(param, SslContextBuilder.forClient()
.trustManager(cert.certificate())
.protocols(param.protocols())
.ciphers(param.ciphers())
.endpointIdentificationAlgorithm(null)
.sslProvider(OPENSSL).build());
final SSLEngine clientEngine =
wrapEngine(clientSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
final String enabledCipher = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256";
try {
//lets set the cipher suite to a specific one with DHE
assumeTrue(Arrays.asList(clientEngine.getSupportedCipherSuites()).contains(enabledCipher),
"The diffie hellman cipher is not supported on your runtime.");
//https://www.ietf.org/rfc/rfc5289.txt
//For cipher suites ending with _SHA256, the PRF is the TLS PRF
//[RFC5246] with SHA-256 as the hash function. The MAC is HMAC
//[RFC2104] with SHA-256 as the hash function.
clientEngine.setEnabledCipherSuites(new String[] { enabledCipher });
serverEngine.setEnabledCipherSuites(new String[] { enabledCipher });
int appBufferMax = clientEngine.getSession().getApplicationBufferSize();
int netBufferMax = clientEngine.getSession().getPacketBufferSize();
/*
* We'll make the input buffers a bit bigger than the max needed
* size, so that unwrap()s following a successful data transfer
* won't generate BUFFER_OVERFLOWS.
*/
ByteBuffer clientIn = ByteBuffer.allocate(appBufferMax + 50);
ByteBuffer serverIn = ByteBuffer.allocate(appBufferMax + 50);
ByteBuffer cTOs = ByteBuffer.allocate(netBufferMax);
ByteBuffer sTOc = ByteBuffer.allocate(netBufferMax);
ByteBuffer clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes(CharsetUtil.US_ASCII));
ByteBuffer serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes(CharsetUtil.US_ASCII));
// This implementation is largely imitated from
// https://docs.oracle.com/javase/8/docs/technotes/
// guides/security/jsse/samples/sslengine/SSLEngineSimpleDemo.java
// It has been simplified however without the need for running delegation tasks
// Do handshake for SSL
// A typical handshake will usually contain the following steps:
// 1. wrap: ClientHello
// 2. unwrap: ServerHello/Cert/ServerHelloDone
// 3. wrap: ClientKeyExchange
// 4. wrap: ChangeCipherSpec
// 5. wrap: Finished
// 6. unwrap: ChangeCipherSpec
// 7. unwrap: Finished
//set a for loop; instead of a while loop to guarantee we quit out eventually
boolean asserted = false;
for (int i = 0; i < 1000; i++) {
clientEngine.wrap(clientOut, cTOs);
serverEngine.wrap(serverOut, sTOc);
cTOs.flip();
sTOc.flip();
runTasksIfNeeded(clientEngine);
runTasksIfNeeded(serverEngine);
clientEngine.unwrap(sTOc, clientIn);
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does testExtractMasterkeyWorksCorrectly() do?
testExtractMasterkeyWorksCorrectly() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java.
Where is testExtractMasterkeyWorksCorrectly() defined?
testExtractMasterkeyWorksCorrectly() is defined in handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java at line 1187.
What does testExtractMasterkeyWorksCorrectly() call?
testExtractMasterkeyWorksCorrectly() calls 1 function(s): runTasksIfNeeded.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free