anon.crypto.tinytls.keyexchange
Class DHE_RSA_Key_Exchange

java.lang.Object
  extended by anon.crypto.tinytls.keyexchange.Key_Exchange
      extended by anon.crypto.tinytls.keyexchange.DHE_RSA_Key_Exchange

public class DHE_RSA_Key_Exchange
extends Key_Exchange

Author:
stefan Diffie Hellman Key Exchange with a RSA signed Certificate

Field Summary
private static byte[] CLIENTFINISHEDLABEL
           
private static org.bouncycastle.crypto.params.DHParameters DH_PARAMS
           
private static byte[] KEYEXPANSION
           
private  byte[] m_clientrandom
           
private  org.bouncycastle.crypto.agreement.DHBasicAgreement m_dhe
           
private  org.bouncycastle.crypto.params.DHParameters m_dhparams
           
private  org.bouncycastle.crypto.params.DHPublicKeyParameters m_dhserverpub
           
private  byte[] m_mastersecret
           
private  byte[] m_premastersecret
           
private  byte[] m_serverrandom
           
private static byte[] MASTERSECRET
           
private static int MAXKEYMATERIALLENGTH
           
private static java.math.BigInteger SAFEPRIME
           
private static byte[] SERVERFINISHEDLABEL
           
 
Constructor Summary
DHE_RSA_Key_Exchange()
           
 
Method Summary
 byte[] calculateClientFinished(byte[] handshakemessages)
          generate the client finished message (see RFC2246)
 byte[] calculateClientKeyExchange()
          generates the client key exchange message (see RFC2246)
 byte[] calculateKeys()
          calculates the key material (see RFC2246 TLS Record Protocoll)
 byte[] calculateServerFinished(byte[] handshakemessages)
          calculates server finished message
 byte[] generateServerKeyExchange(IMyPrivateKey key, byte[] clientrandom, byte[] serverrandom)
           
 void processClientFinished(byte[] verify_data, byte[] handshakemessages)
          checks the client finished message
 void processClientKeyExchange(java.math.BigInteger dh_y)
          processes the client key exchange
 void processServerFinished(byte[] b, int len, byte[] handshakemessages)
          checks the server finished message
 void processServerKeyExchange(byte[] bytes, int bytes_offset, int bytes_len, byte[] clientrandom, byte[] serverrandom, JAPCertificate servercertificate)
          Decode the server keys and check the certificate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXKEYMATERIALLENGTH

private static final int MAXKEYMATERIALLENGTH
See Also:
Constant Field Values

CLIENTFINISHEDLABEL

private static final byte[] CLIENTFINISHEDLABEL

SERVERFINISHEDLABEL

private static final byte[] SERVERFINISHEDLABEL

KEYEXPANSION

private static final byte[] KEYEXPANSION

MASTERSECRET

private static final byte[] MASTERSECRET

SAFEPRIME

private static final java.math.BigInteger SAFEPRIME

DH_PARAMS

private static final org.bouncycastle.crypto.params.DHParameters DH_PARAMS

m_dhparams

private org.bouncycastle.crypto.params.DHParameters m_dhparams

m_dhserverpub

private org.bouncycastle.crypto.params.DHPublicKeyParameters m_dhserverpub

m_premastersecret

private byte[] m_premastersecret

m_mastersecret

private byte[] m_mastersecret

m_clientrandom

private byte[] m_clientrandom

m_serverrandom

private byte[] m_serverrandom

m_dhe

private org.bouncycastle.crypto.agreement.DHBasicAgreement m_dhe
Constructor Detail

DHE_RSA_Key_Exchange

public DHE_RSA_Key_Exchange()
Method Detail

generateServerKeyExchange

public byte[] generateServerKeyExchange(IMyPrivateKey key,
                                        byte[] clientrandom,
                                        byte[] serverrandom)
                                 throws TLSException
Specified by:
generateServerKeyExchange in class Key_Exchange
Throws:
TLSException

processServerKeyExchange

public void processServerKeyExchange(byte[] bytes,
                                     int bytes_offset,
                                     int bytes_len,
                                     byte[] clientrandom,
                                     byte[] serverrandom,
                                     JAPCertificate servercertificate)
                              throws TLSException
Description copied from class: Key_Exchange
Decode the server keys and check the certificate

Specified by:
processServerKeyExchange in class Key_Exchange
clientrandom - clientrandom
serverrandom - serverrandom
Throws:
TLSException

calculateServerFinished

public byte[] calculateServerFinished(byte[] handshakemessages)
Description copied from class: Key_Exchange
calculates server finished message

Specified by:
calculateServerFinished in class Key_Exchange
Parameters:
handshakemessages - handshakemessages
Returns:
server finished message

processServerFinished

public void processServerFinished(byte[] b,
                                  int len,
                                  byte[] handshakemessages)
                           throws TLSException
Description copied from class: Key_Exchange
checks the server finished message

Specified by:
processServerFinished in class Key_Exchange
Parameters:
b - server finished message
Throws:
TLSException

processClientKeyExchange

public void processClientKeyExchange(java.math.BigInteger dh_y)
Description copied from class: Key_Exchange
processes the client key exchange

Specified by:
processClientKeyExchange in class Key_Exchange
Parameters:
dh_y - diffie hellman parameter

calculateClientKeyExchange

public byte[] calculateClientKeyExchange()
                                  throws TLSException
Description copied from class: Key_Exchange
generates the client key exchange message (see RFC2246)

Specified by:
calculateClientKeyExchange in class Key_Exchange
Returns:
client key exchange message
Throws:
TLSException

processClientFinished

public void processClientFinished(byte[] verify_data,
                                  byte[] handshakemessages)
                           throws TLSException
Description copied from class: Key_Exchange
checks the client finished message

Specified by:
processClientFinished in class Key_Exchange
Parameters:
verify_data - verify data
handshakemessages - handshakemessages
Throws:
TLSException

calculateClientFinished

public byte[] calculateClientFinished(byte[] handshakemessages)
                               throws TLSException
Description copied from class: Key_Exchange
generate the client finished message (see RFC2246)

Specified by:
calculateClientFinished in class Key_Exchange
Parameters:
handshakemessages - all handshakemessages that have been send before this
Returns:
client finished message
Throws:
TLSException

calculateKeys

public byte[] calculateKeys()
Description copied from class: Key_Exchange
calculates the key material (see RFC2246 TLS Record Protocoll)

Specified by:
calculateKeys in class Key_Exchange
Returns:
key material