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

Unified Diff: chrome/renderer/extensions/platform_keys_natives.cc

Issue 884073002: Implement chrome.platformKeys.getKeyPair(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_impl2
Patch Set: Rebased. Created 5 years, 11 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: chrome/renderer/extensions/platform_keys_natives.cc
diff --git a/chrome/renderer/extensions/platform_keys_natives.cc b/chrome/renderer/extensions/platform_keys_natives.cc
index 779b9091c9e324c85689fa3666fc5b489a4ee26c..7af7f11bbcfd7aa71e15c59617fda99e937e27f2 100644
--- a/chrome/renderer/extensions/platform_keys_natives.cc
+++ b/chrome/renderer/extensions/platform_keys_natives.cc
@@ -25,6 +25,10 @@ bool StringToWebCryptoOperation(const std::string& str,
*op = blink::WebCryptoOperationGenerateKey;
return true;
}
+ if (str == "ImportKey") {
+ *op = blink::WebCryptoOperationImportKey;
+ return true;
+ }
if (str == "Sign") {
*op = blink::WebCryptoOperationSign;
return true;
@@ -44,6 +48,9 @@ scoped_ptr<base::DictionaryValue> WebCryptoAlgorithmToBaseValue(
const blink::WebCryptoAlgorithmInfo* info =
blink::WebCryptoAlgorithm::lookupAlgorithmInfo(algorithm.id());
dict->SetStringWithoutPathExpansion("name", info->name);
+
+ const blink::WebCryptoAlgorithm* hash = nullptr;
+
const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen =
algorithm.rsaHashedKeyGenParams();
if (rsaHashedKeyGen) {
@@ -57,10 +64,20 @@ scoped_ptr<base::DictionaryValue> WebCryptoAlgorithmToBaseValue(
reinterpret_cast<const char*>(public_exponent.data()),
public_exponent.size()));
- const blink::WebCryptoAlgorithm& hash = rsaHashedKeyGen->hash();
- DCHECK(!hash.isNull());
+ hash = &rsaHashedKeyGen->hash();
+ DCHECK(!hash->isNull());
+ }
+
+ const blink::WebCryptoRsaHashedImportParams* rsaHashedImport =
+ algorithm.rsaHashedImportParams();
+ if (rsaHashedImport) {
+ hash = &rsaHashedImport->hash();
+ DCHECK(!hash->isNull());
+ }
+
+ if (hash) {
const blink::WebCryptoAlgorithmInfo* hash_info =
- blink::WebCryptoAlgorithm::lookupAlgorithmInfo(hash.id());
+ blink::WebCryptoAlgorithm::lookupAlgorithmInfo(hash->id());
scoped_ptr<base::DictionaryValue> hash_dict(new base::DictionaryValue);
hash_dict->SetStringWithoutPathExpansion("name", hash_info->name);

Powered by Google App Engine
This is Rietveld 408576698