diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-12-02 06:57:08 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-12-02 06:57:08 +0400 |
commit | b4830d65bcadfe33158f30547f960f9e4f9c1908 (patch) | |
tree | 7576da4db718df1b43cfe8ed00acf079e44c72b1 /core/src/main/jdk1.1 | |
parent | 2b4e963048e3a28e9c9b3bdc6b85dff3c97e9d41 (diff) |
updates
Diffstat (limited to 'core/src/main/jdk1.1')
-rw-r--r-- | core/src/main/jdk1.1/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/core/src/main/jdk1.1/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java b/core/src/main/jdk1.1/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java index d50c325f..af694ac9 100644 --- a/core/src/main/jdk1.1/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java +++ b/core/src/main/jdk1.1/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java @@ -6,6 +6,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; +import org.bouncycastle.crypto.Digest; import org.bouncycastle.util.Integers; class DTLSReliableHandshake @@ -14,7 +15,7 @@ class DTLSReliableHandshake private DTLSRecordLayer recordLayer; - private TlsHandshakeHash hash = new DeferredHash(); + private TlsHandshakeHash handshakeHash; private Hashtable currentInboundFlight = new Hashtable(); private Hashtable previousInboundFlight = null; @@ -26,25 +27,32 @@ class DTLSReliableHandshake DTLSReliableHandshake(TlsContext context, DTLSRecordLayer transport) { this.recordLayer = transport; - this.hash.init(context); + this.handshakeHash = new DeferredHash(); + this.handshakeHash.init(context); } void notifyHelloComplete() { - this.hash = this.hash.commit(); + this.handshakeHash = handshakeHash.notifyPRFDetermined(); } - byte[] getCurrentHash() + TlsHandshakeHash getHandshakeHash() { - TlsHandshakeHash copyOfHash = hash.fork(); - byte[] result = new byte[copyOfHash.getDigestSize()]; - copyOfHash.doFinal(result, 0); + return handshakeHash; + } + + TlsHandshakeHash prepareToFinish() + { + TlsHandshakeHash result = handshakeHash; + this.handshakeHash = handshakeHash.stopTracking(); return result; } void sendMessage(short msg_type, byte[] body) throws IOException { + TlsUtils.checkUint24(body.length); + if (!sending) { checkInboundFlight(); @@ -60,6 +68,18 @@ class DTLSReliableHandshake updateHandshakeMessagesDigest(message); } + byte[] receiveMessageBody(short msg_type) + throws IOException + { + Message message = receiveMessage(); + if (message.getType() != msg_type) + { + throw new TlsFatalAlert(AlertDescription.unexpected_message); + } + + return message.getBody(); + } + Message receiveMessage() throws IOException { @@ -276,7 +296,7 @@ class DTLSReliableHandshake void resetHandshakeMessagesDigest() { - hash.reset(); + handshakeHash.reset(); } /** @@ -324,8 +344,8 @@ class DTLSReliableHandshake TlsUtils.writeUint16(message.getSeq(), buf, 4); TlsUtils.writeUint24(0, buf, 6); TlsUtils.writeUint24(body.length, buf, 9); - hash.update(buf, 0, buf.length); - hash.update(body, 0, body.length); + handshakeHash.update(buf, 0, buf.length); + handshakeHash.update(body, 0, body.length); } return message; } @@ -394,7 +414,6 @@ class DTLSReliableHandshake static class Message { - private final int message_seq; private final short msg_type; private final byte[] body; @@ -422,7 +441,7 @@ class DTLSReliableHandshake } } - private static class RecordLayerBuffer extends ByteArrayOutputStream + static class RecordLayerBuffer extends ByteArrayOutputStream { RecordLayerBuffer(int size) { |