anon.tor
Class OnionRouter

java.lang.Object
  extended by anon.tor.OnionRouter

public class OnionRouter
extends java.lang.Object

Author:
stefan

Field Summary
private static org.bouncycastle.crypto.params.DHParameters DH_PARAMS
           
private  int m_circID
           
private  MyAES m_decryptionEngine
           
private  ORDescription m_description
           
private  org.bouncycastle.crypto.agreement.DHBasicAgreement m_dhe
           
private  org.bouncycastle.crypto.digests.SHA1Digest m_digestDb
           
private  org.bouncycastle.crypto.digests.SHA1Digest m_digestDf
           
private  MyAES m_encryptionEngine
           
private  boolean m_extended
           
private  OnionRouter m_nextOR
           
private static java.math.BigInteger MAXKEY
           
private static java.math.BigInteger MINKEY
           
private static java.math.BigInteger SAFEPRIME
           
 
Constructor Summary
OnionRouter(int circID, ORDescription description)
          Constructor
 
Method Summary
 boolean checkCreatedCell(Cell cell)
          checks the created cell if the answer was right
 boolean checkExtendedCell(RelayCell cell)
          checks if the extendedcell has the right parameters and hash
private  void checkExtendParameters(byte[] param, int offset, int len)
          checks the parameters of a extend cell and calculate the secrets
 CreateCell createConnection()
          create cell this cell is needed to connect to the first OR.
private  byte[] createExtendOnionSkin()
          creates the onion skin for a create or extend cell
 RelayCell decryptCell(RelayCell cell)
          decrypts a RelayCell
 RelayCell encryptCell(RelayCell cell)
          encrypts a RelayCell
 RelayCell extendConnection(ORDescription description)
          extends the connction to another OR and encrypts the data
private  RelayCell extendConnection(java.lang.String address, int port)
          extends the connection to another OR
 ORDescription getDescription()
          returns a description of this router
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAFEPRIME

private static final java.math.BigInteger SAFEPRIME

MINKEY

private static final java.math.BigInteger MINKEY

MAXKEY

private static final java.math.BigInteger MAXKEY

DH_PARAMS

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

m_description

private ORDescription m_description

m_dhe

private org.bouncycastle.crypto.agreement.DHBasicAgreement m_dhe

m_encryptionEngine

private MyAES m_encryptionEngine

m_decryptionEngine

private MyAES m_decryptionEngine

m_nextOR

private OnionRouter m_nextOR

m_circID

private int m_circID

m_digestDf

private org.bouncycastle.crypto.digests.SHA1Digest m_digestDf

m_digestDb

private org.bouncycastle.crypto.digests.SHA1Digest m_digestDb

m_extended

private boolean m_extended
Constructor Detail

OnionRouter

public OnionRouter(int circID,
                   ORDescription description)
            throws java.io.IOException
Constructor

Parameters:
circID - circID of the circuit where it is used
description - ORDescription of the onionrouter
Throws:
java.io.IOException
Method Detail

getDescription

public ORDescription getDescription()
returns a description of this router

Returns:
ORDescription

encryptCell

public RelayCell encryptCell(RelayCell cell)
                      throws java.lang.Exception
encrypts a RelayCell

Parameters:
cell - unencrypted cell
Returns:
encrypted cell
Throws:
java.lang.Exception

decryptCell

public RelayCell decryptCell(RelayCell cell)
                      throws java.lang.Exception
decrypts a RelayCell

Parameters:
cell - encrypted cell
Returns:
decrypted cell
Throws:
java.lang.Exception

createConnection

public CreateCell createConnection()
                            throws java.lang.Exception
create cell this cell is needed to connect to the first OR. after the connection is established extendConnection is used

Returns:
createCell
Throws:
java.lang.Exception

checkCreatedCell

public boolean checkCreatedCell(Cell cell)
checks the created cell if the answer was right

Parameters:
cell - createdcell
Throws:
java.lang.Exception

extendConnection

private RelayCell extendConnection(java.lang.String address,
                                   int port)
                            throws java.io.IOException,
                                   org.bouncycastle.crypto.InvalidCipherTextException,
                                   java.lang.Exception
extends the connection to another OR

Parameters:
address - address of the OR
port - port
Returns:
RelayCell with the data that is needed to connect to the new OR
Throws:
java.io.IOException
org.bouncycastle.crypto.InvalidCipherTextException
java.lang.Exception

extendConnection

public RelayCell extendConnection(ORDescription description)
                           throws java.io.IOException,
                                  org.bouncycastle.crypto.InvalidCipherTextException,
                                  java.lang.Exception
extends the connction to another OR and encrypts the data

Parameters:
description - ORDescription
Returns:
cell that is needed to extend the connection
Throws:
java.io.IOException
org.bouncycastle.crypto.InvalidCipherTextException
java.lang.Exception

checkExtendedCell

public boolean checkExtendedCell(RelayCell cell)
checks if the extendedcell has the right parameters and hash

Parameters:
cell - cell
Throws:
java.lang.Exception

createExtendOnionSkin

private byte[] createExtendOnionSkin()
                              throws java.io.IOException,
                                     org.bouncycastle.crypto.InvalidCipherTextException,
                                     java.lang.Exception
creates the onion skin for a create or extend cell

Returns:
payload
Throws:
java.io.IOException
org.bouncycastle.crypto.InvalidCipherTextException
java.lang.Exception

checkExtendParameters

private void checkExtendParameters(byte[] param,
                                   int offset,
                                   int len)
                            throws java.lang.Exception
checks the parameters of a extend cell and calculate the secrets

Parameters:
param - parameters
offset - offset of the parameters
len - length of the parameters
Throws:
java.lang.Exception