📄 intro.txt
字号:
(requires use of -k option as well) \\ -l & list the avaliable debug modules \\ -d $<$debug$>$ & turn on debugging for module $<$debug$>$ \\\end{tabular}\end{center}In order to get a random 30-byte value for use as a key/salt pair, youcan use the \texttt{rand\_gen} utility in the \texttt{test/}subdirectory.An example of an SRTP session using two rtpw programs follows:\begin{verbatim}[sh1] set k=`test/rand_gen -n 30`[sh1] echo $kc1eec3717da76195bb878578790af71c4ee9f859e197a414a78d5abc7451[sh1]$ test/rtpw -s -k $k -ea 0.0.0.0 9999 Security services: confidentiality message authenticationset master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451setting SSRC to 2078917053sending word: Asending word: asending word: aasending word: aalsending word: aaliisending word: aamsending word: Aanisending word: aardvark...[sh2] set k=c1eec3717da76195bb878578790af71c4ee9f859e197a414a78d5abc7451[sh2]$ test/rtpw -r -k $k -ea 0.0.0.0 9999 security services: confidentiality message authenticationset master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC745119 octets received from SSRC 2078917053 word: A19 octets received from SSRC 2078917053 word: a20 octets received from SSRC 2078917053 word: aa21 octets received from SSRC 2078917053 word: aal...\end{verbatim}@endlatexonly@section Review Secure RTP BackgroundIn this section we review SRTP and introduce some terms that are usedin libSRTP. An RTP session is defined by a pair of destinationtransport addresses, that is, a network address plus a pair of UDPports for RTP and RTCP. RTCP, the RTP control protocol, is used tocoordinate between the participants in an RTP session, e.g. to providefeedback from receivers to senders. An @e SRTP @e session issimilarly defined; it is just an RTP session for which the SRTPprofile is being used. An SRTP session consists of the traffic sentto the SRTP or SRTCP destination transport addresses. Eachparticipant in a session is identified by a synchronization source(SSRC) identifier. Some participants may not send any SRTP traffic;they are called receivers, even though they send out SRTCP traffic,such as receiver reports.RTP allows multiple sources to send RTP and RTCP traffic during thesame session. The synchronization source identifier (SSRC) is used todistinguish these sources. In libSRTP, we call the SRTP and SRTCPtraffic from a particular source a @e stream. Each stream has its ownSSRC, sequence number, rollover counter, and other data. A particularchoice of options, cryptographic mechanisms, and keys is called a @epolicy. Each stream within a session can have a distinct policyapplied to it. A session policy is a collection of stream policies.A single policy can be used for all of the streams in a given session,though the case in which a single @e key is shared across multiplestreams requires care. When key sharing is used, the SSRC values thatidentify the streams @b must be distinct. This requirement can beenforced by using the convention that each SRTP and SRTCP key is usedfor encryption by only a single sender. In other words, the key isshared only across streams that originate from a particular device (ofcourse, other SRTP participants will need to use the key fordecryption). libSRTP supports this enforcement by detecting the casein which a key is used for both inbound and outbound data.@section Overview libSRTP OverviewlibSRTP provides functions for protecting RTP and RTCP. RTP packetscan be encrypted and authenticated (using the srtp_protect()function), turning them into SRTP packets. Similarly, SRTP packetscan be decrypted and have their authentication verified (using thesrtp_unprotect() function), turning them into RTP packets. Similarfunctions apply security to RTCP packets.The typedef srtp_stream_t points to a structure holding all of thestate associated with an SRTP stream, including the keys andparameters for cipher and message authentication functions and theanti-replay data. A particular srtp_stream_t holds the informationneeded to protect a particular RTP and RTCP stream. This datatypeis intentionally opaque in order to better seperate the libSRTPAPI from its implementation.Within an SRTP session, there can be multiple streams, eachoriginating from a particular sender. Each source uses a distinctstream context to protect the RTP and RTCP stream that it isoriginating. The typedef srtp_t points to a structure holding all ofthe state associated with an SRTP session. There can be multiplestream contexts associated with a single srtp_t. A stream contextcannot exist indepent from an srtp_t, though of course an srtp_t canbe created that contains only a single stream context. A deviceparticipating in an SRTP session must have a stream context for eachsource in that session, so that it can process the data that itreceives from each sender.In libSRTP, a session is created using the function srtp_create().The policy to be implemented in the session is passed into thisfunction as an srtp_policy_t structure. A single one of thesestructures describes the policy of a single stream. These structurescan also be linked together to form an entire session policy. A linkedlist of srtp_policy_t structures is equivalent to a session policy. In such a policy, we refer to a single srtp_policy_t as an @e element.An srtp_policy_t strucutre contains two crypto_policy_t structuresthat describe the cryptograhic policies for RTP and RTCP, as well asthe SRTP master key and the SSRC value. The SSRC describes what toprotect (e.g. which stream), and the crypto_policy_t structuresdescribe how to protect it. The key is contained in a policy elementbecause it simplifies the interface to the library. In many cases, itis desirable to use the same cryptographic policies across all of thestreams in a session, but to use a distinct key for each stream. Acrypto_policy_t structure can be initialized by using either thecrypto_policy_set_rtp_default() or crypto_policy_set_rtcp_default()functions, which set a crypto policy structure to the default policiesfor RTP and RTCP protection, respectively. @section Example Example CodeThis section provides a simple example of how to use libSRTP. Theexample code lacks error checking, but is functional. Here we assumethat the value ssrc is already set to describe the SSRC of the streamthat we are sending, and that the functions get_rtp_packet() andsend_srtp_packet() are available to us. The former puts an RTP packetinto the buffer and returns the number of octets written to thatbuffer. The latter sends the RTP packet in the buffer, given thelength as its second argument.@verbatim srtp_t session; srtp_policy_t policy; uint8_t key[30]; // initialize libSRTP srtp_init(); // set policy to describe a policy for an SRTP stream crypto_policy_set_rtp_default(&policy.rtp); crypto_policy_set_rtcp_default(&policy.rtcp); policy.ssrc = ssrc; policy.key = key; policy.next = NULL; // set key to random value crypto_get_random(key, 30); // allocate and initialize the SRTP session srtp_create(&session, policy); // main loop: get rtp packets, send srtp packets while (1) { char rtp_buffer[2048]; unsigned len; len = get_rtp_packet(rtp_buffer); srtp_protect(session, rtp_buffer, &len); send_srtp_packet(rtp_buffer, len); }@endverbatim@section ISMAcryp ISMA Encryption SupportThe Internet Streaming Media Alliance (ISMA) specifies a way to pre-encrypt a media file prior to streaming. This methodis an alternative to SRTP encryption, which is potentiallyuseful when a particular media file will be streamedmultiple times. The specification is available online at http://www.isma.tv/specreq.nsf/SpecRequest.libSRTP provides the encryption and decryption functions needed for ISMAcrypin the library @t libaesicm.a, which is included in the defaultMakefile target. This library is used by the MPEG4IP project; see http://mpeg4ip.sourceforge.net/.Note that ISMAcryp does not provide authentication for RTP nor RTCP, nor confidentiality for RTCP. ISMAcryp RECOMMENDS the use of SRTP message authentication for ISMAcrypstreams while using ISMAcryp encryption to protect the media itself. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -