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 "components/webcrypto/jwk.h" | 5 #include "components/webcrypto/jwk.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 // Creates a JWK key_ops list from a Web Crypto usage mask. | 92 // Creates a JWK key_ops list from a Web Crypto usage mask. |
93 scoped_ptr<base::ListValue> CreateJwkKeyOpsFromWebCryptoUsages( | 93 scoped_ptr<base::ListValue> CreateJwkKeyOpsFromWebCryptoUsages( |
94 blink::WebCryptoKeyUsageMask usages) { | 94 blink::WebCryptoKeyUsageMask usages) { |
95 scoped_ptr<base::ListValue> jwk_key_ops(new base::ListValue()); | 95 scoped_ptr<base::ListValue> jwk_key_ops(new base::ListValue()); |
96 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { | 96 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { |
97 if (usages & kJwkWebCryptoUsageMap[i].webcrypto_usage) | 97 if (usages & kJwkWebCryptoUsageMap[i].webcrypto_usage) |
98 jwk_key_ops->AppendString(kJwkWebCryptoUsageMap[i].jwk_key_op); | 98 jwk_key_ops->AppendString(kJwkWebCryptoUsageMap[i].jwk_key_op); |
99 } | 99 } |
100 return jwk_key_ops.Pass(); | 100 return jwk_key_ops; |
101 } | 101 } |
102 | 102 |
103 // Composes a Web Crypto usage mask from an array of JWK key_ops values. | 103 // Composes a Web Crypto usage mask from an array of JWK key_ops values. |
104 Status GetWebCryptoUsagesFromJwkKeyOps(const base::ListValue* key_ops, | 104 Status GetWebCryptoUsagesFromJwkKeyOps(const base::ListValue* key_ops, |
105 blink::WebCryptoKeyUsageMask* usages) { | 105 blink::WebCryptoKeyUsageMask* usages) { |
106 // This set keeps track of all unrecognized key_ops values. | 106 // This set keeps track of all unrecognized key_ops values. |
107 std::set<std::string> unrecognized_usages; | 107 std::set<std::string> unrecognized_usages; |
108 | 108 |
109 *usages = 0; | 109 *usages = 0; |
110 for (size_t i = 0; i < key_ops->GetSize(); ++i) { | 110 for (size_t i = 0; i < key_ops->GetSize(); ++i) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 utf8_bytes->assign(json.begin(), json.end()); | 382 utf8_bytes->assign(json.begin(), json.end()); |
383 } | 383 } |
384 | 384 |
385 Status GetWebCryptoUsagesFromJwkKeyOpsForTest( | 385 Status GetWebCryptoUsagesFromJwkKeyOpsForTest( |
386 const base::ListValue* key_ops, | 386 const base::ListValue* key_ops, |
387 blink::WebCryptoKeyUsageMask* usages) { | 387 blink::WebCryptoKeyUsageMask* usages) { |
388 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages); | 388 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages); |
389 } | 389 } |
390 | 390 |
391 } // namespace webcrypto | 391 } // namespace webcrypto |
OLD | NEW |