2002/05/05 08:37:32
[org.ibex.core.git] / src / org / xwt / TinySSL.java
index 516fee6..e3f90ab 100644 (file)
@@ -151,12 +151,17 @@ public class TinySSL extends Socket {
     public InputStream getInputStream() { return is; }
     public OutputStream getOutputStream() { return os; }
 
-    public TinySSL(String host, int port) throws IOException {
+    public TinySSL(String host, int port) throws IOException { this(host, port, true); }
+    public TinySSL(String host, int port, boolean negotiateImmediately) throws IOException {
         super(host, port);
         hostname = host;
+        if (negotiateImmediately) negotiate();
+    }
+
+    /** negotiates the SSL connection */
+    public void negotiate() throws IOException {
         os = new SSLOutputStream(super.getOutputStream());
         is = new SSLInputStream(super.getInputStream());
-            
         os.writeClientHello();
         is.readServerHandshakes();
         os.sendClientHandshakes();
@@ -1532,7 +1537,7 @@ public class TinySSL extends Socket {
         }
 
         public int getInputBlockSize() { return engine.getInputBlockSize() - (forEncryption ? HEADER_LENGTH : 0); }
-        public int getOutputBlockSize() { return engine.getInputBlockSize() - (forEncryption ? 0 : HEADER_LENGTH); }
+        public int getOutputBlockSize() { return engine.getOutputBlockSize() - (forEncryption ? 0 : HEADER_LENGTH); }
 
         public byte[] processBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException {
             return forEncryption ? encodeBlock(in, inOff, inLen) : decodeBlock(in, inOff, inLen);