OLD | NEW |
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 std::string AlgorithmIdToName(blink::WebCryptoAlgorithmId id) { | 22 std::string AlgorithmIdToName(blink::WebCryptoAlgorithmId id) { |
22 switch (id) { | 23 switch (id) { |
23 case blink::WebCryptoAlgorithmIdHmac: | 24 case blink::WebCryptoAlgorithmIdHmac: |
24 return "HMAC"; | 25 return "HMAC"; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 DCHECK(!algorithm.isNull()); | 70 DCHECK(!algorithm.isNull()); |
70 | 71 |
71 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 72 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
72 dict->SetStringWithoutPathExpansion("name", | 73 dict->SetStringWithoutPathExpansion("name", |
73 AlgorithmIdToName(algorithm.id())); | 74 AlgorithmIdToName(algorithm.id())); |
74 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen = | 75 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen = |
75 algorithm.rsaHashedKeyGenParams(); | 76 algorithm.rsaHashedKeyGenParams(); |
76 if (rsaHashedKeyGen) { | 77 if (rsaHashedKeyGen) { |
77 dict->SetIntegerWithoutPathExpansion("modulusLength", | 78 dict->SetIntegerWithoutPathExpansion("modulusLength", |
78 rsaHashedKeyGen->modulusLengthBits()); | 79 rsaHashedKeyGen->modulusLengthBits()); |
| 80 const blink::WebVector<unsigned char>& public_exponent = |
| 81 rsaHashedKeyGen->publicExponent(); |
| 82 dict->SetWithoutPathExpansion( |
| 83 "publicExponent", |
| 84 base::BinaryValue::CreateWithCopiedBuffer( |
| 85 reinterpret_cast<const char*>(public_exponent.data()), |
| 86 public_exponent.size())); |
79 return dict.Pass(); | 87 return dict.Pass(); |
80 } | 88 } |
81 // Otherwise, |algorithm| is missing support here or no parameters were | 89 // Otherwise, |algorithm| is missing support here or no parameters were |
82 // required. | 90 // required. |
83 return dict.Pass(); | 91 return dict.Pass(); |
84 } | 92 } |
85 | 93 |
86 } // namespace | 94 } // namespace |
87 | 95 |
88 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives( | 96 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (!algorithm_dict) | 130 if (!algorithm_dict) |
123 return; | 131 return; |
124 | 132 |
125 scoped_ptr<content::V8ValueConverter> converter( | 133 scoped_ptr<content::V8ValueConverter> converter( |
126 content::V8ValueConverter::create()); | 134 content::V8ValueConverter::create()); |
127 call_info.GetReturnValue().Set( | 135 call_info.GetReturnValue().Set( |
128 converter->ToV8Value(algorithm_dict.get(), context()->v8_context())); | 136 converter->ToV8Value(algorithm_dict.get(), context()->v8_context())); |
129 } | 137 } |
130 | 138 |
131 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |