Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: components/webcrypto/algorithms/pbkdf2.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/hmac_unittest.cc ('k') | components/webcrypto/algorithms/rsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698