Go to the documentation of this file.
46 for (
i = 0, outpos = 0; outpos < outlen;
i++) {
47 uint8_t keystream[16];
50 for (j = 0; j < 16 && outpos < outlen; j++, outpos++)
51 outbuf[outpos] ^= keystream[j];
56 uint8_t *
out,
int outlen)
58 uint8_t
input[16] = { 0 };
59 memcpy(
input, salt, 14);
61 input[14 - 7] ^= label;
62 memset(
out, 0, outlen);
74 if (!strcmp(
suite,
"AES_CM_128_HMAC_SHA1_80") ||
75 !strcmp(
suite,
"SRTP_AES128_CM_HMAC_SHA1_80")) {
76 s->rtp_hmac_size =
s->rtcp_hmac_size = 10;
77 }
else if (!strcmp(
suite,
"AES_CM_128_HMAC_SHA1_32")) {
78 s->rtp_hmac_size =
s->rtcp_hmac_size = 4;
79 }
else if (!strcmp(
suite,
"SRTP_AES128_CM_HMAC_SHA1_32")) {
82 s->rtcp_hmac_size = 10;
95 if (!
s->aes || !
s->hmac)
97 memcpy(
s->master_key, buf, 16);
98 memcpy(
s->master_salt, buf + 16, 14);
103 derive_key(
s->aes,
s->master_salt, 0x00,
s->rtp_key,
sizeof(
s->rtp_key));
104 derive_key(
s->aes,
s->master_salt, 0x02,
s->rtp_salt,
sizeof(
s->rtp_salt));
105 derive_key(
s->aes,
s->master_salt, 0x01,
s->rtp_auth,
sizeof(
s->rtp_auth));
107 derive_key(
s->aes,
s->master_salt, 0x03,
s->rtcp_key,
sizeof(
s->rtcp_key));
108 derive_key(
s->aes,
s->master_salt, 0x05,
s->rtcp_salt,
sizeof(
s->rtcp_salt));
109 derive_key(
s->aes,
s->master_salt, 0x04,
s->rtcp_auth,
sizeof(
s->rtcp_auth));
121 for (
i = 0;
i < 8;
i++)
122 iv[6 +
i] ^= indexbuf[
i];
123 for (
i = 0;
i < 14;
i++)
129 uint8_t iv[16] = { 0 }, hmac[20];
142 hmac_size = rtcp ?
s->rtcp_hmac_size :
s->rtp_hmac_size;
148 av_hmac_init(
s->hmac, rtcp ?
s->rtcp_auth :
s->rtp_auth,
sizeof(
s->rtp_auth));
158 seq_largest =
s->seq_initialized ?
s->seq_largest : seq;
160 if (seq_largest < 32768) {
161 if (seq - seq_largest > 32768)
164 if (seq_largest - 32768 > seq)
168 seq_largest =
FFMAX(seq_largest, seq);
169 }
else if (v == roc + 1) {
173 index = seq + (((uint64_t)v) << 16);
180 if (memcmp(hmac, buf +
len - hmac_size, hmac_size)) {
192 uint32_t srtcp_index =
AV_RB32(buf +
len - 4);
197 index = srtcp_index & 0x7fffffff;
201 if (!(srtcp_index & 0x80000000))
205 s->seq_initialized = 1;
206 s->seq_largest = seq_largest;
209 csrc = buf[0] & 0x0f;
224 ext = (
AV_RB16(buf + 2) + 1) * 4;
240 uint8_t *
out,
int outlen)
242 uint8_t iv[16] = { 0 }, hmac[20];
245 int rtcp, hmac_size, padding;
252 hmac_size = rtcp ?
s->rtcp_hmac_size :
s->rtp_hmac_size;
257 if (
len + padding > outlen)
278 if (seq < s->seq_largest)
280 s->seq_largest = seq;
281 index = seq + (((uint64_t)
s->roc) << 16);
283 csrc = buf[0] & 0x0f;
297 ext = (
AV_RB16(buf + 2) + 1) * 4;
314 av_hmac_init(
s->hmac, rtcp ?
s->rtcp_auth :
s->rtp_auth,
sizeof(
s->rtp_auth));
323 memcpy(buf +
len, hmac, hmac_size);
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_hmac_final(AVHMAC *c, uint8_t *out, unsigned int outlen)
Finish hashing and output the HMAC digest.
int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
int ff_srtp_encrypt(struct SRTPContext *s, const uint8_t *in, int len, uint8_t *out, int outlen)
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
void av_hmac_update(AVHMAC *c, const uint8_t *data, unsigned int len)
Hash data with the HMAC.
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test suite
#define RTP_PT_IS_RTCP(x)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void ff_srtp_free(struct SRTPContext *s)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
AVHMAC * av_hmac_alloc(enum AVHMACType type)
Allocate an AVHMAC context.
void av_hmac_free(AVHMAC *c)
Free an AVHMAC context.
#define i(width, name, range_min, range_max)
void av_hmac_init(AVHMAC *c, const uint8_t *key, unsigned int keylen)
Initialize an AVHMAC context with an authentication key.
int ff_srtp_set_crypto(struct SRTPContext *s, const char *suite, const char *params)
static void create_iv(uint8_t *iv, const uint8_t *salt, uint64_t index, uint32_t ssrc)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void encrypt_counter(struct AVAES *aes, uint8_t *iv, uint8_t *outbuf, int outlen)
static void derive_key(struct AVAES *aes, const uint8_t *salt, int label, uint8_t *out, int outlen)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16