CVSROOT: /cvsroot/classpath Module name: classpath Branch: generics-branch Changes by: Casey Marshall <rsdio> 06/06/11 07:23:24
Modified files: . : ChangeLog-ssl-nio jessie-tests : testExtensionsList.java testServerHello.java testClientHello.java Log message: 2006-06-10 Casey Marshall <[EMAIL PROTECTED]> * jessie-tests/testClientHello.java: update for extensions changes. * jessie-tests/testExtensionList.java: likewise. * jessie-tests/testServerHello.java: likewise. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog-ssl-nio?cvsroot=classpath&only_with_tag=ssl-nio-branch&r1=1.1.2.4&r2=1.1.2.5 http://cvs.savannah.gnu.org/viewcvs/classpath/jessie-tests/testExtensionsList.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.1&r2=1.1.2.2 http://cvs.savannah.gnu.org/viewcvs/classpath/jessie-tests/testServerHello.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.1&r2=1.1.2.2 http://cvs.savannah.gnu.org/viewcvs/classpath/jessie-tests/testClientHello.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.1.2.1&r2=1.1.2.2 Patches: Index: ChangeLog-ssl-nio =================================================================== RCS file: /cvsroot/classpath/classpath/Attic/ChangeLog-ssl-nio,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -b -r1.1.2.4 -r1.1.2.5 --- ChangeLog-ssl-nio 6 Jun 2006 01:01:19 -0000 1.1.2.4 +++ ChangeLog-ssl-nio 11 Jun 2006 07:23:24 -0000 1.1.2.5 @@ -1,3 +1,41 @@ +2006-06-10 Casey Marshall <[EMAIL PROTECTED]> + + * jessie-tests/testClientHello.java: update for extensions + changes. + * jessie-tests/testExtensionList.java: likewise. + * jessie-tests/testServerHello.java: likewise. + +2006-06-10 Casey Marshall <[EMAIL PROTECTED]> + + * gnu/javax/net/ssl/provider/ServerHello.java (extensions): return + an ExtensionList. + (setExtensionsLength): set the length in the buffer. + (toString): print out individual extensions. + * gnu/javax/net/ssl/provider/Extension.java (valueBytes): new + method. + (valueBuffer): new method. + (value): return an Extenion.Value. + (toString): print out extension value. + (Value): new abstract inner class. + * gnu/javax/net/ssl/provider/ClientHello.java (extensions): return + an ExtensionList. + (setExtensionListLength): set the length in the buffer. + (toString): print out extensions. + * gnu/javax/net/ssl/provider/ServerHandshake.java + (chooseSuite, chooseCompression): use generics and foreach loops. + * gnu/javax/net/ssl/provider/ExtensionList.java: new class. + * gnu/javax/net/ssl/provider/MaxFragmentLength.java: new class. + * gnu/javax/net/ssl/provider/CertificateURL.java: new class. + * gnu/javax/net/ssl/provider/UnresolvedExtensionValue.java: new + class. + * gnu/javax/net/ssl/provider/TruncatedHMAC.java: new class. + * gnu/javax/net/ssl/provider/ServerNameList.java: new class. + * gnu/javax/net/ssl/provider/TrustedAuthorities.java: new class. + * gnu/javax/net/ssl/provider/CertificateStatusType.java: new + class. + * gnu/javax/net/ssl/provider/CertificateStatusRequest.java: new + class. + 2006-06-05 Casey Marshall <[EMAIL PROTECTED]> * gnu/javax/net/ssl/provider/Extension.java: add Javadoc. Index: jessie-tests/testExtensionsList.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testExtensionsList.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -b -r1.1.2.1 -r1.1.2.2 --- jessie-tests/testExtensionsList.java 6 Jun 2006 01:01:20 -0000 1.1.2.1 +++ jessie-tests/testExtensionsList.java 11 Jun 2006 07:23:24 -0000 1.1.2.2 @@ -44,7 +44,7 @@ System.out.println ("PASS: get(0).type()"); else System.out.println ("FAIL: get(0).type()"); - if (Arrays.equals (e.value(), new byte[] { 1 })) + if (Arrays.equals (e.valueBytes(), new byte[] { 1 })) System.out.println ("PASS: get(0).value()"); else System.out.println ("FAIL: get(0).value()"); @@ -54,7 +54,7 @@ System.out.println ("PASS: get(1).type()"); else System.out.println ("FAIL: get(1).type()"); - if (Arrays.equals(e.value(), new byte[3])) + if (Arrays.equals(e.valueBytes(), new byte[3])) System.out.println ("PASS: get(1).value()"); else System.out.println ("FAIL: get(1).value()"); Index: jessie-tests/testServerHello.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testServerHello.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -b -r1.1.2.1 -r1.1.2.2 --- jessie-tests/testServerHello.java 3 Jun 2006 07:44:41 -0000 1.1.2.1 +++ jessie-tests/testServerHello.java 11 Jun 2006 07:23:24 -0000 1.1.2.2 @@ -1,6 +1,8 @@ import gnu.javax.net.ssl.provider.CipherSuite; import gnu.javax.net.ssl.provider.CompressionMethod; +import gnu.javax.net.ssl.provider.Extension; +import gnu.javax.net.ssl.provider.ExtensionList; import gnu.javax.net.ssl.provider.Handshake; import gnu.javax.net.ssl.provider.ProtocolVersion; import gnu.javax.net.ssl.provider.Random; @@ -48,7 +50,14 @@ hello.setSessionId (sessionId); hello.setCipherSuite (CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA); hello.setCompressionMethod (CompressionMethod.ZLIB); - hello.setExtensionsLength (0); + hello.setExtensionsLength (12); + ExtensionList exts = hello.extensions(); + // Max fragment length of 2^9-1 + exts.set (0, Extension.Type.MAX_FRAGMENT_LENGTH, 1); // 2 + 2 + 1 + exts.get (0).setValue (new byte[] { 1 }); + // Zero-length server name. + exts.set (1, Extension.Type.SERVER_NAME, 3); // 2 + 2 + 3 + exts.get(1).setValue(new byte[3]); handshake.setLength (hello.length ()); System.err.println (handshake); @@ -69,5 +78,58 @@ System.out.println ("PASS: compressionMethod"); else System.out.println ("FAIL: compressionMethod"); + + exts = hello.extensions(); + Extension e = exts.get(0); + if (e.type() == Extension.Type.MAX_FRAGMENT_LENGTH) + System.out.println ("PASS: extensions().get(0).type"); + else + System.out.println ("FAIL: extensions().get(0).type"); + if (Arrays.equals(e.valueBytes(), new byte[] { 1 })) + System.out.println ("PASS: extensions().get(0).value"); + else + System.out.println ("FAIL: extensions().get(0).value"); + + e = exts.get(1); + if (e.type() == Extension.Type.SERVER_NAME) + System.out.println ("PASS: extensions().get(1).type"); + else + System.out.println ("FAIL: extensions().get(1).type"); + if (Arrays.equals(e.valueBytes(), new byte[3])) + System.out.println ("PASS: extensions().get(1).value"); + else + System.out.println ("FAIL: extensions().get(1).value"); + + // Part 2: with no extensions. + buffer = ByteBuffer.allocate (74); + handshake = new Handshake (buffer); + + handshake.setType (Handshake.Type.SERVER_HELLO); + handshake.setLength (70); + + hello = (ServerHello) handshake.body (); + + hello.setVersion (ProtocolVersion.TLS_1); // 2 + random = hello.random (); + random.setGmtUnixTime (123456); + nonce = new byte[28]; + for (int i = 0; i < nonce.length; i++) + nonce[i] = (byte) i; + random.setRandomBytes (nonce); // + 32 + sessionId = new byte[32]; + for (int i = 0; i < sessionId.length; i++) + sessionId[i] = (byte) i; + hello.setSessionId (sessionId); // + 33 + hello.setCipherSuite (CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA); // + 2 + hello.setCompressionMethod (CompressionMethod.ZLIB); // + 1 + + handshake = new Handshake (buffer); + hello = (ServerHello) handshake.body(); + if (hello.extensions() == null) + System.out.println ("PASS: hello.extensions() == null"); + else + System.out.println ("FAIL: hello.extensions() != null"); + + System.err.println (handshake); } } Index: jessie-tests/testClientHello.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testClientHello.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -b -r1.1.2.1 -r1.1.2.2 --- jessie-tests/testClientHello.java 3 Jun 2006 07:44:41 -0000 1.1.2.1 +++ jessie-tests/testClientHello.java 11 Jun 2006 07:23:24 -0000 1.1.2.2 @@ -5,6 +5,8 @@ import gnu.javax.net.ssl.provider.ClientHello; import gnu.javax.net.ssl.provider.CompressionMethod; import gnu.javax.net.ssl.provider.CompressionMethodList; +import gnu.javax.net.ssl.provider.Extension; +import gnu.javax.net.ssl.provider.ExtensionList; import gnu.javax.net.ssl.provider.ProtocolVersion; import gnu.javax.net.ssl.provider.Handshake; import gnu.javax.net.ssl.provider.Random; @@ -71,7 +73,15 @@ comps.put (0, CompressionMethod.NULL); comps.put (1, CompressionMethod.ZLIB); - hello.setExtensionsLength (0); + hello.setExtensionsLength (12); + ExtensionList exts = hello.extensions(); + // Max fragment length of 2^9-1 + exts.set (0, Extension.Type.MAX_FRAGMENT_LENGTH, 1); // 2 + 2 + 1 + exts.get (0).setValue (new byte[] { 1 }); + // Zero-length server name. + exts.set (1, Extension.Type.SERVER_NAME, 3); // 2 + 2 + 3 + exts.get(1).setValue(new byte[3]); + handshake.setLength (hello.length ()); handshake = new Handshake (buffer); @@ -102,6 +112,87 @@ else System.out.println ("FAIL: compressionMethods()"); + exts = hello.extensions(); + if (exts.size() == 2) + System.out.println ("PASS: extensions().size"); + else + System.out.println ("FAIL: extensions().size"); + if (exts.length () == 12) + System.out.println ("PASS: extensions().length"); + else + System.out.println ("FAIL: extensions().length"); + + Extension e = exts.get(0); + if (e.type() == Extension.Type.MAX_FRAGMENT_LENGTH) + System.out.println ("PASS: get(0).type()"); + else + System.out.println ("FAIL: get(0).type()"); + if (Arrays.equals (e.valueBytes(), new byte[] { 1 })) + System.out.println ("PASS: get(0).value()"); + else + System.out.println ("FAIL: get(0).value()"); + + e = exts.get(1); + if (e.type () == Extension.Type.SERVER_NAME) + System.out.println ("PASS: get(1).type()"); + else + System.out.println ("FAIL: get(1).type()"); + if (Arrays.equals(e.valueBytes(), new byte[3])) + System.out.println ("PASS: get(1).value()"); + else + System.out.println ("FAIL: get(1).value()"); + System.err.println (handshake); + + // Part 2: no extensions. + buffer = ByteBuffer.allocate(96); + handshake = new Handshake (buffer); + + handshake.setType (Handshake.Type.CLIENT_HELLO); + handshake.setLength (92); + + hello = null; + hello = (ClientHello) handshake.body (); + + sessionId = new byte[32]; + for (int i = 0; i < 32; i++) + sessionId[i] = (byte) i; + + hello.setVersion (ProtocolVersion.TLS_1); // 2 + hello.setSessionId (sessionId); // +33 (1 + 32) + + random = hello.random (); // +32 + random.setGmtUnixTime (123456); + nonce = new byte [28]; + for (int i = 0; i < nonce.length; i++) + nonce[i] = (byte) i; + random.setRandomBytes (nonce); + + suites = hello.cipherSuites (); + suites.setSize (10); // + 22 (2 + 2*10) + suites.put (0, CipherSuite.TLS_NULL_WITH_NULL_NULL); + suites.put (1, CipherSuite.TLS_RSA_WITH_NULL_MD5); + suites.put (2, CipherSuite.TLS_RSA_WITH_NULL_SHA); + suites.put (3, CipherSuite.TLS_RSA_EXPORT_WITH_RC4_40_MD5); + suites.put (4, CipherSuite.TLS_RSA_WITH_RC4_128_MD5); + suites.put (5, CipherSuite.TLS_RSA_WITH_RC4_128_SHA); + suites.put (6, CipherSuite.TLS_RSA_EXPORT_WITH_DES40_CBC_SHA); + suites.put (7, CipherSuite.TLS_RSA_WITH_DES_CBC_SHA); + suites.put (8, CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA); + suites.put (9, CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA); + + comps = hello.compressionMethods (); // + 3 (1 + 2*1) + comps.setSize (2); + comps.put (0, CompressionMethod.NULL); + comps.put (1, CompressionMethod.ZLIB); + + handshake = new Handshake(buffer); + hello = (ClientHello) handshake.body(); + if (hello.extensions() == null) + System.out.println("PASS: extensions() == null"); + else + System.out.println("FAIL: extensions() != null"); + + System.err.println(handshake); } }