tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SsrcGenerator.cpp (630B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "jsep/SsrcGenerator.h"
      6 
      7 #include "pk11pub.h"
      8 
      9 namespace mozilla {
     10 
     11 bool SsrcGenerator::GenerateSsrc(uint32_t* ssrc) {
     12  do {
     13    SECStatus rv = PK11_GenerateRandom(reinterpret_cast<unsigned char*>(ssrc),
     14                                       sizeof(uint32_t));
     15    if (rv != SECSuccess) {
     16      return false;
     17    }
     18  } while (mSsrcs.count(*ssrc));
     19  mSsrcs.insert(*ssrc);
     20 
     21  return true;
     22 }
     23 }  // namespace mozilla