Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: webrtc/base/helpers.cc

Issue 2115123002: Remove NSS SecureRandomGenerator. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class SecureRandomGenerator : public RandomGenerator { 49 class SecureRandomGenerator : public RandomGenerator {
50 public: 50 public:
51 SecureRandomGenerator() {} 51 SecureRandomGenerator() {}
52 ~SecureRandomGenerator() override {} 52 ~SecureRandomGenerator() override {}
53 bool Init(const void* seed, size_t len) override { return true; } 53 bool Init(const void* seed, size_t len) override { return true; }
54 bool Generate(void* buf, size_t len) override { 54 bool Generate(void* buf, size_t len) override {
55 return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0); 55 return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0);
56 } 56 }
57 }; 57 };
58 58
59 #elif defined(SSL_USE_NSS_RNG)
60 // The NSS RNG.
61 class SecureRandomGenerator : public RandomGenerator {
62 public:
63 SecureRandomGenerator() {}
64 ~SecureRandomGenerator() override {}
65 bool Init(const void* seed, size_t len) override { return true; }
66 bool Generate(void* buf, size_t len) override {
67 return (PK11_GenerateRandom(reinterpret_cast<unsigned char*>(buf),
68 static_cast<int>(len)) == SECSuccess);
69 }
70 };
71
72 #else 59 #else
73 #if defined(WEBRTC_WIN) 60 #if defined(WEBRTC_WIN)
74 class SecureRandomGenerator : public RandomGenerator { 61 class SecureRandomGenerator : public RandomGenerator {
75 public: 62 public:
76 SecureRandomGenerator() : advapi32_(NULL), rtl_gen_random_(NULL) {} 63 SecureRandomGenerator() : advapi32_(NULL), rtl_gen_random_(NULL) {}
77 ~SecureRandomGenerator() { 64 ~SecureRandomGenerator() {
78 FreeLibrary(advapi32_); 65 FreeLibrary(advapi32_);
79 } 66 }
80 67
81 virtual bool Init(const void* seed, size_t seed_len) { 68 virtual bool Init(const void* seed, size_t seed_len) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } while (id == 0); 286 } while (id == 0);
300 return id; 287 return id;
301 } 288 }
302 289
303 double CreateRandomDouble() { 290 double CreateRandomDouble() {
304 return CreateRandomId() / (std::numeric_limits<uint32_t>::max() + 291 return CreateRandomId() / (std::numeric_limits<uint32_t>::max() +
305 std::numeric_limits<double>::epsilon()); 292 std::numeric_limits<double>::epsilon());
306 } 293 }
307 294
308 } // namespace rtc 295 } // namespace rtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698