private UpdateHandshakeData ( byte message, int offset, int len ) : void | ||
message | byte | |
offset | int | |
len | int | |
Результат | void |
private void ProcessHandshake() { bool read; do { read = false; /* * We need the first 4 bytes, they contain type and length of * the message. */ if (handshakeQueue.Available >= 4) { byte[] beginning = new byte[4]; handshakeQueue.Read(beginning, 0, 4, 0); MemoryStream bis = new MemoryStream(beginning, false); short type = TlsUtilities.ReadUint8(bis); int len = TlsUtilities.ReadUint24(bis); /* * Check if we have enough bytes in the buffer to read * the full message. */ if (handshakeQueue.Available >= (len + 4)) { /* * Read the message. */ byte[] buf = new byte[len]; handshakeQueue.Read(buf, 0, len, 4); handshakeQueue.RemoveData(len + 4); /* * RFC 2246 7.4.9. "The value handshake_messages includes all * handshake messages starting at client hello up to, but not * including, this finished message. [..] Note: [Also,] Hello Request * messages are omitted from handshake hashes." */ switch (type) { case HP_HELLO_REQUEST: case HP_FINISHED: break; default: rs.UpdateHandshakeData(beginning, 0, 4); rs.UpdateHandshakeData(buf, 0, len); break; } /* * Now, parse the message. */ ProcessHandshakeMessage(type, buf); read = true; } } }while (read); }
private void ProcessHandshake() { bool flag; do { flag = false; if (mHandshakeQueue.Available >= 4) { byte[] array = new byte[4]; mHandshakeQueue.Read(array, 0, 4, 0); byte b = TlsUtilities.ReadUint8(array, 0); int num = TlsUtilities.ReadUint24(array, 1); if (mHandshakeQueue.Available >= num + 4) { byte[] array2 = mHandshakeQueue.RemoveData(num, 4); CheckReceivedChangeCipherSpec(mConnectionState == 16 || b == 20); switch (b) { default: { TlsContext context = Context; if (b == 20 && mExpectedVerifyData == null && context.SecurityParameters.MasterSecret != null) { mExpectedVerifyData = CreateVerifyData(!context.IsServer); } mRecordStream.UpdateHandshakeData(array, 0, 4); mRecordStream.UpdateHandshakeData(array2, 0, num); break; } case 0: break; } HandleHandshakeMessage(b, array2); flag = true; } } }while (flag); }