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

Side by Side Diff: chrome/renderer/extensions/enterprise_platform_keys_natives.cc

Issue 306433003: enterprise.platformKeys: Support the publicExponent parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h" 5 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
11 #include "content/public/renderer/v8_value_converter.h" 11 #include "content/public/renderer/v8_value_converter.h"
12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/WebVector.h"
15 #include "third_party/WebKit/public/web/WebCryptoNormalize.h" 16 #include "third_party/WebKit/public/web/WebCryptoNormalize.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 namespace { 20 namespace {
20 21
21 bool StringToWebCryptoOperation(const std::string& str, 22 bool StringToWebCryptoOperation(const std::string& str,
22 blink::WebCryptoOperation* op) { 23 blink::WebCryptoOperation* op) {
23 if (str == "GenerateKey") { 24 if (str == "GenerateKey") {
24 *op = blink::WebCryptoOperationGenerateKey; 25 *op = blink::WebCryptoOperationGenerateKey;
(...skipping 15 matching lines...) Expand all
40 DCHECK(!algorithm.isNull()); 41 DCHECK(!algorithm.isNull());
41 42
42 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 43 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
43 dict->SetStringWithoutPathExpansion( 44 dict->SetStringWithoutPathExpansion(
44 "name", blink::WebCryptoAlgorithm::idToName(algorithm.id())); 45 "name", blink::WebCryptoAlgorithm::idToName(algorithm.id()));
45 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen = 46 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen =
46 algorithm.rsaHashedKeyGenParams(); 47 algorithm.rsaHashedKeyGenParams();
47 if (rsaHashedKeyGen) { 48 if (rsaHashedKeyGen) {
48 dict->SetIntegerWithoutPathExpansion("modulusLength", 49 dict->SetIntegerWithoutPathExpansion("modulusLength",
49 rsaHashedKeyGen->modulusLengthBits()); 50 rsaHashedKeyGen->modulusLengthBits());
51 const blink::WebVector<unsigned char>& public_exponent =
52 rsaHashedKeyGen->publicExponent();
53 dict->SetWithoutPathExpansion(
54 "publicExponent",
55 base::BinaryValue::CreateWithCopiedBuffer(
56 reinterpret_cast<const char*>(public_exponent.data()),
57 public_exponent.size()));
50 return dict.Pass(); 58 return dict.Pass();
51 } 59 }
52 // Otherwise, |algorithm| is missing support here or no parameters were 60 // Otherwise, |algorithm| is missing support here or no parameters were
53 // required. 61 // required.
54 return dict.Pass(); 62 return dict.Pass();
55 } 63 }
56 64
57 } // namespace 65 } // namespace
58 66
59 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives( 67 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!algorithm_dict) 101 if (!algorithm_dict)
94 return; 102 return;
95 103
96 scoped_ptr<content::V8ValueConverter> converter( 104 scoped_ptr<content::V8ValueConverter> converter(
97 content::V8ValueConverter::create()); 105 content::V8ValueConverter::create());
98 call_info.GetReturnValue().Set( 106 call_info.GetReturnValue().Set(
99 converter->ToV8Value(algorithm_dict.get(), context()->v8_context())); 107 converter->ToV8Value(algorithm_dict.get(), context()->v8_context()));
100 } 108 }
101 109
102 } // namespace extensions 110 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698