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

Side by Side Diff: content/child/webcrypto/nss/sha_nss.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 <sechash.h> 5 #include <sechash.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "content/child/webcrypto/algorithm_implementation.h" 8 #include "content/child/webcrypto/algorithm_implementation.h"
9 #include "content/child/webcrypto/crypto_data.h" 9 #include "content/child/webcrypto/crypto_data.h"
10 #include "content/child/webcrypto/nss/util_nss.h" 10 #include "content/child/webcrypto/nss/util_nss.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 virtual bool finish(unsigned char*& result_data, 73 virtual bool finish(unsigned char*& result_data,
74 unsigned int& result_data_size) { 74 unsigned int& result_data_size) {
75 Status error = FinishInternal(result_, &result_data_size); 75 Status error = FinishInternal(result_, &result_data_size);
76 if (!error.IsSuccess()) 76 if (!error.IsSuccess())
77 return false; 77 return false;
78 result_data = result_; 78 result_data = result_;
79 return true; 79 return true;
80 } 80 }
81 81
82 Status FinishWithVectorAndStatus(std::vector<uint8>* result) { 82 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) {
83 if (!hash_context_) 83 if (!hash_context_)
84 return Status::ErrorUnexpected(); 84 return Status::ErrorUnexpected();
85 85
86 unsigned int result_length = HASH_ResultLenContext(hash_context_); 86 unsigned int result_length = HASH_ResultLenContext(hash_context_);
87 result->resize(result_length); 87 result->resize(result_length);
88 unsigned char* digest = Uint8VectorStart(result); 88 unsigned char* digest = Uint8VectorStart(result);
89 unsigned int digest_size; // ignored 89 unsigned int digest_size; // ignored
90 return FinishInternal(digest, &digest_size); 90 return FinishInternal(digest, &digest_size);
91 } 91 }
92 92
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 HASHContext* hash_context_; 126 HASHContext* hash_context_;
127 blink::WebCryptoAlgorithmId algorithm_id_; 127 blink::WebCryptoAlgorithmId algorithm_id_;
128 unsigned char result_[HASH_LENGTH_MAX]; 128 unsigned char result_[HASH_LENGTH_MAX];
129 }; 129 };
130 130
131 class ShaImplementation : public AlgorithmImplementation { 131 class ShaImplementation : public AlgorithmImplementation {
132 public: 132 public:
133 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, 133 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm,
134 const CryptoData& data, 134 const CryptoData& data,
135 std::vector<uint8>* buffer) const OVERRIDE { 135 std::vector<uint8_t>* buffer) const OVERRIDE {
136 DigestorNSS digestor(algorithm.id()); 136 DigestorNSS digestor(algorithm.id());
137 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); 137 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length());
138 // http://crbug.com/366427: the spec does not define any other failures for 138 // http://crbug.com/366427: the spec does not define any other failures for
139 // digest, so none of the subsequent errors are spec compliant. 139 // digest, so none of the subsequent errors are spec compliant.
140 if (!error.IsSuccess()) 140 if (!error.IsSuccess())
141 return error; 141 return error;
142 return digestor.FinishWithVectorAndStatus(buffer); 142 return digestor.FinishWithVectorAndStatus(buffer);
143 } 143 }
144 }; 144 };
145 145
146 } // namespace 146 } // namespace
147 147
148 AlgorithmImplementation* CreatePlatformShaImplementation() { 148 AlgorithmImplementation* CreatePlatformShaImplementation() {
149 return new ShaImplementation(); 149 return new ShaImplementation();
150 } 150 }
151 151
152 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( 152 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor(
153 blink::WebCryptoAlgorithmId algorithm) { 153 blink::WebCryptoAlgorithmId algorithm) {
154 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm)); 154 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm));
155 } 155 }
156 156
157 } // namespace webcrypto 157 } // namespace webcrypto
158 158
159 } // namespace content 159 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/rsa_ssa_nss.cc ('k') | content/child/webcrypto/openssl/aes_cbc_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698