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

Side by Side Diff: content/child/webcrypto/webcrypto_util.cc

Issue 308183003: [webcrypto] Don't fail JWK import if key_ops contains an unrecognized value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « content/child/webcrypto/shared_crypto_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/child/webcrypto/webcrypto_util.h" 5 #include "content/child/webcrypto/webcrypto_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/child/webcrypto/status.h" 10 #include "content/child/webcrypto/status.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 Status GetWebCryptoUsagesFromJwkKeyOps( 96 Status GetWebCryptoUsagesFromJwkKeyOps(
97 const base::ListValue* jwk_key_ops_value, 97 const base::ListValue* jwk_key_ops_value,
98 blink::WebCryptoKeyUsageMask* usage_mask) { 98 blink::WebCryptoKeyUsageMask* usage_mask) {
99 *usage_mask = 0; 99 *usage_mask = 0;
100 for (size_t i = 0; i < jwk_key_ops_value->GetSize(); ++i) { 100 for (size_t i = 0; i < jwk_key_ops_value->GetSize(); ++i) {
101 std::string key_op; 101 std::string key_op;
102 if (!jwk_key_ops_value->GetString(i, &key_op)) { 102 if (!jwk_key_ops_value->GetString(i, &key_op)) {
103 return Status::ErrorJwkPropertyWrongType( 103 return Status::ErrorJwkPropertyWrongType(
104 base::StringPrintf("key_ops[%d]", static_cast<int>(i)), "string"); 104 base::StringPrintf("key_ops[%d]", static_cast<int>(i)), "string");
105 } 105 }
106 if (!JwkKeyOpToWebCryptoUsage(key_op, usage_mask)) 106 // Unrecognized key_ops are silently skipped.
107 return Status::ErrorJwkUnrecognizedKeyop(); 107 ignore_result(JwkKeyOpToWebCryptoUsage(key_op, usage_mask));
108 } 108 }
109 return Status::Success(); 109 return Status::Success();
110 } 110 }
111 111
112 // Composes a JWK key_ops List from a Web Crypto usage mask. 112 // Composes a JWK key_ops List from a Web Crypto usage mask.
113 // Note: Caller must assume ownership of returned instance. 113 // Note: Caller must assume ownership of returned instance.
114 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( 114 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages(
115 blink::WebCryptoKeyUsageMask usage_mask) { 115 blink::WebCryptoKeyUsageMask usage_mask) {
116 base::ListValue* jwk_key_ops = new base::ListValue(); 116 base::ListValue* jwk_key_ops = new base::ListValue();
117 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { 117 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) { 199 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) {
200 // TODO(padolph): include all other asymmetric algorithms once they are 200 // TODO(padolph): include all other asymmetric algorithms once they are
201 // defined, e.g. EC and DH. 201 // defined, e.g. EC and DH.
202 return IsAlgorithmRsa(alg_id); 202 return IsAlgorithmRsa(alg_id);
203 } 203 }
204 204
205 } // namespace webcrypto 205 } // namespace webcrypto
206 206
207 } // namespace content 207 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/shared_crypto_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698