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

Side by Side Diff: content/child/webcrypto/openssl/sha_openssl.cc

Issue 410743002: [refactor] Replace custom utility function with base's "vector_as_array()" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto master Created 6 years, 5 months 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 #include <openssl/evp.h> 6 #include <openssl/evp.h>
7 #include <openssl/sha.h> 7 #include <openssl/sha.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h"
10 #include "content/child/webcrypto/algorithm_implementation.h" 11 #include "content/child/webcrypto/algorithm_implementation.h"
11 #include "content/child/webcrypto/crypto_data.h" 12 #include "content/child/webcrypto/crypto_data.h"
12 #include "content/child/webcrypto/openssl/util_openssl.h" 13 #include "content/child/webcrypto/openssl/util_openssl.h"
13 #include "content/child/webcrypto/status.h" 14 #include "content/child/webcrypto/status.h"
14 #include "content/child/webcrypto/webcrypto_util.h" 15 #include "content/child/webcrypto/webcrypto_util.h"
15 #include "crypto/openssl_util.h" 16 #include "crypto/openssl_util.h"
16 #include "crypto/scoped_openssl_types.h" 17 #include "crypto/scoped_openssl_types.h"
17 18
18 namespace content { 19 namespace content {
19 20
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Status error = FinishInternal(result_, &result_data_size); 54 Status error = FinishInternal(result_, &result_data_size);
54 if (!error.IsSuccess()) 55 if (!error.IsSuccess())
55 return false; 56 return false;
56 result_data = result_; 57 result_data = result_;
57 return true; 58 return true;
58 } 59 }
59 60
60 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) { 61 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) {
61 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get()); 62 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get());
62 result->resize(hash_expected_size); 63 result->resize(hash_expected_size);
63 unsigned char* const hash_buffer = Uint8VectorStart(result); 64 unsigned char* const hash_buffer = vector_as_array(result);
64 unsigned int hash_buffer_size; // ignored 65 unsigned int hash_buffer_size; // ignored
65 return FinishInternal(hash_buffer, &hash_buffer_size); 66 return FinishInternal(hash_buffer, &hash_buffer_size);
66 } 67 }
67 68
68 private: 69 private:
69 Status Init() { 70 Status Init() {
70 if (initialized_) 71 if (initialized_)
71 return Status::Success(); 72 return Status::Success();
72 73
73 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_); 74 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 131 }
131 132
132 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( 133 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor(
133 blink::WebCryptoAlgorithmId algorithm) { 134 blink::WebCryptoAlgorithmId algorithm) {
134 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm)); 135 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm));
135 } 136 }
136 137
137 } // namespace webcrypto 138 } // namespace webcrypto
138 139
139 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/hmac_openssl.cc ('k') | content/child/webcrypto/shared_crypto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698