MCPcopy Create free account
hub / github.com/SIPp/sipp / deriveSessionEncryptionKey

Method deriveSessionEncryptionKey

src/jlsrtp.cpp:1378–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1376}
1377
1378int JLSRTP::deriveSessionEncryptionKey()
1379{
1380 std::vector<unsigned char> input_vector; // Input vector (built from applicable keyid_XXXs)
1381 std::vector<unsigned char> keyid_encryption;
1382 unsigned int saltSize = 0;
1383 int retVal = -1;
1384
1385 switch (_active_crypto)
1386 {
1387 case PRIMARY_CRYPTO:
1388 {
1389 saltSize = _primary_crypto.master_salt.size();
1390 assert(saltSize == JLSRTP_SALTING_KEY_LENGTH);
1391 if (saltSize == JLSRTP_SALTING_KEY_LENGTH)
1392 {
1393 input_vector.clear();
1394
1395 keyid_encryption.clear();
1396 keyid_encryption.resize(7);
1397 keyid_encryption.push_back(JLSRTP_KEY_ENCRYPTION_LABEL);
1398 keyid_encryption.push_back(0x00);
1399 keyid_encryption.push_back(0x00);
1400 keyid_encryption.push_back(0x00);
1401 keyid_encryption.push_back(0x00);
1402 keyid_encryption.push_back(0x00);
1403 keyid_encryption.push_back(0x00);
1404
1405 xorVector(keyid_encryption, _primary_crypto.master_salt, input_vector);
1406
1407 retVal = pseudorandomFunction(input_vector, 128, _session_enc_key);
1408 }
1409 else
1410 {
1411 retVal = -1;
1412 }
1413 }
1414 break;
1415
1416 case SECONDARY_CRYPTO:
1417 {
1418 saltSize = _secondary_crypto.master_salt.size();
1419 assert(saltSize == JLSRTP_SALTING_KEY_LENGTH);
1420 if (saltSize == JLSRTP_SALTING_KEY_LENGTH)
1421 {
1422 input_vector.clear();
1423
1424 keyid_encryption.clear();
1425 keyid_encryption.resize(7);
1426 keyid_encryption.push_back(JLSRTP_KEY_ENCRYPTION_LABEL);
1427 keyid_encryption.push_back(0x00);
1428 keyid_encryption.push_back(0x00);
1429 keyid_encryption.push_back(0x00);
1430 keyid_encryption.push_back(0x00);
1431 keyid_encryption.push_back(0x00);
1432 keyid_encryption.push_back(0x00);
1433
1434 xorVector(keyid_encryption, _secondary_crypto.master_salt, input_vector);
1435

Callers 1

executeActionMethod · 0.80

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected