David McGrew | e08c7fd | 2007-05-04 20:16:01 +0000 | [diff] [blame] | 1 | Secure RTP (SRTP) Reference Implementation |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 2 | David A. McGrew |
| 3 | Cisco Systems, Inc. |
| 4 | mcgrew@cisco.com |
| 5 | |
| 6 | |
| 7 | This package provides an implementation of the Secure Real-time |
| 8 | Transport Protocol (SRTP), the Universal Security Transform (UST), and |
| 9 | a supporting cryptographic kernel. These mechanisms are documented in |
| 10 | the Internet Drafts in the doc/ subdirectory. The SRTP API is |
| 11 | documented in include/srtp.h, and the library is in libsrtp.a (after |
David McGrew | e08c7fd | 2007-05-04 20:16:01 +0000 | [diff] [blame] | 12 | compilation). An overview and reference manual is available in |
| 13 | doc/libsrtp.pdf. The PDF documentation is more up to date than this |
| 14 | file. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 15 | |
| 16 | |
| 17 | Installation: |
| 18 | |
| 19 | ./configure [ options ] # GNU autoconf script |
| 20 | make # or gmake if needed; use GNU make |
| 21 | |
| 22 | The configure script accepts the following options: |
| 23 | |
| 24 | --help provides a usage summary |
| 25 | --disable-debug compile without the runtime debugging system |
| 26 | --enable-syslog use syslog for error reporting |
| 27 | --disable-stdout use stdout for error reporting |
| 28 | --enable-console use /dev/console for error reporting |
jfigus | 5b22e37 | 2013-05-09 09:23:26 -0400 | [diff] [blame] | 29 | --enable-openssl use OpenSSL crypto primitives |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 30 | --with-openssl-dir Specify location of OpenSSL installation |
| 31 | --enable-openssl-kdf use OpenSSL SRTP KDF algorithm |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 32 | --gdoi use GDOI key management (disabled at present) |
| 33 | |
Nicolas Kaiser | 230dde6 | 2013-12-14 09:37:54 +0100 | [diff] [blame] | 34 | By default, debugging is enabled and stdout is used for debugging. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 35 | You can use the above configure options to have the debugging output |
| 36 | sent to syslog or the system console. Alternatively, you can define |
| 37 | ERR_REPORTING_FILE in include/conf.h to be any other file that can be |
| 38 | opened by libSRTP, and debug messages will be sent to it. |
| 39 | |
| 40 | This package has been tested on Mac OS X (powerpc-apple-darwin1.4), |
| 41 | Cygwin (i686-pc-cygwin), and Sparc (sparc-sun-solaris2.6). Previous |
| 42 | versions have been tested on Linux and OpenBSD on both x86 and sparc |
| 43 | platforms. |
| 44 | |
| 45 | A quick tour of this package: |
| 46 | |
| 47 | Makefile targets: all, clean, ... |
| 48 | README this file |
| 49 | CHANGES change log |
| 50 | VERSION version number of this package |
| 51 | LICENSE legal details (it's a BSD-like license) |
| 52 | crypto/ciphers/ ciphers (null, aes_icm, ...) |
| 53 | crypto/math/ crypto math routines |
| 54 | crypto/hash/ crypto hashing (hmac, tmmhv2, ...) |
| 55 | crypto/replay/ replay protection |
| 56 | doc/ documentation: rfcs, apis, and suchlike |
| 57 | include/ include files for all code in distribution |
| 58 | srtp/ secure real-time transport protocol implementation |
| 59 | tables/ apps for generating tables (useful in porting) |
| 60 | test/ test drivers |
| 61 | |
| 62 | |
| 63 | Applications |
| 64 | |
| 65 | Several test drivers and a simple and portable srtp application |
| 66 | are included in the test/ subdirectory. |
| 67 | |
| 68 | test driver function tested |
| 69 | ------------------------------------------------------------- |
| 70 | kernel_driver crypto kernel (ciphers, auth funcs, rng) |
| 71 | srtp_driver srtp in-memory tests (does not use the network) |
| 72 | rdbx_driver rdbx (extended replay database) |
| 73 | roc_driver extended sequence number functions |
| 74 | replay_driver replay database (n.b. not used in libsrtp) |
| 75 | cipher_driver ciphers |
| 76 | auth_driver hash functions |
| 77 | |
| 78 | The app rtpw is a simple rtp application which reads words from |
| 79 | /usr/dict/words and then sends them out one at a time using [s]rtp. |
| 80 | Manual srtp keying uses the -k option; automated key management |
| 81 | using gdoi will be added later. |
| 82 | |
Christian Oien | 9e4c091 | 2014-10-29 09:11:16 +0100 | [diff] [blame] | 83 | usage: rtpw [-d <debug>]* [-k|b <key> [-a][-e <key size>][-g]] [-s | -r] dest_ip dest_port |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 84 | or rtpw -l |
| 85 | |
| 86 | Either the -s (sender) or -r (receiver) option must be chosen. |
| 87 | |
| 88 | The values dest_ip, dest_port are the ip address and udp port to |
| 89 | which the dictionary will be sent, respectively. |
| 90 | |
| 91 | options: |
| 92 | |
| 93 | -s (s)rtp sender - causes app to send words |
| 94 | |
Nicolas Kaiser | 230dde6 | 2013-12-14 09:37:54 +0100 | [diff] [blame] | 95 | -r (s)rtp receive - causes app to receive words |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 96 | |
| 97 | -k <key> use srtp master key <key>, where the |
| 98 | key is a hexadecimal value (without the |
| 99 | leading "0x") |
| 100 | |
Christian Oien | 9e4c091 | 2014-10-29 09:11:16 +0100 | [diff] [blame] | 101 | -b <key> same as -k but with base64 encoded key |
| 102 | |
jfigus | bce4f85 | 2014-03-01 22:39:57 -0500 | [diff] [blame] | 103 | -e <keysize> encrypt/decrypt (for data confidentiality) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 104 | (requires use of -k option as well) |
jfigus | bce4f85 | 2014-03-01 22:39:57 -0500 | [diff] [blame] | 105 | (use 128, 192, or 256 for keysize) |
| 106 | |
| 107 | -g use AES-GCM mode (must be used with -e) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 108 | |
| 109 | -a message authentication |
| 110 | (requires use of -k option as well) |
| 111 | |
| 112 | -l list debug modules |
| 113 | |
| 114 | -d <debug> turn on debugging for module <debug> |
jfigus | bce4f85 | 2014-03-01 22:39:57 -0500 | [diff] [blame] | 115 | -i specify input/output file |
| 116 | (instead of using dictionary file) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 117 | |
| 118 | |
| 119 | In order to get random 30-byte values for use as key/salt pairs , you |
| 120 | can use the following bash function to format the output of |
| 121 | /dev/random (where that device is available). |
| 122 | |
| 123 | function randhex() { |
| 124 | cat /dev/random | od --read-bytes=32 --width=32 -x | awk '{ print $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 }' |
| 125 | } |
| 126 | |
| 127 | |
| 128 | An example of an SRTP session using two rtpw programs follows: |
| 129 | |
| 130 | set k=c1eec3717da76195bb878578790af71c4ee9f859e197a414a78d5abc7451 |
| 131 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 132 | [sh1]$ test/rtpw -s -k $k -e 128 -a 0.0.0.0 9999 |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 133 | Security services: confidentiality message authentication |
| 134 | set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 |
| 135 | setting SSRC to 2078917053 |
| 136 | sending word: A |
| 137 | sending word: a |
| 138 | sending word: aa |
| 139 | sending word: aal |
| 140 | ... |
| 141 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 142 | [sh2]$ test/rtpw -r -k $k -e 128 -a 0.0.0.0 9999 |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 143 | security services: confidentiality message authentication |
| 144 | set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 |
| 145 | 19 octets received from SSRC 2078917053 word: A |
| 146 | 19 octets received from SSRC 2078917053 word: a |
| 147 | 20 octets received from SSRC 2078917053 word: aa |
| 148 | 21 octets received from SSRC 2078917053 word: aal |
| 149 | ... |
| 150 | |
| 151 | Implementation Notes |
| 152 | |
| 153 | * The srtp_protect() function assumes that the buffer holding the |
| 154 | rtp packet has enough storage allocated that the authentication |
| 155 | tag can be written to the end of that packet. If this assumption |
| 156 | is not valid, memory corruption will ensue. |
| 157 | |
| 158 | * Automated tests for the crypto functions are provided through |
| 159 | the cipher_type_self_test() and auth_type_self_test() functions. |
| 160 | These functions should be used to test each port of this code |
| 161 | to a new platform. |
| 162 | |
| 163 | * Replay protection is contained in the crypto engine, and |
| 164 | tests for it are provided. |
| 165 | |
| 166 | * This implementation provides calls to initialize, protect, and |
| 167 | unprotect RTP packets, and makes as few as possible assumptions |
| 168 | about how these functions will be called. For example, the |
| 169 | caller is not expected to provide packets in order (though if |
| 170 | they're called more than 65k out of sequence, synchronization |
| 171 | will be lost). |
| 172 | |
| 173 | * The sequence number in the rtp packet is used as the low 16 bits |
| 174 | of the sender's local packet index. Note that RTP will start its |
| 175 | sequence number in a random place, and the SRTP layer just jumps |
| 176 | forward to that number at its first invocation. An earlier |
| 177 | version of this library used initial sequence numbers that are |
| 178 | less than 32,768; this trick is no longer required as the |
| 179 | rdbx_estimate_index(...) function has been made smarter. |
| 180 | |
| 181 | * The replay window is 128 bits in length, and is hard-coded to this |
| 182 | value for now. |
Cullen Jennings | d778c79 | 2005-10-02 12:04:37 +0000 | [diff] [blame] | 183 | |
| 184 | |