| 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/openssl/rsa_key_openssl.h" | 5 #include "content/child/webcrypto/openssl/rsa_key_openssl.h" |
| 6 | 6 |
| 7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
| 8 #include <openssl/pkcs12.h> | 8 #include <openssl/pkcs12.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( | 313 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( |
| 314 blink::WebCryptoKeyFormat format, | 314 blink::WebCryptoKeyFormat format, |
| 315 blink::WebCryptoKeyUsageMask usages) const { | 315 blink::WebCryptoKeyUsageMask usages) const { |
| 316 switch (format) { | 316 switch (format) { |
| 317 case blink::WebCryptoKeyFormatSpki: | 317 case blink::WebCryptoKeyFormatSpki: |
| 318 return CheckKeyCreationUsages(all_public_key_usages_, usages); | 318 return CheckKeyCreationUsages(all_public_key_usages_, usages); |
| 319 case blink::WebCryptoKeyFormatPkcs8: | 319 case blink::WebCryptoKeyFormatPkcs8: |
| 320 return CheckKeyCreationUsages(all_private_key_usages_, usages); | 320 return CheckKeyCreationUsages(all_private_key_usages_, usages); |
| 321 case blink::WebCryptoKeyFormatJwk: | 321 case blink::WebCryptoKeyFormatJwk: |
| 322 // TODO(eroman): http://crbug.com/395904 | 322 // The JWK could represent either a public key or private key. The usages |
| 323 return CheckKeyCreationUsages( | 323 // must make sense for one of the two. The usages will be checked again by |
| 324 all_public_key_usages_ | all_private_key_usages_, usages); | 324 // ImportKeyJwk() once the key type has been determined. |
| 325 if (CheckKeyCreationUsages(all_private_key_usages_, usages) |
| 326 .IsSuccess() || |
| 327 CheckKeyCreationUsages(all_public_key_usages_, usages) |
| 328 .IsSuccess()) { |
| 329 return Status::Success(); |
| 330 } |
| 331 return Status::ErrorCreateKeyBadUsages(); |
| 325 default: | 332 default: |
| 326 return Status::ErrorUnsupportedImportKeyFormat(); | 333 return Status::ErrorUnsupportedImportKeyFormat(); |
| 327 } | 334 } |
| 328 } | 335 } |
| 329 | 336 |
| 330 Status RsaHashedAlgorithm::ImportKeyPkcs8( | 337 Status RsaHashedAlgorithm::ImportKeyPkcs8( |
| 331 const CryptoData& key_data, | 338 const CryptoData& key_data, |
| 332 const blink::WebCryptoAlgorithm& algorithm, | 339 const blink::WebCryptoAlgorithm& algorithm, |
| 333 bool extractable, | 340 bool extractable, |
| 334 blink::WebCryptoKeyUsageMask usages, | 341 blink::WebCryptoKeyUsageMask usages, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 return Status::Success(); | 507 return Status::Success(); |
| 501 | 508 |
| 502 default: | 509 default: |
| 503 return Status::ErrorUnexpected(); | 510 return Status::ErrorUnexpected(); |
| 504 } | 511 } |
| 505 } | 512 } |
| 506 | 513 |
| 507 } // namespace webcrypto | 514 } // namespace webcrypto |
| 508 | 515 |
| 509 } // namespace content | 516 } // namespace content |
| OLD | NEW |