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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return Status::Success(); | 62 return Status::Success(); |
63 } | 63 } |
64 | 64 |
65 // Creates a blink::WebCryptoAlgorithm having the modulus length and public | 65 // Creates a blink::WebCryptoAlgorithm having the modulus length and public |
66 // exponent of |key|. | 66 // exponent of |key|. |
67 Status CreateRsaHashedKeyAlgorithm( | 67 Status CreateRsaHashedKeyAlgorithm( |
68 blink::WebCryptoAlgorithmId rsa_algorithm, | 68 blink::WebCryptoAlgorithmId rsa_algorithm, |
69 blink::WebCryptoAlgorithmId hash_algorithm, | 69 blink::WebCryptoAlgorithmId hash_algorithm, |
70 EVP_PKEY* key, | 70 EVP_PKEY* key, |
71 blink::WebCryptoKeyAlgorithm* key_algorithm) { | 71 blink::WebCryptoKeyAlgorithm* key_algorithm) { |
72 DCHECK(IsAlgorithmRsa(rsa_algorithm)); | |
73 DCHECK_EQ(EVP_PKEY_RSA, EVP_PKEY_id(key)); | 72 DCHECK_EQ(EVP_PKEY_RSA, EVP_PKEY_id(key)); |
74 | 73 |
75 crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(key)); | 74 crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(key)); |
76 if (!rsa.get()) | 75 if (!rsa.get()) |
77 return Status::ErrorUnexpected(); | 76 return Status::ErrorUnexpected(); |
78 | 77 |
79 unsigned int modulus_length_bits = BN_num_bits(rsa.get()->n); | 78 unsigned int modulus_length_bits = BN_num_bits(rsa.get()->n); |
80 | 79 |
81 // Convert the public exponent to big-endian representation. | 80 // Convert the public exponent to big-endian representation. |
82 std::vector<uint8_t> e(BN_num_bytes(rsa.get()->e)); | 81 std::vector<uint8_t> e(BN_num_bytes(rsa.get()->e)); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 return Status::Success(); | 500 return Status::Success(); |
502 | 501 |
503 default: | 502 default: |
504 return Status::ErrorUnexpected(); | 503 return Status::ErrorUnexpected(); |
505 } | 504 } |
506 } | 505 } |
507 | 506 |
508 } // namespace webcrypto | 507 } // namespace webcrypto |
509 | 508 |
510 } // namespace content | 509 } // namespace content |
OLD | NEW |