Chromium Code Reviews| 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 VerifyUsagesBeforeImportAsymmetricKey( | |
| 266 blink::WebCryptoKeyFormat format, | |
| 267 blink::WebCryptoKeyUsageMask all_public_key_usages, | |
| 268 blink::WebCryptoKeyUsageMask all_private_key_usages, | |
| 269 blink::WebCryptoKeyUsageMask usages) { | |
| 270 switch (format) { | |
| 271 case blink::WebCryptoKeyFormatSpki: | |
| 272 return CheckKeyCreationUsages(all_public_key_usages, usages); | |
| 273 case blink::WebCryptoKeyFormatPkcs8: | |
| 274 return CheckKeyCreationUsages(all_private_key_usages, usages); | |
| 275 case blink::WebCryptoKeyFormatJwk: { | |
| 276 // The JWK could represent either a public key or private key. The usages | |
| 277 // must make sense for one of the two. The usages will be checked again by | |
| 278 // ImportKeyJwk() once the key type has been determined. | |
| 279 Status status = CheckKeyCreationUsages(all_public_key_usages, usages); | |
| 280 if (status.IsError()) | |
| 281 return status; | |
|
davidben
2014/12/09 20:36:39
I think this got inverted from the original code.
eroman
2014/12/09 20:41:54
Ugh you are right! I will restore the original cod
eroman
2014/12/09 20:46:40
OK Fixed.
I reordered it a bit from the original
| |
| 282 | |
| 283 status = CheckKeyCreationUsages(all_private_key_usages, usages); | |
| 284 if (status.IsError()) | |
| 285 return status; | |
| 286 return Status::Success(); | |
| 287 } | |
| 288 default: | |
| 289 return Status::ErrorUnsupportedImportKeyFormat(); | |
| 290 } | |
| 291 } | |
| 292 | |
| 265 } // namespace webcrypto | 293 } // namespace webcrypto |
| 266 | 294 |
| 267 } // namespace content | 295 } // namespace content |
| OLD | NEW |