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

Side by Side Diff: components/webcrypto/algorithms/sha.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 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 <openssl/evp.h> 5 #include <openssl/evp.h>
6 #include <openssl/sha.h> 6 #include <openssl/sha.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h"
11 #include "components/webcrypto/algorithm_implementation.h" 10 #include "components/webcrypto/algorithm_implementation.h"
12 #include "components/webcrypto/algorithms/util.h" 11 #include "components/webcrypto/algorithms/util.h"
13 #include "components/webcrypto/crypto_data.h" 12 #include "components/webcrypto/crypto_data.h"
14 #include "components/webcrypto/status.h" 13 #include "components/webcrypto/status.h"
15 #include "crypto/openssl_util.h" 14 #include "crypto/openssl_util.h"
16 #include "crypto/scoped_openssl_types.h" 15 #include "crypto/scoped_openssl_types.h"
17 16
18 namespace webcrypto { 17 namespace webcrypto {
19 18
20 namespace { 19 namespace {
(...skipping 30 matching lines...) Expand all
51 Status error = FinishInternal(result_, &result_data_size); 50 Status error = FinishInternal(result_, &result_data_size);
52 if (!error.IsSuccess()) 51 if (!error.IsSuccess())
53 return false; 52 return false;
54 result_data = result_; 53 result_data = result_;
55 return true; 54 return true;
56 } 55 }
57 56
58 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) { 57 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) {
59 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get()); 58 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get());
60 result->resize(hash_expected_size); 59 result->resize(hash_expected_size);
61 unsigned char* const hash_buffer = vector_as_array(result);
62 unsigned int hash_buffer_size; // ignored 60 unsigned int hash_buffer_size; // ignored
63 return FinishInternal(hash_buffer, &hash_buffer_size); 61 return FinishInternal(result->data(), &hash_buffer_size);
64 } 62 }
65 63
66 private: 64 private:
67 Status Init() { 65 Status Init() {
68 if (initialized_) 66 if (initialized_)
69 return Status::Success(); 67 return Status::Success();
70 68
71 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_); 69 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_);
72 if (!digest_algorithm) 70 if (!digest_algorithm)
73 return Status::ErrorUnsupported(); 71 return Status::ErrorUnsupported();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 scoped_ptr<AlgorithmImplementation> CreateShaImplementation() { 124 scoped_ptr<AlgorithmImplementation> CreateShaImplementation() {
127 return make_scoped_ptr(new ShaImplementation()); 125 return make_scoped_ptr(new ShaImplementation());
128 } 126 }
129 127
130 scoped_ptr<blink::WebCryptoDigestor> CreateDigestorImplementation( 128 scoped_ptr<blink::WebCryptoDigestor> CreateDigestorImplementation(
131 blink::WebCryptoAlgorithmId algorithm) { 129 blink::WebCryptoAlgorithmId algorithm) {
132 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorImpl(algorithm)); 130 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorImpl(algorithm));
133 } 131 }
134 132
135 } // namespace webcrypto 133 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/secret_key_util.cc ('k') | components/webcrypto/algorithms/sha_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698