README 6.7 KB

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