|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--de.bb.minissl.SslBase
|
+--de.bb.minissl.Ssl3
|
+--de.bb.minissl.Ssl3Server
Implements the server side handshake for SSL3. Supports an SSL2 client hello Contains all server specific function which are needed to establish an SSL3 connection.
| Field Summary | |
protected byte |
byte0
|
protected java.util.Vector |
certs
|
protected int |
cipherType
|
protected static byte[] |
client
|
protected byte[] |
clientRandom
|
protected boolean |
collect
|
protected byte[] |
head
|
protected MessageDigest |
hsMd5
|
protected MessageDigest |
hsSha
|
protected java.io.InputStream |
is
|
protected byte[] |
masterSecret
|
protected MessageDigest |
md5
|
protected static byte[] |
nullbytes
|
protected byte[] |
onebyte
|
protected java.io.OutputStream |
os
|
protected byte[] |
readBuffer
|
protected MessageDigest |
readHash
|
protected int |
readHLen
|
protected byte[] |
readkey
|
protected long |
readnum
|
protected byte[] |
readSecret
|
protected byte[] |
rhashBuffer
|
protected int |
rpos
|
protected static byte[] |
server
|
protected byte[] |
serverRandom
|
protected byte[] |
sessionId
|
protected MessageDigest |
sha
|
protected MessageDigest |
writeHash
|
protected int |
writeHLen
|
protected byte[] |
writekey
|
protected long |
writenum
|
protected byte[] |
writeSecret
|
| Constructor Summary | |
Ssl3Server()
Creates a new Ssl3Server object, which uses the given InputStream for reading and the given OutputStream for writing. |
|
| Method Summary | |
protected int |
available()
Returns the number of bytes that can be read from this input stream without blocking. |
protected byte[] |
calc_hs_hash(MessageDigest md,
int len,
byte[] sender)
calculate a handshake MAC. hash(masterSecret + pad2 + hash(handshake + sender + mastersecret + pad1)); |
protected byte[] |
calcMessageHash(MessageDigest md,
int hlen,
byte[] secret,
long seqNum,
int typ,
byte[] b)
calculate a message MAC. hash(secret + pad_2 + hash (secret + pad_1 + seq_num + typ + length + content)); this functions is synchronized since the same MessageDigest object is used for reading and writing. |
protected void |
close()
close the input and output stream |
protected void |
createKeys(boolean isServer,
int hlen)
create the key and secret material |
protected static byte[] |
doRSA(byte[] z,
byte[] n,
byte[] e)
perform an RSA encrption |
protected static boolean |
equals(byte[] a,
int ai,
byte[] b,
int bi,
int len)
compare 2 bytearrays |
protected void |
flush()
flush the output stream |
java.util.Vector |
getCertificates()
return the vector of received certificates |
int |
getCipherType()
Query the used ciphertype |
protected java.io.InputStream |
getInputStream()
Returns an input stream for this Ssl connection. |
protected java.io.OutputStream |
getOutputStream()
Returns an input stream for this Ssl connection. |
protected byte[] |
hs_read(int msgType)
Reads an array for a handshake message from input stream with blocking. |
protected void |
hs_write(byte[] b,
int msgType)
Write the array to the output stream as an handshake packet. |
void |
listen(java.io.InputStream _is,
java.io.OutputStream _os,
byte[] cert,
byte[] kn,
byte[] kf)
|
protected byte[] |
makeHashBytes(byte[] x,
int n,
byte[] ra,
byte[] readBuffer)
create some hash bytes md5(x + sha('A' + x + ra + readBuffer)) + md5(x + sha('BB' + x + ra + readBuffer)) + md5(x + sha('CCC' + x + ra + readBuffer)) + ... |
protected static void |
prepare_key(byte[] key_data_ptr,
byte[] key)
perform the rc4 key expansion |
protected boolean |
rawread(byte[] b,
int typ)
Reads into the given byte array from input stream with blocking. |
protected void |
rawwrite(byte[] b,
int typ)
Write the array to the output stream using the given packet type. |
protected static void |
rc4(byte[] buffer_ptr,
byte[] key)
perform an rc4 key encryption/decryption |
protected int |
read()
Reads one byte from input stream with blocking. |
protected int |
read(byte[] b)
Reads into the given byte array from input stream with blocking. |
protected int |
readahead()
Reads the next SSL3 block into internal buffer. |
protected void |
setStreams(java.io.InputStream i,
java.io.OutputStream o)
|
protected static void |
unzero(byte[] b)
replace all zeros with a new random value ! |
protected void |
write(byte[] b)
Writes the given byte array to the output stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final byte[] server
protected static final byte[] client
protected static final byte[] nullbytes
protected boolean collect
protected MessageDigest hsMd5
protected MessageDigest hsSha
protected long readnum
protected long writenum
protected java.util.Vector certs
protected java.io.InputStream is
protected java.io.OutputStream os
protected int cipherType
protected MessageDigest md5
protected MessageDigest sha
protected byte[] head
protected byte[] readBuffer
protected byte[] onebyte
protected int rpos
protected byte[] masterSecret
protected byte[] clientRandom
protected byte[] serverRandom
protected byte[] sessionId
protected byte[] readSecret
protected byte[] writeSecret
protected byte[] readkey
protected byte[] writekey
protected MessageDigest readHash
protected MessageDigest writeHash
protected int readHLen
protected int writeHLen
protected byte[] rhashBuffer
protected byte byte0
| Constructor Detail |
public Ssl3Server()
throws java.io.IOException
_is - the InputStream, which is used for reading#_os - the OutputStream, which is used for writingcert - is the used certificatekn - is the private key modulokf - is the private key exponentjava.io.IOException - throws an IOException if any non recoverable error occurs.| Method Detail |
public void listen(java.io.InputStream _is,
java.io.OutputStream _os,
byte[] cert,
byte[] kn,
byte[] kf)
throws java.io.IOException
protected final int read()
throws java.io.IOException
read in class de.bb.minissl.SslBasejava.io.IOException - throws an IOException if an I/O Error occurs.
protected final int read(byte[] b)
throws java.io.IOException
read in class de.bb.minissl.SslBaseb - the buffer into which the data is read.java.io.IOException - throws an IOException if an I/O Error occurs.
protected final void write(byte[] b)
throws java.io.IOException
write in class de.bb.minissl.SslBaseb - the buffer which is written.java.io.IOException - throws an IOException if an I/O Error occurs.
protected final int readahead()
throws java.io.IOException
readahead in class de.bb.minissl.SslBasejava.io.IOException - throws an IOException if an I/O Error occurs.
protected final boolean rawread(byte[] b,
int typ)
throws java.io.IOException
b - the buffer into which the data is read.typ - the type of the read packetjava.io.IOException - throws an IOException if an I/O Error occurs,
an alert is received or a type mismatch is detected.
protected final byte[] hs_read(int msgType)
throws java.io.IOException
msgType - the handshake message type of the read packetjava.io.IOException - throws an IOException if an I/O Error occurs.
protected final void rawwrite(byte[] b,
int typ)
throws java.io.IOException
b - the bytes to senttyp - the packet type of the sent packetjava.io.IOException - throws an IOException if an I/O Error occurs.
protected final void hs_write(byte[] b,
int msgType)
throws java.io.IOException
b - the bytes to sentmsgType - the handshake message type of the sent packetjava.io.IOException - throws an IOException if an I/O Error occurs.
protected final byte[] calcMessageHash(MessageDigest md,
int hlen,
byte[] secret,
long seqNum,
int typ,
byte[] b)
md - the MessageDigest which is used to caclulate the MAChlen - length for the given hashsecret - the secret for this MAC (see formula)seqNum - the sequence Number for this MAC (see formula)typ - the packet type for this MAC (see formula)b - the message content for this MAC (see formula)
protected final byte[] makeHashBytes(byte[] x,
int n,
byte[] ra,
byte[] readBuffer)
n - the number of needed hash bytesx - an input parameter(see formula)ra - an input parameter(see formula)readBuffer - an input parameter(see formula)
protected final byte[] calc_hs_hash(MessageDigest md,
int len,
byte[] sender)
md - the MessageDigest which is used to caclulate the MAClen - the count of pad_x bytes (see formula)sender - the sender of this message (see formula)
protected final void createKeys(boolean isServer,
int hlen)
isServer - indicates whether they are generated for a server or a clienthlen - length for the new hash
protected void close()
throws java.io.IOException
de.bb.minissl.SslBaseclose in class de.bb.minissl.SslBase
protected void setStreams(java.io.InputStream i,
java.io.OutputStream o)
public final int getCipherType()
protected final java.io.InputStream getInputStream()
protected final java.io.OutputStream getOutputStream()
public final java.util.Vector getCertificates()
protected final void flush()
throws java.io.IOException
protected final int available()
throws java.io.IOException
java.io.IOException - throws an IOException if an I/O Error occurs.protected static final void unzero(byte[] b)
b - a byte array wherein all zeros are replaced by non zero random values
protected static final boolean equals(byte[] a,
int ai,
byte[] b,
int bi,
int len)
a - first byte arrayai - offset into first byte arrayb - second byte arraybi - offset into second byte arraylen - the count of bytes to compare
protected static final void rc4(byte[] buffer_ptr,
byte[] key)
buffer_ptr - the input/output datakey - the byte array for the key (key.length == 258)
protected static final void prepare_key(byte[] key_data_ptr,
byte[] key)
key_data_ptr - the input data for the keykey - the byte array for the key (key.length == 258)
protected static final byte[] doRSA(byte[] z,
byte[] n,
byte[] e)
z - the data to encrypt/decryptn - the moduloe - the exponent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||