diff options
Diffstat (limited to 'jessie-tests/gnu/javax')
11 files changed, 293 insertions, 104 deletions
diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testAlert.java b/jessie-tests/gnu/javax/net/ssl/provider/testAlert.java index d209248e2..089a9e43d 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testAlert.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testAlert.java @@ -8,41 +8,48 @@ class testAlert { public static void main (String[] argv) { - Alert a1 = new Alert (ByteBuffer.allocate (2)); try { - a1.setLevel (Alert.Level.WARNING); - System.out.println ("PASS: setLevel()"); - a1.setDescription (Alert.Description.UNEXPECTED_MESSAGE); - System.out.println ("PASS: setDescription()"); + check (); } - catch (Throwable t) + catch (Exception x) { - System.out.println ("FAIL: " + t); - t.printStackTrace (); - System.exit (1); + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); } + } + + static void check () throws Exception + { + Alert a1 = new Alert (ByteBuffer.allocate (2)); + + a1.setLevel (Alert.Level.WARNING); + System.out.println ("PASS: setLevel()"); + a1.setDescription (Alert.Description.UNEXPECTED_MESSAGE); + System.out.println ("PASS: setDescription()"); Alert a2 = new Alert (ByteBuffer.allocate (2)); - try - { - a2.setLevel (Alert.Level.WARNING); - System.out.println ("PASS: setLevel()"); - a2.setDescription (Alert.Description.UNEXPECTED_MESSAGE); - System.out.println ("PASS: setDescription()"); - } - catch (Throwable t) - { - System.out.println ("FAIL: " + t); - t.printStackTrace (); - System.exit (1); - } + + a2.setLevel (Alert.Level.WARNING); + System.out.println ("PASS: setLevel()"); + a2.setDescription (Alert.Description.UNEXPECTED_MESSAGE); + System.out.println ("PASS: setDescription()"); if (a1.equals (a2)) System.out.println ("PASS: equals()"); else System.out.println ("FAIL: equals()"); + if (a1.level () == Alert.Level.WARNING) + System.out.println ("PASS: level"); + else + System.out.println ("FAIL: level"); + + if (a1.description () == Alert.Description.UNEXPECTED_MESSAGE) + System.out.println ("PASS: description"); + else + System.out.println ("FAIL: description"); + System.err.println (a1); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testCertificate.java b/jessie-tests/gnu/javax/net/ssl/provider/testCertificate.java index 7a93feac4..e0eda8b6e 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testCertificate.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testCertificate.java @@ -7,6 +7,7 @@ import java.nio.ByteBuffer; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Collections; +import java.util.List; class testCertificate { @@ -28,6 +29,19 @@ class testCertificate public static void main (String[] argv) throws Throwable { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception + { final int alloc_len = 4096; CertificateFactory factory = CertificateFactory.getInstance ("X.509"); X509Certificate cert = (X509Certificate) @@ -38,9 +52,19 @@ class testCertificate handshake.setType (Handshake.Type.CERTIFICATE); handshake.setLength (alloc_len - 4); - Certificate _cert = (Certificate) handshake.getBody (); + Certificate _cert = (Certificate) handshake.body (); _cert.setCertificates (Collections.singletonList (cert)); - System.err.println (_cert.getCertificates ()); + System.err.println (_cert.certificates ()); System.err.println (_cert); + handshake.setLength (_cert.length ()); + + Handshake handshake2 = new Handshake (buffer); + Certificate _cert2 = (Certificate) handshake2.body (); + List certs = _cert2.certificates (); + + if (cert.equals (certs.get (0))) + System.out.println ("PASS: equals()"); + else + System.out.println ("FAIL: equals()"); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testCertificateRequest.java b/jessie-tests/gnu/javax/net/ssl/provider/testCertificateRequest.java index 84350d039..24706e881 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testCertificateRequest.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testCertificateRequest.java @@ -9,6 +9,19 @@ class testCertificateRequest { public static void main (String[] argv) throws Throwable { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception + { ByteBuffer buffer = ByteBuffer.allocate (4096); System.err.println ("create X500Principal..."); X500Principal name = new X500Principal ("C=US,ST=MA,L=Boston,O=FSF,OU=Certificate Authority,CN=savannah.gnu.org"); @@ -16,7 +29,7 @@ class testCertificateRequest CertificateRequest req = new CertificateRequest (buffer); System.err.println ("getting types..."); - ClientCertificateTypeList types = req.getTypes (); + ClientCertificateTypeList types = req.types (); types.setSize (4); System.err.println ("adding types..."); types.put (0, CertificateRequest.ClientCertificateType.DSS_FIXED_DH); @@ -25,12 +38,24 @@ class testCertificateRequest types.put (3, CertificateRequest.ClientCertificateType.RSA_SIGN); System.err.println ("getting names..."); - X500PrincipalList names = req.getAuthorities (); + X500PrincipalList names = req.authorities (); byte[] bytes = name.getEncoded (); names.setSize (1, bytes.length); System.err.println ("putting name..."); names.put (0, bytes); System.err.println (req); + + CertificateRequest req2 = new CertificateRequest (buffer); + ClientCertificateTypeList types2 = req2.types (); + X500PrincipalList names2 = req2.authorities (); + if (types2.equals (types)) + System.out.println ("PASS: equals(types)"); + else + System.out.println ("FAIL: equals(types)"); + if (names2.equals (names)) + System.out.println ("PASS: equals(names)"); + else + System.out.println ("FAIL: equals(names)"); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testCipherSuiteList.java b/jessie-tests/gnu/javax/net/ssl/provider/testCipherSuiteList.java index 4c52570e4..041291559 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testCipherSuiteList.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testCipherSuiteList.java @@ -24,5 +24,12 @@ class testCipherSuiteList } System.err.println (list); + + CipherSuiteList list2 = new CipherSuiteList (buffer); + + if (list2.equals (list)) + System.out.println ("PASS: equals()"); + else + System.out.println ("FAIL: equals()"); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testClientHello.java b/jessie-tests/gnu/javax/net/ssl/provider/testClientHello.java index a540f0f8e..619779203 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testClientHello.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testClientHello.java @@ -9,6 +9,19 @@ class testClientHello { public static void main (String[] argv) { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception + { final int alloc_len = 4096; ByteBuffer buffer = ByteBuffer.allocate (alloc_len); Handshake handshake = new Handshake (buffer); @@ -17,16 +30,7 @@ class testClientHello handshake.setLength (alloc_len - 4); ClientHello hello = null; - try - { - hello = (ClientHello) handshake.getBody (); - } - catch (Exception x) - { - x.printStackTrace (System.err); - System.out.println ("FAIL: " + x); - System.exit (1); - } + hello = (ClientHello) handshake.body (); byte[] sessionId = new byte[32]; for (int i = 0; i < 32; i++) @@ -35,14 +39,14 @@ class testClientHello hello.setProtocolVersion (ProtocolVersion.TLS_1); hello.setSessionId (sessionId); - Random random = hello.getRandom (); - random.setGMTUnixTime (123456); + Random random = hello.random (); + random.setGmtUnixTime (123456); byte[] nonce = new byte [28]; for (int i = 0; i < nonce.length; i++) nonce[i] = (byte) i; random.setRandomBytes (nonce); - CipherSuiteList suites = hello.getCipherSuites (); + CipherSuiteList suites = hello.cipherSuites (); suites.setSize (10); suites.put (0, CipherSuite.TLS_NULL_WITH_NULL_NULL); suites.put (1, CipherSuite.TLS_RSA_WITH_NULL_MD5); @@ -55,21 +59,41 @@ class testClientHello suites.put (8, CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA); suites.put (9, CipherSuite.TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA); - CompressionMethodList comps = hello.getCompressionMethods (); + CompressionMethodList comps = hello.compressionMethods (); comps.setSize (2); comps.put (0, CompressionMethod.NULL); comps.put (1, CompressionMethod.ZLIB); hello.setExtensionsLength (0); - handshake.setLength (hello.getLength ()); - - hello = (ClientHello) handshake.getBody (); - if (!ProtocolVersion.TLS_1.equals (hello.getProtocolVersion ())) - System.out.println ("FAIL: getProtocolVersion ()"); - if (hello.getRandom ().getGMTUnixTime () != 123456) - System.out.println ("FAIL: getRandom ().getGMTUnixTime ()"); - if (!Arrays.equals (nonce, hello.getRandom ().getRandomBytes ())) - System.out.println ("FAIL: getRandom ().getRandomBytes ()"); + handshake.setLength (hello.length ()); + + handshake = new Handshake (buffer); + + hello = (ClientHello) handshake.body (); + if (ProtocolVersion.TLS_1.equals (hello.protocolVersion ())) + System.out.println ("PASS: protocolVersion ()"); + else + System.out.println ("FAIL: protocolVersion ()"); + + if (hello.random ().gmtUnixTime () == 123456) + System.out.println ("PASS: random ().gmtUnixTime ()"); + else + System.out.println ("FAIL: random ().gmtUnixTime ()"); + + if (Arrays.equals (nonce, hello.random ().randomBytes ())) + System.out.println ("PASS: random ().randomBytes ()"); + else + System.out.println ("FAIL: random ().randomBytes ()"); + + if (suites.equals (hello.cipherSuites ())) + System.out.println ("PASS: cipherSuites()"); + else + System.out.println ("FAIL: cipherSuites()"); + + if (comps.equals (hello.compressionMethods ())) + System.out.println ("PASS: compressionMethods()"); + else + System.out.println ("FAIL: compressionMethods()"); System.err.println (handshake); } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testCompressionMethodList.java b/jessie-tests/gnu/javax/net/ssl/provider/testCompressionMethodList.java index 456c1f9a3..369836142 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testCompressionMethodList.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testCompressionMethodList.java @@ -8,7 +8,20 @@ import java.nio.ByteBuffer; class testCompressionMethodList { - public static void main (String[] argv) throws Exception + public static void main (String[] argv) + { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: uncaught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception { ByteBuffer buffer = ByteBuffer.allocate (3); CompressionMethodList list = new CompressionMethodList (buffer); @@ -16,6 +29,13 @@ class testCompressionMethodList list.setSize (2); list.put (0, CompressionMethod.NULL); list.put (1, CompressionMethod.ZLIB); + System.err.println (list); + + CompressionMethodList list2 = new CompressionMethodList (buffer); + if (list2.equals (list)) + System.out.println ("PASS: equals()"); + else + System.out.println ("FAIL: equals()"); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testHelloRequest.java b/jessie-tests/gnu/javax/net/ssl/provider/testHelloRequest.java index ff51940d0..e83e54759 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testHelloRequest.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testHelloRequest.java @@ -6,16 +6,28 @@ import java.nio.ByteBuffer; class testHelloRequest { - public static void main (String[] argv) throws Throwable + public static void main (String[] argv) + { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception { ByteBuffer buffer = ByteBuffer.allocate (4); Handshake handshake = new Handshake (buffer); handshake.setType (Handshake.Type.HELLO_REQUEST); handshake.setLength (0); - Handshake.Body body = handshake.getBody (); + HelloRequest body = (HelloRequest) handshake.body (); - if (!(body instanceof HelloRequest)) - System.out.println ("FAIL: " + body.getClass ()); + System.out.println ("PASS: body"); System.err.println (handshake); } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testRecord.java b/jessie-tests/gnu/javax/net/ssl/provider/testRecord.java index 176d575a4..a14417f3e 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testRecord.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testRecord.java @@ -9,57 +9,55 @@ class testRecord { public static void main (final String[] argv) { - ByteBuffer buf = ByteBuffer.allocate (42 + 5); - Record record = new Record (buf); - byte[] fragment = new byte[42]; - new java.util.Random (31337).nextBytes (fragment); try { - record.setVersion (ProtocolVersion.TLS_1); - System.out.println ("PASS: setVersion"); - record.setContentType (ContentType.APPLICATION_DATA); - System.out.println ("PASS: setContentType"); - record.setLength (42); - System.out.println ("PASS: setLength"); + check (); } - catch (Throwable t) + catch (Exception x) { - System.out.println ("FAIL: " + t); - System.exit (1); + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); } + } - try - { - record.getFragment ().put (fragment); - System.out.println ("PASS: getFragment ().put ()"); - } - catch (Throwable t) - { - System.out.println ("FAIL: " + t); - System.exit (1); - } + static void check () throws Exception + { + ByteBuffer buf = ByteBuffer.allocate (42 + 5); + Record record = new Record (buf); + byte[] fragment = new byte[42]; + new java.util.Random (31337).nextBytes (fragment); + + record.setVersion (ProtocolVersion.TLS_1); + System.out.println ("PASS: setVersion"); + record.setContentType (ContentType.APPLICATION_DATA); + System.out.println ("PASS: setContentType"); + record.setLength (42); + System.out.println ("PASS: setLength"); + + record.fragment ().put (fragment); + System.out.println ("PASS: fragment ().put ()"); - if (ProtocolVersion.TLS_1.equals (record.getVersion ())) - System.out.println ("PASS: getVersion()"); + if (ProtocolVersion.TLS_1.equals (record.version ())) + System.out.println ("PASS: version()"); else - System.out.println ("FAIL: getVersion()"); + System.out.println ("FAIL: version()"); - if (ContentType.APPLICATION_DATA.equals (record.getContentType ())) - System.out.println ("PASS: getContentType()"); + if (ContentType.APPLICATION_DATA.equals (record.contentType ())) + System.out.println ("PASS: contentType()"); else - System.out.println ("FAIL: getContentType()"); + System.out.println ("FAIL: contentType()"); - if (record.getLength () == 42) - System.out.println ("PASS: getLength()"); + if (record.length () == 42) + System.out.println ("PASS: length()"); else - System.out.println ("FAIL: getLength()"); + System.out.println ("FAIL: length()"); byte[] fragment2 = new byte[42]; - record.getFragment ().get (fragment2); + record.fragment ().get (fragment2); if (Arrays.equals (fragment, fragment2)) - System.out.println ("PASS: getFragment ().get ()"); + System.out.println ("PASS: fragment ().get ()"); else - System.out.println ("FAIL: getFragment ().get ()"); + System.out.println ("FAIL: fragment ().get ()"); System.err.println (record); } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testServerDHParams.java b/jessie-tests/gnu/javax/net/ssl/provider/testServerDHParams.java index 20c03dc07..f511e8b81 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testServerDHParams.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testServerDHParams.java @@ -9,6 +9,19 @@ class testServerDHParams { public static void main (String[] argv) throws Throwable { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception + { BigInteger p = new BigInteger ("1234567890abcdef1234567890abcdef1234567890abcdef", 16); BigInteger g = BigInteger.valueOf (2); BigInteger y = new BigInteger ("fedcba0987654321fedcba0987654321fedcba0987654321", 16); @@ -20,12 +33,20 @@ class testServerDHParams params.setG (g); params.setY (y); - if (!params.getP ().equals (p)) - System.out.println ("FAIL: " + p + " != " + params.getP ()); - if (!params.getG ().equals (g)) - System.out.println ("FAIL: " + g + " != " + params.getG ()); - if (!params.getY ().equals (y)) - System.out.println ("FAIL: " + y + " != " + params.getY ()); + if (params.p ().equals (p)) + System.out.println ("PASS: p"); + else + System.out.println ("FAIL: " + p + " != " + params.p ()); + + if (params.g ().equals (g)) + System.out.println ("PASS: g"); + else + System.out.println ("FAIL: " + g + " != " + params.g ()); + + if (params.y ().equals (y)) + System.out.println ("PASS: y"); + else + System.out.println ("FAIL: " + y + " != " + params.y ()); System.err.println (params); } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testServerHello.java b/jessie-tests/gnu/javax/net/ssl/provider/testServerHello.java index eba9176ce..ff59831e1 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testServerHello.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testServerHello.java @@ -3,10 +3,24 @@ package gnu.javax.net.ssl.provider; import java.nio.ByteBuffer; +import java.util.Arrays; class testServerHello { - public static void main (String[] argv) throws Exception + public static void main (String[] argv) + { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception { final int alloc_len = 4096; ByteBuffer buffer = ByteBuffer.allocate (alloc_len); @@ -15,11 +29,11 @@ class testServerHello handshake.setType (Handshake.Type.SERVER_HELLO); handshake.setLength (alloc_len - 4); - ServerHello hello = (ServerHello) handshake.getBody (); + ServerHello hello = (ServerHello) handshake.body (); hello.setProtocolVersion (ProtocolVersion.TLS_1); - Random random = hello.getRandom (); - random.setGMTUnixTime (123456); + Random random = hello.random (); + random.setGmtUnixTime (123456); byte[] nonce = new byte[28]; for (int i = 0; i < nonce.length; i++) nonce[i] = (byte) i; @@ -32,7 +46,24 @@ class testServerHello hello.setCompressionMethod (CompressionMethod.ZLIB); hello.setExtensionsLength (0); - handshake.setLength (hello.getLength ()); + handshake.setLength (hello.length ()); System.err.println (handshake); + + handshake = new Handshake (buffer); + hello = (ServerHello) handshake.body (); + if (Arrays.equals (sessionId, hello.sessionId ())) + System.out.println ("PASS: sessionId"); + else + System.out.println ("FAIL: sessionId"); + + if (hello.cipherSuite () == CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA) + System.out.println ("PASS: cipherSuite"); + else + System.out.println ("FAIL: cipherSuite"); + + if (hello.compressionMethod () == CompressionMethod.ZLIB) + System.out.println ("PASS: compressionMethod"); + else + System.out.println ("FAIL: compressionMethod"); } } diff --git a/jessie-tests/gnu/javax/net/ssl/provider/testServerRSAParams.java b/jessie-tests/gnu/javax/net/ssl/provider/testServerRSAParams.java index b40518613..e41926c7e 100644 --- a/jessie-tests/gnu/javax/net/ssl/provider/testServerRSAParams.java +++ b/jessie-tests/gnu/javax/net/ssl/provider/testServerRSAParams.java @@ -9,6 +9,19 @@ class testServerRSAParams { public static void main (String[] argv) throws Throwable { + try + { + check (); + } + catch (Exception x) + { + System.out.println ("FAIL: caught exception " + x); + x.printStackTrace (); + } + } + + static void check () throws Exception + { BigInteger modulus = new BigInteger ("1234567890abcdef1234567890abcdef1234567890abcdef", 16); BigInteger exponent = BigInteger.valueOf (0xff); ByteBuffer buffer = ByteBuffer.allocate (1024); @@ -18,10 +31,17 @@ class testServerRSAParams params.setModulus (modulus); params.setExponent (exponent); - if (!params.getModulus ().equals (modulus)) - System.out.println ("FAIL: " + modulus + " != " + params.getModulus ()); - if (!params.getExponent ().equals (exponent)) - System.out.println ("FAIL: " + exponent + " != " + params.getExponent ()); + params = new ServerRSAParams (buffer); + + if (params.modulus ().equals (modulus)) + System.out.println ("PASS: modulus"); + else + System.out.println ("FAIL: " + modulus + " != " + params.modulus ()); + + if (params.exponent ().equals (exponent)) + System.out.println ("PASS: exponent"); + else + System.out.println ("FAIL: " + exponent + " != " + params.exponent ()); System.err.println (params); } |