Re: [recon-devel] allocate memory for srtp_protect
Looks more or less right - but you need to add 12 bytes not 4.
Here is the comment from the srtp.h header file for srtp_protect:
* @warning This function assumes that it can write the authentication
* tag into the location in memory immediately following the RTP
* packet, and assumes that the RTP packet is aligned on a 32-bit
* boundary.
There is a define in the srtp code for how many bytes that need to be
available at the end of the buffer:
/**
* SRTP_MAX_TRAILER_LEN is the maximum length of the SRTP trailer
* (authentication tag and MKI) supported by libSRTP. This value is
* the maximum number of octets that will be added to an RTP packet by
* srtp_protect().
*
* @brief the maximum number of octets added by srtp_protect().
*/
#define SRTP_MAX_TAG_LEN 12
#define SRTP_MAX_TRAILER_LEN SRTP_MAX_TAG_LEN
Note: There is full documentation at the libSrtp website:
http://srtp.sourceforge.net/srtp.html
Scott
2009/1/20 Karlsson <boost.regex@xxxxxxxxx>:
> Hi, if I got a RTP packet want to crypto it before sending, do I need to
> allocate 4 byte memory for this RTP packet to allows srtp write "tag" ?
>
> Likes:
>
> RTPPacket packet;
> int length = packet.getLegth(); // length = rtp header length + rtp paylaod
> length
>
> unsigned char srtpPacket * = new char[length+4];
> memcpy(srtpPacket, &packet.getData(), length);
>
> srtp_protect(mSRTPSessionOut, srtpPacket, &length);
>
> Does this code is right ?
>
> Sorry for my simple question, I'm new to SRTP :)
>
> Thanks
>
> _______________________________________________
> recon-devel mailing list
> recon-devel@xxxxxxxxxxxxxxx
> List Archive: http://list.resiprocate.org/archive/recon-devel/
>