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

Unified Diff: crypto/symmetric_key_win.cc

Issue 6683060: Private API for extensions like ssh-client that need access to TCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c Created 9 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 side-by-side diff with in-line comments
Download patch
« crypto/symmetric_key.h ('K') | « crypto/symmetric_key_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/symmetric_key_win.cc
diff --git a/crypto/symmetric_key_win.cc b/crypto/symmetric_key_win.cc
index d2034e0304c7bc163ef67704aa90a6a851fae261..1168f312c0cb216e2f6695cee3978bb125af2fd3 100644
--- a/crypto/symmetric_key_win.cc
+++ b/crypto/symmetric_key_win.cc
@@ -312,6 +312,26 @@ SymmetricKey::~SymmetricKey() {
}
// static
+bool SymmetricKey::GenerateRandomBytes(size_t num_bytes, uint8* out) {
+ if (num_bytes == 0)
+ return true;
+ if (out == NULL)
+ return false;
+
+ ScopedHCRYPTPROV provider;
+ // See comment in GenerateAESKey as to why NULL is acceptable for the
+ // container name.
+ if (!CryptAcquireContext(
+ provider.receive(), NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
+ return false;
+ }
+ if (CryptGenRandom(provider, num_bytes, out))
+ return true;
+ else
+ return false;
+}
+
+// static
SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm,
size_t key_size_in_bits) {
DCHECK_GE(key_size_in_bits, 8);
« crypto/symmetric_key.h ('K') | « crypto/symmetric_key_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698