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

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

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback from Matt Created 4 years, 7 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
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 bool CreateRandomString(size_t len, std::string* str) { 238 bool CreateRandomString(size_t len, std::string* str) {
239 return CreateRandomString(len, kBase64, 64, str); 239 return CreateRandomString(len, kBase64, 64, str);
240 } 240 }
241 241
242 bool CreateRandomString(size_t len, const std::string& table, 242 bool CreateRandomString(size_t len, const std::string& table,
243 std::string* str) { 243 std::string* str) {
244 return CreateRandomString(len, table.c_str(), 244 return CreateRandomString(len, table.c_str(),
245 static_cast<int>(table.size()), str); 245 static_cast<int>(table.size()), str);
246 } 246 }
247 247
248 bool CreateRandomData(size_t length, void* data) {
249 return Rng().Generate(data, length);
250 }
251
248 // Version 4 UUID is of the form: 252 // Version 4 UUID is of the form:
249 // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx 253 // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
250 // Where 'x' is a hex digit, and 'y' is 8, 9, a or b. 254 // Where 'x' is a hex digit, and 'y' is 8, 9, a or b.
251 std::string CreateRandomUuid() { 255 std::string CreateRandomUuid() {
252 std::string str; 256 std::string str;
253 std::unique_ptr<uint8_t[]> bytes(new uint8_t[31]); 257 std::unique_ptr<uint8_t[]> bytes(new uint8_t[31]);
254 if (!Rng().Generate(bytes.get(), 31)) { 258 if (!Rng().Generate(bytes.get(), 31)) {
255 LOG(LS_ERROR) << "Failed to generate random string!"; 259 LOG(LS_ERROR) << "Failed to generate random string!";
256 return str; 260 return str;
257 } 261 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } while (id == 0); 303 } while (id == 0);
300 return id; 304 return id;
301 } 305 }
302 306
303 double CreateRandomDouble() { 307 double CreateRandomDouble() {
304 return CreateRandomId() / (std::numeric_limits<uint32_t>::max() + 308 return CreateRandomId() / (std::numeric_limits<uint32_t>::max() +
305 std::numeric_limits<double>::epsilon()); 309 std::numeric_limits<double>::epsilon());
306 } 310 }
307 311
308 } // namespace rtc 312 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698