X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FTestSSL.java;fp=tests%2Forg%2Fcacert%2Fgigi%2FTestSSL.java;h=c39b20f5b07505cb9219c1ed22f6317616e96c38;hp=9756a7f3f4e2a044acd5860d1b58c000bf84fee5;hb=2824d1c165c501e2f3a8809044788b33b81f478a;hpb=8ef6a07673d3f52d9cb72b20f2560f12a6727459 diff --git a/tests/org/cacert/gigi/TestSSL.java b/tests/org/cacert/gigi/TestSSL.java index 9756a7f3..c39b20f5 100644 --- a/tests/org/cacert/gigi/TestSSL.java +++ b/tests/org/cacert/gigi/TestSSL.java @@ -25,14 +25,13 @@ public class TestSSL extends ManagedTest { static { InitTruststore.run(); } + @Test - public void testClientIntitiatedRenegotiation() - throws NoSuchAlgorithmException, IOException { + public void testClientIntitiatedRenegotiation() throws NoSuchAlgorithmException, IOException { SSLContext sc = SSLContext.getDefault(); SSLEngine se = sc.createSSLEngine(); String[] serverParts = getServerName().split(":", 2); - SocketChannel s = SocketChannel.open(new InetSocketAddress( - serverParts[0], Integer.parseInt(serverParts[1]))); + SocketChannel s = SocketChannel.open(new InetSocketAddress(serverParts[0], Integer.parseInt(serverParts[1]))); in = ByteBuffer.allocate(se.getSession().getApplicationBufferSize()); inC = ByteBuffer.allocate(se.getSession().getPacketBufferSize()); @@ -47,34 +46,33 @@ public class TestSSL extends ManagedTest { se.beginHandshake(); try { work(se, s); - throw new Error( - "Client re-negotiation succeded (possible DoS vulnerability"); + throw new Error("Client re-negotiation succeded (possible DoS vulnerability"); } catch (EOFException e) { // Cool, server closed connection } } - private void work(SSLEngine se, SocketChannel s) throws SSLException, - IOException { + + private void work(SSLEngine se, SocketChannel s) throws SSLException, IOException { while (se.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING - && se.getHandshakeStatus() != HandshakeStatus.FINISHED) { + && se.getHandshakeStatus() != HandshakeStatus.FINISHED) { switch (se.getHandshakeStatus()) { - case NEED_WRAP : - wrap(se, s); - break; - case NEED_UNWRAP : - unwrap(se, s); - break; - case NEED_TASK : - se.getDelegatedTask().run(); - break; - default : - System.out.println(se.getHandshakeStatus()); + case NEED_WRAP: + wrap(se, s); + break; + case NEED_UNWRAP: + unwrap(se, s); + break; + case NEED_TASK: + se.getDelegatedTask().run(); + break; + default: + System.out.println(se.getHandshakeStatus()); } } } - private SSLEngineResult unwrap(SSLEngine se, SocketChannel s) - throws IOException, SSLException { + + private SSLEngineResult unwrap(SSLEngine se, SocketChannel s) throws IOException, SSLException { if (inC.remaining() == 0) { inC.clear(); s.read(inC); @@ -95,8 +93,8 @@ public class TestSSL extends ManagedTest { } return result; } - private SSLEngineResult wrap(SSLEngine se, SocketChannel s) - throws SSLException, IOException { + + private SSLEngineResult wrap(SSLEngine se, SocketChannel s) throws SSLException, IOException { outC.clear(); SSLEngineResult result = se.wrap(out, outC); outC.flip();