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

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

Issue 404733005: Replace uses of uint8 with uint8_t. (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 "content/child/webcrypto/algorithm_implementation.h" 10 #include "content/child/webcrypto/algorithm_implementation.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 virtual bool finish(unsigned char*& result_data, 51 virtual bool finish(unsigned char*& result_data,
52 unsigned int& result_data_size) { 52 unsigned int& result_data_size) {
53 Status error = FinishInternal(result_, &result_data_size); 53 Status error = FinishInternal(result_, &result_data_size);
54 if (!error.IsSuccess()) 54 if (!error.IsSuccess())
55 return false; 55 return false;
56 result_data = result_; 56 result_data = result_;
57 return true; 57 return true;
58 } 58 }
59 59
60 Status FinishWithVectorAndStatus(std::vector<uint8>* result) { 60 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) {
61 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get()); 61 const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get());
62 result->resize(hash_expected_size); 62 result->resize(hash_expected_size);
63 unsigned char* const hash_buffer = Uint8VectorStart(result); 63 unsigned char* const hash_buffer = Uint8VectorStart(result);
64 unsigned int hash_buffer_size; // ignored 64 unsigned int hash_buffer_size; // ignored
65 return FinishInternal(hash_buffer, &hash_buffer_size); 65 return FinishInternal(hash_buffer, &hash_buffer_size);
66 } 66 }
67 67
68 private: 68 private:
69 Status Init() { 69 Status Init() {
70 if (initialized_) 70 if (initialized_)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bool initialized_; 105 bool initialized_;
106 crypto::ScopedEVP_MD_CTX digest_context_; 106 crypto::ScopedEVP_MD_CTX digest_context_;
107 blink::WebCryptoAlgorithmId algorithm_id_; 107 blink::WebCryptoAlgorithmId algorithm_id_;
108 unsigned char result_[EVP_MAX_MD_SIZE]; 108 unsigned char result_[EVP_MAX_MD_SIZE];
109 }; 109 };
110 110
111 class ShaImplementation : public AlgorithmImplementation { 111 class ShaImplementation : public AlgorithmImplementation {
112 public: 112 public:
113 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, 113 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm,
114 const CryptoData& data, 114 const CryptoData& data,
115 std::vector<uint8>* buffer) const OVERRIDE { 115 std::vector<uint8_t>* buffer) const OVERRIDE {
116 DigestorOpenSsl digestor(algorithm.id()); 116 DigestorOpenSsl digestor(algorithm.id());
117 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); 117 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length());
118 // http://crbug.com/366427: the spec does not define any other failures for 118 // http://crbug.com/366427: the spec does not define any other failures for
119 // digest, so none of the subsequent errors are spec compliant. 119 // digest, so none of the subsequent errors are spec compliant.
120 if (!error.IsSuccess()) 120 if (!error.IsSuccess())
121 return error; 121 return error;
122 return digestor.FinishWithVectorAndStatus(buffer); 122 return digestor.FinishWithVectorAndStatus(buffer);
123 } 123 }
124 }; 124 };
125 125
126 } // namespace 126 } // namespace
127 127
128 AlgorithmImplementation* CreatePlatformShaImplementation() { 128 AlgorithmImplementation* CreatePlatformShaImplementation() {
129 return new ShaImplementation(); 129 return new ShaImplementation();
130 } 130 }
131 131
132 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( 132 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor(
133 blink::WebCryptoAlgorithmId algorithm) { 133 blink::WebCryptoAlgorithmId algorithm) {
134 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm)); 134 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm));
135 } 135 }
136 136
137 } // namespace webcrypto 137 } // namespace webcrypto
138 138
139 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/key_openssl.cc ('k') | content/child/webcrypto/platform_crypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698