void SendTLSRecord(TLSRecord record, bool bAppend) { if (SocketClient.ShowDebug == true) { record.DebugDump(false); } if (bAppend == true) { AllHandShakeMessages.AppendData(record.Content); if (SocketClient.ShowDebug == true) { System.Diagnostics.Debug.WriteLine("AllHandShakeMessages Length is now {0}", AllHandShakeMessages.Size); } } else { } /// Encrypt the record if we are in that state byte[] bEncryptedGenericBlockCipher = state.CompressEncryptOutgoingData(record); byte[] bSend = record.GetBytesWithEncryptedContent(bEncryptedGenericBlockCipher); Client.Send(bSend, bSend.Length, false); }
void BuildAndSendApplicationRecords(byte [] bData) { int nLengthRemaining = bData.Length; int nAt = 0; while (nLengthRemaining > 0) { int nLengthToSend = ((bData.Length - nAt) > TLSRecord.MaxUncompressedRecordSize) ? TLSRecord.MaxUncompressedRecordSize : bData.Length - nAt; TLSApplicationMessage msg = new TLSApplicationMessage(); msg.ApplicationData = new byte[nLengthToSend]; Array.Copy(bData, nAt, msg.ApplicationData, 0, nLengthToSend); TLSRecord record = new TLSRecord(); record.ContentType = TLSContentType.Application; record.Messages.Add(msg); /// Encrypt the record if we are in that state byte[] bEncryptedGenericBlockCipher = state.CompressEncryptOutgoingData(record); byte[] bSend = record.GetBytesWithEncryptedContent(bEncryptedGenericBlockCipher); /// Leave this to the higer layer to send, though we could send it here Client.Send(bSend, bSend.Length, false); nAt += nLengthToSend; nLengthRemaining -= nLengthToSend; } }