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

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

Issue 662403005: Cleanup: Remove IsAlgorithmRsa(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase onto master Created 6 years, 2 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
« 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/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/child/webcrypto/status.h" 9 #include "content/child/webcrypto/status.h"
10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 blink::WebCryptoKeyUsageMask b) { 126 blink::WebCryptoKeyUsageMask b) {
127 return (a & b) == b; 127 return (a & b) == b;
128 } 128 }
129 129
130 // TODO(eroman): Move this helper to WebCryptoKey. 130 // TODO(eroman): Move this helper to WebCryptoKey.
131 bool KeyUsageAllows(const blink::WebCryptoKey& key, 131 bool KeyUsageAllows(const blink::WebCryptoKey& key,
132 const blink::WebCryptoKeyUsage usage) { 132 const blink::WebCryptoKeyUsage usage) {
133 return ((key.usages() & usage) != 0); 133 return ((key.usages() & usage) != 0);
134 } 134 }
135 135
136 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) {
137 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep ||
138 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
139 alg_id == blink::WebCryptoAlgorithmIdRsaPss;
140 }
141
142 // The WebCrypto spec defines the default value for the tag length, as well as 136 // The WebCrypto spec defines the default value for the tag length, as well as
143 // the allowed values for tag length. 137 // the allowed values for tag length.
144 Status GetAesGcmTagLengthInBits(const blink::WebCryptoAesGcmParams* params, 138 Status GetAesGcmTagLengthInBits(const blink::WebCryptoAesGcmParams* params,
145 unsigned int* tag_length_bits) { 139 unsigned int* tag_length_bits) {
146 *tag_length_bits = 128; 140 *tag_length_bits = 128;
147 if (params->hasTagLengthBits()) 141 if (params->hasTagLengthBits())
148 *tag_length_bits = params->optionalTagLengthBits(); 142 *tag_length_bits = params->optionalTagLengthBits();
149 143
150 if (*tag_length_bits != 32 && *tag_length_bits != 64 && 144 if (*tag_length_bits != 32 && *tag_length_bits != 64 &&
151 *tag_length_bits != 96 && *tag_length_bits != 104 && 145 *tag_length_bits != 96 && *tag_length_bits != 104 &&
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // avoid feeding OpenSSL data that will hang use a whitelist. 235 // avoid feeding OpenSSL data that will hang use a whitelist.
242 if (*public_exponent != 3 && *public_exponent != 65537) 236 if (*public_exponent != 3 && *public_exponent != 65537)
243 return Status::ErrorGenerateKeyPublicExponent(); 237 return Status::ErrorGenerateKeyPublicExponent();
244 238
245 return Status::Success(); 239 return Status::Success();
246 } 240 }
247 241
248 } // namespace webcrypto 242 } // namespace webcrypto
249 243
250 } // namespace content 244 } // 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