Go to the documentation of this file.
45 for (
i = 0, outpos = 0; outpos < outlen;
i++) {
46 uint8_t keystream[16];
49 for (j = 0; j < 16 && outpos < outlen; j++, outpos++)
50 outbuf[outpos] ^= keystream[j];
55 uint8_t *
out,
int outlen)
57 uint8_t
input[16] = { 0 };
58 memcpy(
input, salt, 14);
60 input[14 - 7] ^= label;
61 memset(
out, 0, outlen);
73 if (!strcmp(
suite,
"AES_CM_128_HMAC_SHA1_80") ||
74 !strcmp(
suite,
"SRTP_AES128_CM_HMAC_SHA1_80")) {
75 s->rtp_hmac_size =
s->rtcp_hmac_size = 10;
76 }
else if (!strcmp(
suite,
"AES_CM_128_HMAC_SHA1_32")) {
77 s->rtp_hmac_size =
s->rtcp_hmac_size = 4;
78 }
else if (!strcmp(
suite,
"SRTP_AES128_CM_HMAC_SHA1_32")) {
81 s->rtcp_hmac_size = 10;
94 if (!
s->aes || !
s->hmac)
96 memcpy(
s->master_key, buf, 16);
97 memcpy(
s->master_salt, buf + 16, 14);
102 derive_key(
s->aes,
s->master_salt, 0x00,
s->rtp_key,
sizeof(
s->rtp_key));
103 derive_key(
s->aes,
s->master_salt, 0x02,
s->rtp_salt,
sizeof(
s->rtp_salt));
104 derive_key(
s->aes,
s->master_salt, 0x01,
s->rtp_auth,
sizeof(
s->rtp_auth));
106 derive_key(
s->aes,
s->master_salt, 0x03,
s->rtcp_key,
sizeof(
s->rtcp_key));
107 derive_key(
s->aes,
s->master_salt, 0x05,
s->rtcp_salt,
sizeof(
s->rtcp_salt));
108 derive_key(
s->aes,
s->master_salt, 0x04,
s->rtcp_auth,
sizeof(
s->rtcp_auth));
120 for (
i = 0;
i < 8;
i++)
121 iv[6 +
i] ^= indexbuf[
i];
122 for (
i = 0;
i < 14;
i++)
128 uint8_t iv[16] = { 0 }, hmac[20];
141 hmac_size = rtcp ?
s->rtcp_hmac_size :
s->rtp_hmac_size;
147 av_hmac_init(
s->hmac, rtcp ?
s->rtcp_auth :
s->rtp_auth,
sizeof(
s->rtp_auth));
157 seq_largest =
s->seq_initialized ?
s->seq_largest : seq;
159 if (seq_largest < 32768) {
160 if (seq - seq_largest > 32768)
163 if (seq_largest - 32768 > seq)
167 seq_largest =
FFMAX(seq_largest, seq);
168 }
else if (v == roc + 1) {
172 index = seq + (((uint64_t)v) << 16);
179 if (memcmp(hmac, buf +
len - hmac_size, hmac_size)) {
191 uint32_t srtcp_index =
AV_RB32(buf +
len - 4);
196 index = srtcp_index & 0x7fffffff;
200 if (!(srtcp_index & 0x80000000))
204 s->seq_initialized = 1;
205 s->seq_largest = seq_largest;
208 csrc = buf[0] & 0x0f;
223 ext = (
AV_RB16(buf + 2) + 1) * 4;
239 uint8_t *
out,
int outlen)
241 uint8_t iv[16] = { 0 }, hmac[20];
244 int rtcp, hmac_size, padding;
251 hmac_size = rtcp ?
s->rtcp_hmac_size :
s->rtp_hmac_size;
256 if (
len + padding > outlen)
277 if (seq < s->seq_largest)
279 s->seq_largest = seq;
280 index = seq + (((uint64_t)
s->roc) << 16);
282 csrc = buf[0] & 0x0f;
296 ext = (
AV_RB16(buf + 2) + 1) * 4;
313 av_hmac_init(
s->hmac, rtcp ?
s->rtcp_auth :
s->rtp_auth,
sizeof(
s->rtp_auth));
322 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