| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/webcrypto/webcrypto_impl.h" | 5 #include "content/renderer/webcrypto/webcrypto_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 new blink::WebCryptoAesCbcParams(Start(iv), iv.size())); | 73 new blink::WebCryptoAesCbcParams(Start(iv), iv.size())); |
| 74 } | 74 } |
| 75 | 75 |
| 76 blink::WebCryptoAlgorithm CreateAesCbcAlgorithm( | 76 blink::WebCryptoAlgorithm CreateAesCbcAlgorithm( |
| 77 unsigned short key_length_bits) { // NOLINT | 77 unsigned short key_length_bits) { // NOLINT |
| 78 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 78 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
| 79 blink::WebCryptoAlgorithmIdAesCbc, | 79 blink::WebCryptoAlgorithmIdAesCbc, |
| 80 new blink::WebCryptoAesKeyGenParams(key_length_bits)); | 80 new blink::WebCryptoAesKeyGenParams(key_length_bits)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 #if !defined(USE_OPENSSL) |
| 83 blink::WebCryptoAlgorithm CreateRsaAlgorithm( | 84 blink::WebCryptoAlgorithm CreateRsaAlgorithm( |
| 84 blink::WebCryptoAlgorithmId algorithm_id, | 85 blink::WebCryptoAlgorithmId algorithm_id, |
| 85 unsigned modulus_length, | 86 unsigned modulus_length, |
| 86 const std::vector<uint8>& public_exponent) { | 87 const std::vector<uint8>& public_exponent) { |
| 87 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || | 88 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || |
| 88 algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || | 89 algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || |
| 89 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); | 90 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); |
| 90 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 91 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
| 91 algorithm_id, | 92 algorithm_id, |
| 92 new blink::WebCryptoRsaKeyGenParams( | 93 new blink::WebCryptoRsaKeyGenParams( |
| 93 modulus_length, Start(public_exponent), public_exponent.size())); | 94 modulus_length, Start(public_exponent), public_exponent.size())); |
| 94 } | 95 } |
| 96 #endif // !defined(USE_OPENSSL) |
| 95 | 97 |
| 96 } // namespace | 98 } // namespace |
| 97 | 99 |
| 98 namespace content { | 100 namespace content { |
| 99 | 101 |
| 100 class WebCryptoImplTest : public testing::Test { | 102 class WebCryptoImplTest : public testing::Test { |
| 101 protected: | 103 protected: |
| 102 blink::WebCryptoKey ImportSecretKeyFromRawHexString( | 104 blink::WebCryptoKey ImportSecretKeyFromRawHexString( |
| 103 const std::string& key_hex, | 105 const std::string& key_hex, |
| 104 const blink::WebCryptoAlgorithm& algorithm, | 106 const blink::WebCryptoAlgorithm& algorithm, |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key.type()); | 790 EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key.type()); |
| 789 EXPECT_EQ(extractable, public_key.extractable()); | 791 EXPECT_EQ(extractable, public_key.extractable()); |
| 790 EXPECT_EQ(extractable, private_key.extractable()); | 792 EXPECT_EQ(extractable, private_key.extractable()); |
| 791 EXPECT_EQ(usage_mask, public_key.usages()); | 793 EXPECT_EQ(usage_mask, public_key.usages()); |
| 792 EXPECT_EQ(usage_mask, private_key.usages()); | 794 EXPECT_EQ(usage_mask, private_key.usages()); |
| 793 } | 795 } |
| 794 | 796 |
| 795 #endif // #if !defined(USE_OPENSSL) | 797 #endif // #if !defined(USE_OPENSSL) |
| 796 | 798 |
| 797 } // namespace content | 799 } // namespace content |
| OLD | NEW |