| 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 "base/stl_util.h" |
| 9 #include "content/child/webcrypto/algorithm_implementation.h" | 9 #include "content/child/webcrypto/algorithm_implementation.h" |
| 10 #include "content/child/webcrypto/crypto_data.h" | 10 #include "content/child/webcrypto/crypto_data.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 HASHContext* hash_context_; | 127 HASHContext* hash_context_; |
| 128 blink::WebCryptoAlgorithmId algorithm_id_; | 128 blink::WebCryptoAlgorithmId algorithm_id_; |
| 129 unsigned char result_[HASH_LENGTH_MAX]; | 129 unsigned char result_[HASH_LENGTH_MAX]; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 class ShaImplementation : public AlgorithmImplementation { | 132 class ShaImplementation : public AlgorithmImplementation { |
| 133 public: | 133 public: |
| 134 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 134 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
| 135 const CryptoData& data, | 135 const CryptoData& data, |
| 136 std::vector<uint8_t>* buffer) const OVERRIDE { | 136 std::vector<uint8_t>* buffer) const override { |
| 137 DigestorNSS digestor(algorithm.id()); | 137 DigestorNSS digestor(algorithm.id()); |
| 138 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); | 138 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); |
| 139 // http://crbug.com/366427: the spec does not define any other failures for | 139 // http://crbug.com/366427: the spec does not define any other failures for |
| 140 // digest, so none of the subsequent errors are spec compliant. | 140 // digest, so none of the subsequent errors are spec compliant. |
| 141 if (!error.IsSuccess()) | 141 if (!error.IsSuccess()) |
| 142 return error; | 142 return error; |
| 143 return digestor.FinishWithVectorAndStatus(buffer); | 143 return digestor.FinishWithVectorAndStatus(buffer); |
| 144 } | 144 } |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 } // namespace | 147 } // namespace |
| 148 | 148 |
| 149 AlgorithmImplementation* CreatePlatformShaImplementation() { | 149 AlgorithmImplementation* CreatePlatformShaImplementation() { |
| 150 return new ShaImplementation(); | 150 return new ShaImplementation(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( | 153 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( |
| 154 blink::WebCryptoAlgorithmId algorithm) { | 154 blink::WebCryptoAlgorithmId algorithm) { |
| 155 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm)); | 155 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorNSS(algorithm)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace webcrypto | 158 } // namespace webcrypto |
| 159 | 159 |
| 160 } // namespace content | 160 } // namespace content |
| OLD | NEW |