diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-06-24 15:17:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-06-24 15:17:27 +0700 |
commit | a0c220585584564fac843c8ffb2834c953c93f03 (patch) | |
tree | f6f633c2b1872a2cf07593734a128cc00e3dd95f | |
parent | 9b0e6058a3a5b3116e58dad65069ff881d4b597a (diff) | |
download | android_external_spongycastle-a0c220585584564fac843c8ffb2834c953c93f03.tar.gz android_external_spongycastle-a0c220585584564fac843c8ffb2834c953c93f03.tar.bz2 android_external_spongycastle-a0c220585584564fac843c8ffb2834c953c93f03.zip |
Refactor to use receiveMessageBody when expected type known
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/tls/DTLSServerProtocol.java | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/DTLSServerProtocol.java b/core/src/main/java/org/bouncycastle/crypto/tls/DTLSServerProtocol.java index b05120e52..d0ed9e9ab 100644 --- a/core/src/main/java/org/bouncycastle/crypto/tls/DTLSServerProtocol.java +++ b/core/src/main/java/org/bouncycastle/crypto/tls/DTLSServerProtocol.java @@ -248,32 +248,14 @@ public class DTLSServerProtocol if (expectCertificateVerifyMessage(state)) { byte[] certificateVerifyHash = handshake.getCurrentHash(); - clientMessage = handshake.receiveMessage(); - - if (clientMessage.getType() == HandshakeType.certificate_verify) - { - processCertificateVerify(state, clientMessage.getBody(), certificateVerifyHash); - } - else - { - throw new TlsFatalAlert(AlertDescription.unexpected_message); - } + byte[] certificateVerifyBody = handshake.receiveMessageBody(HandshakeType.certificate_verify); + processCertificateVerify(state, certificateVerifyBody, certificateVerifyHash); } // NOTE: Calculated exclusive of the actual Finished message from the client - byte[] clientFinishedHash = handshake.getCurrentHash(); - clientMessage = handshake.receiveMessage(); - - if (clientMessage.getType() == HandshakeType.finished) - { - byte[] expectedClientVerifyData = TlsUtils.calculateVerifyData(state.serverContext, "client finished", - clientFinishedHash); - processFinished(clientMessage.getBody(), expectedClientVerifyData); - } - else - { - throw new TlsFatalAlert(AlertDescription.unexpected_message); - } + byte[] expectedClientVerifyData = TlsUtils.calculateVerifyData(state.serverContext, "client finished", + handshake.getCurrentHash()); + processFinished(handshake.receiveMessageBody(HandshakeType.finished), expectedClientVerifyData); if (state.expectSessionTicket) { |