| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |