anon.crypto.tinytls
Class TinyTLS

java.lang.Object
  extended by java.net.Socket
      extended by anon.crypto.tinytls.TinyTLS

public class TinyTLS
extends java.net.Socket

Author:
stefan TinyTLS

Nested Class Summary
(package private)  class TinyTLS.TLSInputStream
           
(package private)  class TinyTLS.TLSOutputStream
           
 
Field Summary
private  boolean m_certificaterequested
           
private  boolean m_certificateverify
           
private  boolean m_checkTrustedRoot
           
private  JAPCertificate[] m_clientcertificates
           
private  byte[] m_clientcertificatetypes
           
private  IMyPrivateKey m_clientprivatekey
           
private  byte[] m_clientrandom
           
private  boolean m_encrypt
           
private  boolean m_handshakecompleted
           
private  byte[] m_handshakemessages
           
private  TinyTLS.TLSInputStream m_istream
           
private  TinyTLS.TLSOutputStream m_ostream
           
private  ProxyConnection m_ProxyConnection
           
private  CipherSuite m_selectedciphersuite
           
private  JAPCertificate m_servercertificate
           
private  boolean m_serverhellodone
           
private  byte[] m_serverrandom
           
private  java.util.Vector m_supportedciphersuites
           
private  IMyPublicKey m_trustedRoot
           
static byte[] PROTOCOLVERSION
          SSL VERSION : 3.1 for TLS
private static int PROTOCOLVERSION_SHORT
           
 
Constructor Summary
TinyTLS(java.lang.String addr, int port)
          TinyTLS creates a TLS Connection to a server
TinyTLS(java.lang.String addr, int port, ImmutableProxyInterface a_proxyInterface)
          TinyTLS creates a TLS Connection to a server which may use a proxy
 
Method Summary
 void addCipherSuite(CipherSuite cs)
          add a ciphersuites to TinyTLS
 void checkRootCertificate(boolean check)
          check or check not the root certificate
 void close()
           
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
 java.net.Socket getSocket()
           
 void setClientCertificate(JAPCertificate[] certificates, IMyPrivateKey key)
          sets a client certificate chain
 void setClientCertificate(JAPCertificate cert, IMyPrivateKey key)
          sets the client certificate
 void setRootKey(IMyPublicKey rootKey)
          sets the root key that is accepted
 void setSoTimeout(int i)
           
 void startHandshake()
          start the handshake
 
Methods inherited from class java.net.Socket
bind, connect, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOLVERSION

public static byte[] PROTOCOLVERSION
SSL VERSION : 3.1 for TLS


PROTOCOLVERSION_SHORT

private static int PROTOCOLVERSION_SHORT

m_supportedciphersuites

private java.util.Vector m_supportedciphersuites

m_selectedciphersuite

private CipherSuite m_selectedciphersuite

m_istream

private TinyTLS.TLSInputStream m_istream

m_ostream

private TinyTLS.TLSOutputStream m_ostream

m_handshakecompleted

private boolean m_handshakecompleted

m_serverhellodone

private boolean m_serverhellodone

m_certificaterequested

private boolean m_certificaterequested

m_servercertificate

private JAPCertificate m_servercertificate

m_trustedRoot

private IMyPublicKey m_trustedRoot

m_checkTrustedRoot

private boolean m_checkTrustedRoot

m_clientrandom

private byte[] m_clientrandom

m_serverrandom

private byte[] m_serverrandom

m_handshakemessages

private byte[] m_handshakemessages

m_clientcertificatetypes

private byte[] m_clientcertificatetypes

m_clientprivatekey

private IMyPrivateKey m_clientprivatekey

m_clientcertificates

private JAPCertificate[] m_clientcertificates

m_certificateverify

private boolean m_certificateverify

m_encrypt

private boolean m_encrypt

m_ProxyConnection

private ProxyConnection m_ProxyConnection
Constructor Detail

TinyTLS

public TinyTLS(java.lang.String addr,
               int port)
        throws java.net.UnknownHostException,
               java.io.IOException,
               java.lang.Exception
TinyTLS creates a TLS Connection to a server

Parameters:
addr - Server Address
port - Server's TLS Port
Throws:
java.net.UnknownHostException
java.io.IOException
java.lang.Exception

TinyTLS

public TinyTLS(java.lang.String addr,
               int port,
               ImmutableProxyInterface a_proxyInterface)
        throws java.net.UnknownHostException,
               java.io.IOException,
               java.lang.Exception
TinyTLS creates a TLS Connection to a server which may use a proxy

Parameters:
addr - Server Address
port - Server's TLS Port
a_proxyInterface - Proxy Settings
Throws:
java.net.UnknownHostException
java.io.IOException
java.lang.Exception
Method Detail

addCipherSuite

public void addCipherSuite(CipherSuite cs)
add a ciphersuites to TinyTLS

Parameters:
cs - ciphersuite you want to add

startHandshake

public void startHandshake()
                    throws java.io.IOException
start the handshake

Throws:
java.io.IOException
CertificateException
java.lang.Exception

setRootKey

public void setRootKey(IMyPublicKey rootKey)
sets the root key that is accepted

Parameters:
rootKey - rootkey

checkRootCertificate

public void checkRootCertificate(boolean check)
check or check not the root certificate

Parameters:
check -

getInputStream

public java.io.InputStream getInputStream()
Overrides:
getInputStream in class java.net.Socket

getOutputStream

public java.io.OutputStream getOutputStream()
Overrides:
getOutputStream in class java.net.Socket

setSoTimeout

public void setSoTimeout(int i)
                  throws java.net.SocketException
Overrides:
setSoTimeout in class java.net.Socket
Throws:
java.net.SocketException

setClientCertificate

public void setClientCertificate(JAPCertificate cert,
                                 IMyPrivateKey key)
                          throws java.io.IOException
sets the client certificate

Parameters:
cert - certificate
key - private key
Throws:
java.io.IOException

setClientCertificate

public void setClientCertificate(JAPCertificate[] certificates,
                                 IMyPrivateKey key)
                          throws java.io.IOException
sets a client certificate chain

Parameters:
certificates - certificate chain, where the previous certificate is signed with the following
key - private key
Throws:
java.io.IOException

close

public void close()
Overrides:
close in class java.net.Socket

getSocket

public java.net.Socket getSocket()