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

Unified Diff: content/child/webcrypto/openssl/sym_key_openssl.cc

Issue 512023002: Refactor the interface for generating keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a new return type "GenerateKeyPairResult" to encapsulate secretkey vs keypair Created 6 years, 3 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
Index: content/child/webcrypto/openssl/sym_key_openssl.cc
diff --git a/content/child/webcrypto/openssl/sym_key_openssl.cc b/content/child/webcrypto/openssl/sym_key_openssl.cc
index e07db69ee7f3f6e96feb5cdcfe34913da8f0f908..21af6831c4f6efc8f4f53cb87105789e9d031339 100644
--- a/content/child/webcrypto/openssl/sym_key_openssl.cc
+++ b/content/child/webcrypto/openssl/sym_key_openssl.cc
@@ -8,6 +8,7 @@
#include <openssl/rand.h>
#include "content/child/webcrypto/crypto_data.h"
+#include "content/child/webcrypto/generate_key_result.h"
#include "content/child/webcrypto/openssl/key_openssl.h"
#include "content/child/webcrypto/status.h"
#include "crypto/openssl_util.h"
@@ -21,7 +22,7 @@ Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
unsigned keylen_bytes,
- blink::WebCryptoKey* key) {
+ GenerateKeyResult* result) {
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
std::vector<unsigned char> random_bytes(keylen_bytes, 0);
@@ -31,7 +32,8 @@ Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm,
return Status::OperationError();
}
- *key =
+ result->set_type(GenerateKeyResult::TYPE_SECRET_KEY);
+ *result->mutable_secret_key() =
blink::WebCryptoKey::create(new SymKeyOpenSsl(CryptoData(random_bytes)),
blink::WebCryptoKeyTypeSecret,
extractable,

Powered by Google App Engine
This is Rietveld 408576698