cisco / libsrtp

Library for SRTP (Secure Realtime Transport Protocol)
Other
1.21k stars 474 forks source link

Question about master key and session key #493

Closed devkil closed 1 year ago

devkil commented 4 years ago

Hello, I student learning about SRTP and have an assignment to study the application of SRTP on a softphone linphone. But I have a few things to ask.

  1. Generate Round Key

    srtp_err_status_t srtp_stream_init_keys(.........)
    {
    ............................
    uint8_t tmp_key[MAX_SRTP_KEY_LEN];
    unsigned char *key = master_key->key;
    ...............
    memset(tmp_key, 0x0, MAX_SRTP_KEY_LEN);
    memcpy(tmp_key, key, (rtp_base_key_len + rtp_salt_len)); 
    stat = srtp_kdf_init(&kdf, (const uint8_t *)tmp_key, kdf_keylen);

    from that function, srtp_kdf_init () function call srtp_aes_icm_context_init where in one of the stages it makes a round key for the aes process with function srtp_aes_expand_encryption_key(key, base_key_len, &c->expanded_key). The parameter used in this function is a key derived from temp_key in the srtp.c. Is it true that the round key is generated from the master key instead of the session key?

  2. In aes counter mode, the input aesprocess is keystream suffix, which is built from nonce and counter values. This keysream suffix value is generated from the process of calling the function srtp_cipher_set_iv -> srtp_aes_cm_set_iv. This value will then be performed bitwise XOR with RTP Packet payload to produce ciphertext that is ready to be sent. Then which variable holds the RTP Packet?

  3. Encryption using AES ICM the encryption process is done through the function

srtp_cipher_encrypt (session_keys-> rtp_cipher, (uint8_t *) enc_start, (unsigned int *) & enc_octet_len)

For each function call, if the AES_CM_128 crypto suites configuration is used, is it done for each data packet or for all data packet in the RTP stream? What is the size of the payload buffer that encrypted by srtp_aes_icm_encrypt ? How about the maximum size of the payload can be encrypted ?

Best Regards,

pabuhler commented 1 year ago

Hi, This is over 2 years old so I am guessing answering now would be a bit late. Sorry that it seams ot have gone unanswered previously. If this is still relevant then please reopen and we can attempt to answer the questions.