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 <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 "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool initialized_; | 106 bool initialized_; |
107 crypto::ScopedEVP_MD_CTX digest_context_; | 107 crypto::ScopedEVP_MD_CTX digest_context_; |
108 blink::WebCryptoAlgorithmId algorithm_id_; | 108 blink::WebCryptoAlgorithmId algorithm_id_; |
109 unsigned char result_[EVP_MAX_MD_SIZE]; | 109 unsigned char result_[EVP_MAX_MD_SIZE]; |
110 }; | 110 }; |
111 | 111 |
112 class ShaImplementation : public AlgorithmImplementation { | 112 class ShaImplementation : public AlgorithmImplementation { |
113 public: | 113 public: |
114 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 114 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
115 const CryptoData& data, | 115 const CryptoData& data, |
116 std::vector<uint8_t>* buffer) const OVERRIDE { | 116 std::vector<uint8_t>* buffer) const override { |
117 DigestorOpenSsl digestor(algorithm.id()); | 117 DigestorOpenSsl digestor(algorithm.id()); |
118 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); | 118 Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); |
119 // http://crbug.com/366427: the spec does not define any other failures for | 119 // http://crbug.com/366427: the spec does not define any other failures for |
120 // digest, so none of the subsequent errors are spec compliant. | 120 // digest, so none of the subsequent errors are spec compliant. |
121 if (!error.IsSuccess()) | 121 if (!error.IsSuccess()) |
122 return error; | 122 return error; |
123 return digestor.FinishWithVectorAndStatus(buffer); | 123 return digestor.FinishWithVectorAndStatus(buffer); |
124 } | 124 } |
125 }; | 125 }; |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 | 128 |
129 AlgorithmImplementation* CreatePlatformShaImplementation() { | 129 AlgorithmImplementation* CreatePlatformShaImplementation() { |
130 return new ShaImplementation(); | 130 return new ShaImplementation(); |
131 } | 131 } |
132 | 132 |
133 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( | 133 scoped_ptr<blink::WebCryptoDigestor> CreatePlatformDigestor( |
134 blink::WebCryptoAlgorithmId algorithm) { | 134 blink::WebCryptoAlgorithmId algorithm) { |
135 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm)); | 135 return scoped_ptr<blink::WebCryptoDigestor>(new DigestorOpenSsl(algorithm)); |
136 } | 136 } |
137 | 137 |
138 } // namespace webcrypto | 138 } // namespace webcrypto |
139 | 139 |
140 } // namespace content | 140 } // namespace content |
OLD | NEW |