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

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

Issue 282133002: [webcryto] Validate key usages during key creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on master Created 6 years, 7 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/webcrypto_util.h ('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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 case blink::WebCryptoAlgorithmIdAesCtr: 172 case blink::WebCryptoAlgorithmIdAesCtr:
173 case blink::WebCryptoAlgorithmIdAesGcm: 173 case blink::WebCryptoAlgorithmIdAesGcm:
174 *key_algorithm = blink::WebCryptoKeyAlgorithm::createAes( 174 *key_algorithm = blink::WebCryptoKeyAlgorithm::createAes(
175 algorithm.id(), keylen_bytes * 8); 175 algorithm.id(), keylen_bytes * 8);
176 return true; 176 return true;
177 default: 177 default:
178 return false; 178 return false;
179 } 179 }
180 } 180 }
181 181
182 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a,
183 blink::WebCryptoKeyUsageMask b) {
184 return (a & b) == b;
185 }
186
182 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { 187 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) {
183 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || 188 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep ||
184 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; 189 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5;
185 } 190 }
186 191
192 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) {
193 // TODO(padolph): include all other asymmetric algorithms once they are
194 // defined, e.g. EC and DH.
195 return IsAlgorithmRsa(alg_id);
196 }
197
187 } // namespace webcrypto 198 } // namespace webcrypto
188 199
189 } // namespace content 200 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698