Added buffer length when calling encrypt/decrypt. Write the extra two bytes.
Replacing http://review.webrtc.org/893004/. BUG=934 TEST=Run ViE Autotest Encryption with Valgrind. Review URL: https://webrtc-codereview.appspot.com/901006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2938 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
443df96c8e
commit
34e83b8e8d
@ -38,7 +38,10 @@ public:
|
|||||||
{
|
{
|
||||||
out_data[i] = ~in_data[i];
|
out_data[i] = ~in_data[i];
|
||||||
}
|
}
|
||||||
|
assert(*bytes_out >= bytes_in + 2);
|
||||||
*bytes_out = bytes_in + 2;
|
*bytes_out = bytes_in + 2;
|
||||||
|
out_data[bytes_in] = 'a';
|
||||||
|
out_data[bytes_in + 1] = 'b';
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void decrypt(int channel_no, unsigned char* in_data,
|
virtual void decrypt(int channel_no, unsigned char* in_data,
|
||||||
@ -48,6 +51,7 @@ public:
|
|||||||
{
|
{
|
||||||
out_data[i] = ~in_data[i];
|
out_data[i] = ~in_data[i];
|
||||||
}
|
}
|
||||||
|
assert(*bytes_out >= bytes_in - 2);
|
||||||
*bytes_out = bytes_in - 2;
|
*bytes_out = bytes_in - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +63,10 @@ public:
|
|||||||
{
|
{
|
||||||
out_data[i] = ~in_data[i];
|
out_data[i] = ~in_data[i];
|
||||||
}
|
}
|
||||||
|
assert(*bytes_out >= bytes_in + 2);
|
||||||
*bytes_out = bytes_in + 2;
|
*bytes_out = bytes_in + 2;
|
||||||
|
out_data[bytes_in] = 'a';
|
||||||
|
out_data[bytes_in + 1] = 'b';
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void decrypt_rtcp(int channel_no, unsigned char* in_data,
|
virtual void decrypt_rtcp(int channel_no, unsigned char* in_data,
|
||||||
@ -70,6 +77,7 @@ public:
|
|||||||
{
|
{
|
||||||
out_data[i] = ~in_data[i];
|
out_data[i] = ~in_data[i];
|
||||||
}
|
}
|
||||||
|
assert(*bytes_out >= bytes_in - 2);
|
||||||
*bytes_out = bytes_in - 2;
|
*bytes_out = bytes_in - 2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -164,7 +164,7 @@ int ViEReceiver::InsertRTPPacket(const WebRtc_Word8* rtp_packet,
|
|||||||
CriticalSectionScoped cs(receive_cs_.get());
|
CriticalSectionScoped cs(receive_cs_.get());
|
||||||
|
|
||||||
if (external_decryption_) {
|
if (external_decryption_) {
|
||||||
int decrypted_length = 0;
|
int decrypted_length = kViEMaxMtu;
|
||||||
external_decryption_->decrypt(channel_id_, received_packet,
|
external_decryption_->decrypt(channel_id_, received_packet,
|
||||||
decryption_buffer_, received_packet_length,
|
decryption_buffer_, received_packet_length,
|
||||||
&decrypted_length);
|
&decrypted_length);
|
||||||
@ -202,7 +202,7 @@ int ViEReceiver::InsertRTCPPacket(const WebRtc_Word8* rtcp_packet,
|
|||||||
CriticalSectionScoped cs(receive_cs_.get());
|
CriticalSectionScoped cs(receive_cs_.get());
|
||||||
|
|
||||||
if (external_decryption_) {
|
if (external_decryption_) {
|
||||||
int decrypted_length = 0;
|
int decrypted_length = kViEMaxMtu;
|
||||||
external_decryption_->decrypt_rtcp(channel_id_, received_packet,
|
external_decryption_->decrypt_rtcp(channel_id_, received_packet,
|
||||||
decryption_buffer_,
|
decryption_buffer_,
|
||||||
received_packet_length,
|
received_packet_length,
|
||||||
|
@ -137,6 +137,8 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) {
|
|||||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||||
void* tmp_ptr = const_cast<void*>(data);
|
void* tmp_ptr = const_cast<void*>(data);
|
||||||
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
||||||
|
|
||||||
|
// Data length for packets sent to possible encryption and to the transport.
|
||||||
int send_packet_length = len;
|
int send_packet_length = len;
|
||||||
|
|
||||||
if (rtp_dump_) {
|
if (rtp_dump_) {
|
||||||
@ -144,10 +146,13 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (external_encryption_) {
|
if (external_encryption_) {
|
||||||
external_encryption_->encrypt(channel_id_, send_packet,
|
// Encryption buffer size.
|
||||||
encryption_buffer_, send_packet_length,
|
int encrypted_packet_length = kViEMaxMtu;
|
||||||
static_cast<int*>(&send_packet_length));
|
|
||||||
|
external_encryption_->encrypt(channel_id_, send_packet, encryption_buffer_,
|
||||||
|
send_packet_length, &encrypted_packet_length);
|
||||||
send_packet = encryption_buffer_;
|
send_packet = encryption_buffer_;
|
||||||
|
send_packet_length = encrypted_packet_length;
|
||||||
}
|
}
|
||||||
const int bytes_sent = transport_->SendPacket(channel_id_, send_packet,
|
const int bytes_sent = transport_->SendPacket(channel_id_, send_packet,
|
||||||
send_packet_length);
|
send_packet_length);
|
||||||
@ -171,6 +176,8 @@ int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) {
|
|||||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||||
void* tmp_ptr = const_cast<void*>(data);
|
void* tmp_ptr = const_cast<void*>(data);
|
||||||
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
||||||
|
|
||||||
|
// Data length for packets sent to possible encryption and to the transport.
|
||||||
int send_packet_length = len;
|
int send_packet_length = len;
|
||||||
|
|
||||||
if (rtp_dump_) {
|
if (rtp_dump_) {
|
||||||
@ -178,10 +185,14 @@ int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (external_encryption_) {
|
if (external_encryption_) {
|
||||||
|
// Encryption buffer size.
|
||||||
|
int encrypted_packet_length = kViEMaxMtu;
|
||||||
|
|
||||||
external_encryption_->encrypt_rtcp(
|
external_encryption_->encrypt_rtcp(
|
||||||
channel_id_, send_packet, encryption_buffer_, send_packet_length,
|
channel_id_, send_packet, encryption_buffer_, send_packet_length,
|
||||||
static_cast<int*>(&send_packet_length));
|
&encrypted_packet_length);
|
||||||
send_packet = encryption_buffer_;
|
send_packet = encryption_buffer_;
|
||||||
|
send_packet_length = encrypted_packet_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int bytes_sent = transport_->SendRTCPPacket(channel_id_, send_packet,
|
const int bytes_sent = transport_->SendRTCPPacket(channel_id_, send_packet,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user