OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/stl_util.h" | 5 #include "base/stl_util.h" |
6 #include "components/webcrypto/algorithm_implementation.h" | 6 #include "components/webcrypto/algorithm_implementation.h" |
7 #include "components/webcrypto/algorithms/secret_key_util.h" | 7 #include "components/webcrypto/algorithms/secret_key_util.h" |
8 #include "components/webcrypto/algorithms/util.h" | 8 #include "components/webcrypto/algorithms/util.h" |
9 #include "components/webcrypto/blink_key_handle.h" | 9 #include "components/webcrypto/blink_key_handle.h" |
10 #include "components/webcrypto/crypto_data.h" | 10 #include "components/webcrypto/crypto_data.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const EVP_MD* digest_algorithm = GetDigest(params->hash()); | 69 const EVP_MD* digest_algorithm = GetDigest(params->hash()); |
70 if (!digest_algorithm) | 70 if (!digest_algorithm) |
71 return Status::ErrorUnsupported(); | 71 return Status::ErrorUnsupported(); |
72 | 72 |
73 unsigned int keylen_bytes = optional_length_bits / 8; | 73 unsigned int keylen_bytes = optional_length_bits / 8; |
74 derived_bytes->resize(keylen_bytes); | 74 derived_bytes->resize(keylen_bytes); |
75 | 75 |
76 const std::vector<uint8_t>& password = GetSymmetricKeyData(base_key); | 76 const std::vector<uint8_t>& password = GetSymmetricKeyData(base_key); |
77 | 77 |
78 if (!PKCS5_PBKDF2_HMAC( | 78 if (!PKCS5_PBKDF2_HMAC( |
79 reinterpret_cast<const char*>(vector_as_array(&password)), | 79 reinterpret_cast<const char*>(password.data()), password.size(), |
80 password.size(), params->salt().data(), params->salt().size(), | 80 params->salt().data(), params->salt().size(), params->iterations(), |
81 params->iterations(), digest_algorithm, keylen_bytes, | 81 digest_algorithm, keylen_bytes, derived_bytes->data())) { |
82 vector_as_array(derived_bytes))) { | |
83 return Status::OperationError(); | 82 return Status::OperationError(); |
84 } | 83 } |
85 return Status::Success(); | 84 return Status::Success(); |
86 } | 85 } |
87 | 86 |
88 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | 87 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, |
89 blink::WebCryptoKeyType type, | 88 blink::WebCryptoKeyType type, |
90 bool extractable, | 89 bool extractable, |
91 blink::WebCryptoKeyUsageMask usages, | 90 blink::WebCryptoKeyUsageMask usages, |
92 const CryptoData& key_data, | 91 const CryptoData& key_data, |
(...skipping 10 matching lines...) Expand all Loading... |
103 } | 102 } |
104 }; | 103 }; |
105 | 104 |
106 } // namespace | 105 } // namespace |
107 | 106 |
108 scoped_ptr<AlgorithmImplementation> CreatePbkdf2Implementation() { | 107 scoped_ptr<AlgorithmImplementation> CreatePbkdf2Implementation() { |
109 return make_scoped_ptr(new Pbkdf2Implementation); | 108 return make_scoped_ptr(new Pbkdf2Implementation); |
110 } | 109 } |
111 | 110 |
112 } // namespace webcrypto | 111 } // namespace webcrypto |
OLD | NEW |