Bug 1952706 - Exporting key material takes not SRTP_MAX_KEY_LENGTH but the actual size a=pascalc

Original Revision: https://phabricator.services.mozilla.com/D240788

Differential Revision: https://phabricator.services.mozilla.com/D241186
This commit is contained in:
Anna Weine 2025-03-13 10:42:44 +00:00
parent 72855d5669
commit a6e538102e

View file

@ -124,7 +124,7 @@ void TransportLayerSrtp::StateChange(TransportLayer* layer, State state) {
MOZ_ASSERT(master_key_size <= SRTP_MAX_KEY_LENGTH);
// SRTP Key Exporter as per RFC 5764 S 4.2
unsigned char srtp_block[SRTP_MAX_KEY_LENGTH * 2];
unsigned char srtp_block[master_key_size * 2];
res = dtls->ExportKeyingMaterial(kDTLSExporterLabel, false, "", srtp_block,
sizeof(srtp_block));
if (NS_FAILED(res)) {
@ -134,8 +134,8 @@ void TransportLayerSrtp::StateChange(TransportLayer* layer, State state) {
}
// Slice and dice as per RFC 5764 S 4.2
unsigned char client_write_key[SRTP_MAX_KEY_LENGTH];
unsigned char server_write_key[SRTP_MAX_KEY_LENGTH];
unsigned char client_write_key[master_key_size];
unsigned char server_write_key[master_key_size];
unsigned int offset = 0;
memcpy(client_write_key, srtp_block + offset, key_size);
offset += key_size;