Skip to content
Snippets Groups Projects
Commit 6270d311 authored by Adrien Béraud's avatar Adrien Béraud Committed by Tristan Matthews
Browse files

srtp: generate SDES key using real random numbers

Regression from commit bebe12d4

Refs #56557

Change-Id: Iafb7d2a92e5c80d55bcae9a44d276eae5ecef44f
parent a68b4d5f
No related branches found
No related tags found
No related merge requests found
...@@ -71,42 +71,30 @@ decodeBase64(unsigned char *input, int length) ...@@ -71,42 +71,30 @@ decodeBase64(unsigned char *input, int length)
// Fills the array dest with length random bytes // Fills the array dest with length random bytes
static void static void
bufferFillMasterKey(std::vector<uint8>& dest) bufferFillMasterKey(std::vector<uint8_t>& dest)
{ {
DEBUG("Init local master key"); DEBUG("Init local master key");
std::uniform_int_distribution<uint8_t> rand_byte(0, 255);
// Prepare pseudo random generationusing Mersenne Twister
std::mt19937 eng;
std::uniform_int_distribution<uint8_t> dist(0, 255);
// Allocate memory for key
std::vector<unsigned char> random_key(dest.size());
// Fill the key // Fill the key
for (size_t i = 0; i < dest.size(); i++) {
random_key[i] = dist(eng); std::random_device rdev;
std::generate(dest.begin(), dest.end(), std::bind(rand_byte, std::ref(rdev)));
std::copy(random_key.begin(), random_key.end(), dest.begin()); }
} }
// Fills the array dest with length random bytes // Fills the array dest with length random bytes
static void static void
bufferFillMasterSalt(std::vector<uint8>& dest) bufferFillMasterSalt(std::vector<uint8_t>& dest)
{ {
DEBUG("Init local master salt"); DEBUG("Init local master salt");
std::uniform_int_distribution<uint8_t> rand_byte(0, 255);
// Prepare pseudo random generation using Mersenne Twister
std::mt19937 eng;
std::uniform_int_distribution<uint8_t> dist(0, 255);
// Allocate memory for key
std::vector<unsigned char> random_key(dest.size());
// Fill the key // Fill the key
for (size_t i = 0; i < dest.size(); i++) {
random_key[i] = dist(eng); std::random_device rdev;
std::generate(dest.begin(), dest.end(), std::bind(rand_byte, std::ref(rdev)));
std::copy(random_key.begin(), random_key.end(), dest.begin()); }
} }
static const unsigned MAX_MASTER_KEY_LENGTH = 16; static const unsigned MAX_MASTER_KEY_LENGTH = 16;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment