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();
}
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);