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 "content/child/webcrypto/webcrypto_util.h" | 5 #include "content/child/webcrypto/webcrypto_util.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 | 256 |
257 // OpenSSL hangs when given bad public exponents, whereas NSS simply fails. To | 257 // OpenSSL hangs when given bad public exponents, whereas NSS simply fails. To |
258 // avoid feeding OpenSSL data that will hang use a whitelist. | 258 // avoid feeding OpenSSL data that will hang use a whitelist. |
259 if (*public_exponent != 3 && *public_exponent != 65537) | 259 if (*public_exponent != 3 && *public_exponent != 65537) |
260 return Status::ErrorGenerateKeyPublicExponent(); | 260 return Status::ErrorGenerateKeyPublicExponent(); |
261 | 261 |
262 return Status::Success(); | 262 return Status::Success(); |
263 } | 263 } |
264 | 264 |
| 265 Status GetUsagesForGenerateAsymmetricKey( |
| 266 blink::WebCryptoKeyUsageMask combined_usages, |
| 267 blink::WebCryptoKeyUsageMask all_public_usages, |
| 268 blink::WebCryptoKeyUsageMask all_private_usages, |
| 269 blink::WebCryptoKeyUsageMask* public_usages, |
| 270 blink::WebCryptoKeyUsageMask* private_usages) { |
| 271 *public_usages = combined_usages & all_public_usages; |
| 272 *private_usages = combined_usages & all_private_usages; |
| 273 |
| 274 Status status = CheckKeyCreationUsages(all_public_usages, *public_usages); |
| 275 if (status.IsError()) |
| 276 return status; |
| 277 |
| 278 status = CheckKeyCreationUsages(all_private_usages, *private_usages); |
| 279 if (status.IsError()) |
| 280 return status; |
| 281 |
| 282 if (private_usages == 0) |
| 283 return Status::ErrorCreateKeyEmptyUsages(); |
| 284 |
| 285 return Status::Success(); |
| 286 } |
| 287 |
265 } // namespace webcrypto | 288 } // namespace webcrypto |
266 | 289 |
267 } // namespace content | 290 } // namespace content |
OLD | NEW |