Commit Graph

20 Commits

Author SHA1 Message Date
Mike Jerris 3bcf5b7ff8 FS-9785: upgrade libsrtp to 2.1 2017-06-26 14:14:36 -05:00
Michael Jerris a99f06dfc6 sync changes from srtp upstream 2014-07-08 10:26:08 -04:00
jfigus 024162cfc9 Add support for 16-byte auth tag for AES GCM mode. 2014-06-30 19:18:20 +00:00
Travis Cross aa4261d11f Avoid buffer-overflow on short RTCP/SRTCP packets
In `srtp_unprotect_rtcp()` we are not validating that the packet
length is as long as the minimum required.  This would cause
`enc_octet_len` to underflow, which would cause us to try to decrypt
data past the end of the packet in memory -- a buffer over-read and
buffer overflow.

In `srtp_protect_rtcp()`, we were similarly not validating the packet
length.  Here we were also polluting the address of the SRTCP
encrypted flag and index (the `trailer`), causing us to write one word
to a bogus memory address before getting to the encryption where we
would also overflow.

In this commit we add checks to appropriately validate the RTCP/SRTCP
packet lengths.

`srtp_unprotect_rtcp_aead()` (but not protect) did correctly validate
the packet length; this check would now be redundant as the check in
`srtcp_unprotect_rtcp()` will also run first, so it has been removed.
2014-06-30 19:00:35 +00:00
Travis Cross 9ea93c4c50 Avoid buffer over-read on null cipher AEAD
In the defined AEAD modes, SRTP packets must always be encrypted and
authenticated, but SRTCP packets may be only authenticated.  It's
possible, therefore, for us to end up in `srtp_protect_aead()` without
the `sec_serv_conf` bit being set.  We should just ignore this and
encrypt the RTP packet anyway.

What we are doing instead is encrypting the packet anyway, but setting
`enc_start` to NULL first.  This causes `aad_len` to underflow which
will cause us to over-read in `cipher_set_aad()`.

If we could get past that, we would try to read and write memory
starting at 0x0 down in `cipher_encrypt()`.

This commit causes us to not check the `sec_serv_conf` bit and never
set `enc_start` to NULL in `srtp_protect_aead()`.

`srtp_unprotect_aead()` does not contain a similar error.
2014-06-30 19:00:35 +00:00
Travis Cross 3bf2b9af75 Prevent buffer overflow from untrusted RTP/SRTP lengths
When computing the start address of the RTP data to encrypt or SRTP
data to decrypt (`enc_start`), we are using `hdr->cc` (the CSRC
count), which is untrusted data from the packet, and the length field
of an RTP header extension, which is also untrusted and unchecked data
from the packet.

This value then pollutes our calculation of how much data we'll be
encrypting or decrypting (`enc_octet_len`), possibly causing us to
underflow.

We'll then call `cipher_encrypt()` or `cipher_decrypt()` with these
two values, causing us to read from and write to arbitrary addresses
in memory.

(In the AEAD functions, we'd also pollute `aad_len`, which would cause
us to read undefined memory in `cipher_set_aad`.)

This commit adds checks to verify that the `enc_start` we calculate is
sane based on the actual packet length.
2014-06-30 19:00:35 +00:00
Dmitry Sobinov 80e203442a - fixed read of memory out of 'seq' variable bounds
- fixed AEAD IV calculation for big-endian machines
2014-04-08 16:13:52 +00:00
jfigus a31491d5b6 This commit resolves issue #46. The GCM mode was using the wrong master SALT length. The master SALT should be 96 bits instead of 112 bits. Note, GCM mode uses the legacy CTR mode for the KDF. The legagacy CTR mode cipher implementations assume a 112 bit SALT. Changes to the cipher abstraction layer API are required to provide the ability to specify the SALT length. For now this commit modifies the SRTP layer to ensure the SALT is zero-appended before initializing the KDF. This commit also provides public definitions for the GCM cipher suite master key sizes to avoid confusion for application developers. 2014-04-08 15:25:39 +00:00
Seven Du 4fd93b0e67 Revert "fix compiler warning vs2010" - Jeff is faster than I
This reverts commit fa9217117a.
2014-02-25 14:24:34 +08:00
Seven Du fa9217117a fix compiler warning vs2010 2014-02-25 14:17:28 +08:00
Michael Jerris 80c7eb85e6 update libsrtp to use openssl 2014-02-24 09:52:25 -05:00
Jeff Lenk 998b656799 remove some _MSC_VER stuff 2014-01-31 12:35:55 -06:00
Michael Jerris 91eb5b237d update srtp to master part 1 2014-01-30 16:55:56 -05:00
Anthony Minessale d3872b3a7b add diffs from 8884f4d 8e47faf @ https://github.com/cisco/libsrtp 2014-01-11 03:46:13 +05:00
Jeff Lenk fd7d5e0801 windows compiler fixes - now builds again 2013-04-03 21:55:50 -05:00
Jeff Lenk d627f7c23d windows compiler warnings 2013-04-01 17:09:37 -05:00
Anthony Minessale 72e2d183c1 update to cvs head srtp 2013-03-31 21:27:19 -05:00
Michael Jerris 8761a73997 change around types for better c99 compliance, fixes windows srtp build and builds that do not default to 8 bit stuct alignment.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3797 d0543943-73ff-0310-b7d9-9358b9ac24b2
2006-12-22 19:02:10 +00:00
Michael Jerris abda472017 srtp msvc updates and cleanup
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1087 d0543943-73ff-0310-b7d9-9358b9ac24b2
2006-04-07 16:34:02 +00:00
Anthony Minessale b3d890ef25 add srtp
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1086 d0543943-73ff-0310-b7d9-9358b9ac24b2
2006-04-07 16:10:03 +00:00