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

Side by Side Diff: content/child/webcrypto/nss/sha_nss.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 <sechash.h> 5 #include <sechash.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/stl_util.h"
8 #include "content/child/webcrypto/algorithm_implementation.h" 9 #include "content/child/webcrypto/algorithm_implementation.h"
9 #include "content/child/webcrypto/crypto_data.h" 10 #include "content/child/webcrypto/crypto_data.h"
10 #include "content/child/webcrypto/nss/util_nss.h" 11 #include "content/child/webcrypto/nss/util_nss.h"
11 #include "content/child/webcrypto/status.h" 12 #include "content/child/webcrypto/status.h"
12 #include "content/child/webcrypto/webcrypto_util.h" 13 #include "content/child/webcrypto/webcrypto_util.h"
13 #include "crypto/nss_util.h" 14 #include "crypto/nss_util.h"
14 #include "crypto/scoped_nss_types.h" 15 #include "crypto/scoped_nss_types.h"
15 16
16 namespace content { 17 namespace content {
17 18
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 result_data = result_; 79 result_data = result_;
79 return true; 80 return true;
80 } 81 }
81 82
82 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) { 83 Status FinishWithVectorAndStatus(std::vector<uint8_t>* result) {
83 if (!hash_context_) 84 if (!hash_context_)
84 return Status::ErrorUnexpected(); 85 return Status::ErrorUnexpected();
85 86
86 unsigned int result_length = HASH_ResultLenContext(hash_context_); 87 unsigned int result_length = HASH_ResultLenContext(hash_context_);
87 result->resize(result_length); 88 result->resize(result_length);
88 unsigned char* digest = Uint8VectorStart(result); 89 unsigned char* digest = vector_as_array(result);
89 unsigned int digest_size; // ignored 90 unsigned int digest_size; // ignored
90 return FinishInternal(digest, &digest_size); 91 return FinishInternal(digest, &digest_size);
91 } 92 }
92 93
93 private: 94 private:
94 Status Init() { 95 Status Init() {
95 HASH_HashType hash_type = WebCryptoAlgorithmToNSSHashType(algorithm_id_); 96 HASH_HashType hash_type = WebCryptoAlgorithmToNSSHashType(algorithm_id_);
96 97
97 if (hash_type == HASH_AlgNULL) 98 if (hash_type == HASH_AlgNULL)
98 return Status::ErrorUnsupported(); 99 return Status::ErrorUnsupported();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 151 }
151 152
152 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( 153 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor(
153 blink::WebCryptoAlgorithmId algorithm) { 154 blink::WebCryptoAlgorithmId algorithm) {
154 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm)); 155 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm));
155 } 156 }
156 157
157 } // namespace webcrypto 158 } // namespace webcrypto
158 159
159 } // namespace content 160 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/rsa_oaep_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