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); |