libsrtp icon indicating copy to clipboard operation
libsrtp copied to clipboard

Question about master key and session key

Open devkil opened this issue 4 years ago • 0 comments

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?

  1. In aes counter mode, the input aes process 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?

  2. 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,

devkil avatar Jun 02 '20 16:06 devkil