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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return FinishInternal(hash_buffer, &hash_buffer_size); | 66 return FinishInternal(hash_buffer, &hash_buffer_size); |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 Status Init() { | 70 Status Init() { |
71 if (initialized_) | 71 if (initialized_) |
72 return Status::Success(); | 72 return Status::Success(); |
73 | 73 |
74 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_); | 74 const EVP_MD* digest_algorithm = GetDigest(algorithm_id_); |
75 if (!digest_algorithm) | 75 if (!digest_algorithm) |
76 return Status::ErrorUnexpected(); | 76 return Status::ErrorUnsupported(); |
77 | 77 |
78 if (!digest_context_.get()) | 78 if (!digest_context_.get()) |
79 return Status::OperationError(); | 79 return Status::OperationError(); |
80 | 80 |
81 if (!EVP_DigestInit_ex(digest_context_.get(), digest_algorithm, NULL)) | 81 if (!EVP_DigestInit_ex(digest_context_.get(), digest_algorithm, NULL)) |
82 return Status::OperationError(); | 82 return Status::OperationError(); |
83 | 83 |
84 initialized_ = true; | 84 initialized_ = true; |
85 return Status::Success(); | 85 return Status::Success(); |
86 } | 86 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |