Skip to content

Commit f0064c8

Browse files
committed
set kdf_key_len to correct value
Set the kdf key length to be the determined input key length. This will set it correctly for AES ICM 128/192/256. In the case of AES GCM 128 & 256 it needs to be increased by 2 to match the corresponding AES ICM cipher. fixes #763
1 parent 9035389 commit f0064c8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

srtp/srtp.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ srtp_err_status_t srtp_stream_init_keys(srtp_session_keys_t *session_keys,
12651265
session_keys->mki_id = NULL;
12661266
}
12671267

1268+
/* Find the maximum key length */
12681269
input_keylen = full_key_length(session_keys->rtp_cipher->type);
12691270
full_keylen = full_auth_key_length(session_keys->rtp_auth->type);
12701271
if (full_keylen > input_keylen) {
@@ -1296,15 +1297,19 @@ srtp_err_status_t srtp_stream_init_keys(srtp_session_keys_t *session_keys,
12961297
}
12971298

12981299
if (rtp_keylen > kdf_keylen) {
1299-
kdf_keylen = 46; /* AES-CTR mode is always used for KDF */
1300+
kdf_keylen = rtp_keylen;
13001301
}
13011302

13021303
if (rtcp_keylen > kdf_keylen) {
1303-
kdf_keylen = 46; /* AES-CTR mode is always used for KDF */
1304+
kdf_keylen = rtcp_keylen;
13041305
}
13051306

13061307
if (input_keylen > kdf_keylen) {
1307-
kdf_keylen = 46; /* AES-CTR mode is always used for KDF */
1308+
kdf_keylen = input_keylen;
1309+
}
1310+
1311+
if (kdf_keylen == SRTP_AES_GCM_128_KEY_LEN_WSALT || kdf_keylen == SRTP_AES_GCM_256_KEY_LEN_WSALT ) {
1312+
kdf_keylen += 2; /* AES-CTR mode is always used for KDF */
13081313
}
13091314

13101315
debug_print(mod_srtp, "input key len: %zu", input_keylen);

0 commit comments

Comments
 (0)