Skip to content
Snippets Groups Projects
Commit a1cb7546 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#1722] Test static keys

parent 91b6a76d
No related branches found
No related tags found
No related merge requests found
...@@ -111,11 +111,13 @@ void AudioSrtpSession::initializeLocalMasterKey(void) ...@@ -111,11 +111,13 @@ void AudioSrtpSession::initializeLocalMasterKey(void)
if((err = RAND_bytes(random_key, _localMasterKeyLength)) != 1) if((err = RAND_bytes(random_key, _localMasterKeyLength)) != 1)
_debug("Error occured while generating cryptographically strong pseudo-random key"); _debug("Error occured while generating cryptographically strong pseudo-random key");
// memcpy(_localMasterKey, mk, _localMasterKeyLength); memcpy(_localMasterKey, mk, _localMasterKeyLength);
printf("Local Master: ");
for(int i = 0; i < _localMasterKeyLength; i++){ for(int i = 0; i < _localMasterKeyLength; i++){
_localMasterKey[i] = mk[i]; printf("%d", _localMasterKey[i]);
} }
printf("\n");
return; return;
} }
...@@ -133,11 +135,13 @@ void AudioSrtpSession::initializeLocalMasterSalt(void) ...@@ -133,11 +135,13 @@ void AudioSrtpSession::initializeLocalMasterSalt(void)
if((err = RAND_bytes(random_key, _localMasterSaltLength)) != 1) if((err = RAND_bytes(random_key, _localMasterSaltLength)) != 1)
_debug("Error occured while generating cryptographically strong pseudo-random key"); _debug("Error occured while generating cryptographically strong pseudo-random key");
// memcpy(_localMasterSalt, ms, _localMasterSaltLength); memcpy(_localMasterSalt, ms, _localMasterSaltLength);
printf("Local Salt: ");
for(int i = 0; i < _localMasterSaltLength; i++){ for(int i = 0; i < _localMasterSaltLength; i++){
_localMasterSalt[i] = ms[i]; printf("%d", _localMasterSalt[i]);
} }
printf("\n");
return; return;
...@@ -168,6 +172,9 @@ std::string AudioSrtpSession::getBase64ConcatenatedKeys() ...@@ -168,6 +172,9 @@ std::string AudioSrtpSession::getBase64ConcatenatedKeys()
void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys) void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys)
{ {
_remoteMasterKeyLength = 16;
_remoteMasterSaltLength = 14;
// length of decoded data data // length of decoded data data
int length; int length;
...@@ -178,8 +185,20 @@ void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys) ...@@ -178,8 +185,20 @@ void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys)
char *output = decodeBase64((unsigned char*)dataptr, strlen(dataptr), &length); char *output = decodeBase64((unsigned char*)dataptr, strlen(dataptr), &length);
// copy master and slt respectively // copy master and slt respectively
memcpy((void*)_remoteMasterKey, (void*)output, 16); memcpy((void*)_remoteMasterKey, (void*)output, _remoteMasterKeyLength);
memcpy((void*)_remoteMasterSalt, (void*)(output + 16), 16); memcpy((void*)_remoteMasterSalt, (void*)(output + _remoteMasterKeyLength), _remoteMasterSaltLength);
printf("Remote Master: ");
for(int i = 0; i < _remoteMasterKeyLength; i++){
printf("%d", _remoteMasterKey[i]);
}
printf("\n");
printf("Remote Salt: ");
for(int i = 0; i < _remoteMasterSaltLength; i++){
printf("%d", _remoteMasterSalt[i]);
}
printf("\n");
free(output); free(output);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment