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

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

Issue 661653002: [webcrypto] Implement RSA-PSS using BoringSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_rsassa
Patch Set: rebase onto master (corrected) 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/test/test_helpers.cc ('k') | content/content_child.gypi » ('j') | 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id)); 111 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id));
112 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 112 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
113 blink::WebCryptoAlgorithmIdHmac, 113 blink::WebCryptoAlgorithmIdHmac,
114 new blink::WebCryptoHmacImportParams(CreateAlgorithm(hash_id))); 114 new blink::WebCryptoHmacImportParams(CreateAlgorithm(hash_id)));
115 } 115 }
116 116
117 blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( 117 blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm(
118 blink::WebCryptoAlgorithmId id, 118 blink::WebCryptoAlgorithmId id,
119 blink::WebCryptoAlgorithmId hash_id) { 119 blink::WebCryptoAlgorithmId hash_id) {
120 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id)); 120 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id));
121 DCHECK(id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
122 id == blink::WebCryptoAlgorithmIdRsaOaep);
123 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 121 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
124 id, new blink::WebCryptoRsaHashedImportParams(CreateAlgorithm(hash_id))); 122 id, new blink::WebCryptoRsaHashedImportParams(CreateAlgorithm(hash_id)));
125 } 123 }
126 124
127 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, 125 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a,
128 blink::WebCryptoKeyUsageMask b) { 126 blink::WebCryptoKeyUsageMask b) {
129 return (a & b) == b; 127 return (a & b) == b;
130 } 128 }
131 129
132 // TODO(eroman): Move this helper to WebCryptoKey. 130 // TODO(eroman): Move this helper to WebCryptoKey.
133 bool KeyUsageAllows(const blink::WebCryptoKey& key, 131 bool KeyUsageAllows(const blink::WebCryptoKey& key,
134 const blink::WebCryptoKeyUsage usage) { 132 const blink::WebCryptoKeyUsage usage) {
135 return ((key.usages() & usage) != 0); 133 return ((key.usages() & usage) != 0);
136 } 134 }
137 135
138 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { 136 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) {
139 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || 137 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep ||
140 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; 138 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
139 alg_id == blink::WebCryptoAlgorithmIdRsaPss;
141 } 140 }
142 141
143 // The WebCrypto spec defines the default value for the tag length, as well as 142 // The WebCrypto spec defines the default value for the tag length, as well as
144 // the allowed values for tag length. 143 // the allowed values for tag length.
145 Status GetAesGcmTagLengthInBits(const blink::WebCryptoAesGcmParams* params, 144 Status GetAesGcmTagLengthInBits(const blink::WebCryptoAesGcmParams* params,
146 unsigned int* tag_length_bits) { 145 unsigned int* tag_length_bits) {
147 *tag_length_bits = 128; 146 *tag_length_bits = 128;
148 if (params->hasTagLengthBits()) 147 if (params->hasTagLengthBits())
149 *tag_length_bits = params->optionalTagLengthBits(); 148 *tag_length_bits = params->optionalTagLengthBits();
150 149
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // avoid feeding OpenSSL data that will hang use a whitelist. 241 // avoid feeding OpenSSL data that will hang use a whitelist.
243 if (*public_exponent != 3 && *public_exponent != 65537) 242 if (*public_exponent != 3 && *public_exponent != 65537)
244 return Status::ErrorGenerateKeyPublicExponent(); 243 return Status::ErrorGenerateKeyPublicExponent();
245 244
246 return Status::Success(); 245 return Status::Success();
247 } 246 }
248 247
249 } // namespace webcrypto 248 } // namespace webcrypto
250 249
251 } // namespace content 250 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/test/test_helpers.cc ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698