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

Side by Side Diff: crypto/secure_hash.h

Issue 1751603002: [Downloads] Rework how hashes are calculated for download files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of https://codereview.chromium.org/1781983002 since that's going in first. Created 4 years, 9 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
« no previous file with comments | « content/public/test/test_file_error_injector.cc ('k') | crypto/secure_hash_default.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CRYPTO_SECURE_HASH_H_ 5 #ifndef CRYPTO_SECURE_HASH_H_
6 #define CRYPTO_SECURE_HASH_H_ 6 #define CRYPTO_SECURE_HASH_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "crypto/crypto_export.h" 11 #include "crypto/crypto_export.h"
12 12
13 namespace base {
14 class Pickle;
15 class PickleIterator;
16 }
17
18 namespace crypto { 13 namespace crypto {
19 14
20 // A wrapper to calculate secure hashes incrementally, allowing to 15 // A wrapper to calculate secure hashes incrementally, allowing to
21 // be used when the full input is not known in advance. 16 // be used when the full input is not known in advance.
22 class CRYPTO_EXPORT SecureHash { 17 class CRYPTO_EXPORT SecureHash {
23 public: 18 public:
24 enum Algorithm { 19 enum Algorithm {
25 SHA256, 20 SHA256,
26 }; 21 };
27 virtual ~SecureHash() {} 22 virtual ~SecureHash() {}
28 23
29 static SecureHash* Create(Algorithm type); 24 static SecureHash* Create(Algorithm type);
30 25
31 virtual void Update(const void* input, size_t len) = 0; 26 virtual void Update(const void* input, size_t len) = 0;
32 virtual void Finish(void* output, size_t len) = 0; 27 virtual void Finish(void* output, size_t len) = 0;
28 virtual size_t GetHashLength() const = 0;
33 29
34 // Serialize the context, so it can be restored at a later time. 30 // Create a clone of this SecureHash. The returned clone and this both
35 // |pickle| will contain the serialized data. 31 // represent the same hash state. But from this point on, calling
36 // Returns whether or not |pickle| was filled. 32 // Update()/Finish() on either doesn't affect the state of the other.
37 virtual bool Serialize(base::Pickle* pickle) = 0; 33 virtual SecureHash* Clone() const = 0;
38
39 // Restore the context that was saved earlier.
40 // |data_iterator| allows this to be used as part of a larger pickle.
41 // |pickle| holds the saved data.
42 // Returns success or failure.
43 virtual bool Deserialize(base::PickleIterator* data_iterator) = 0;
44 34
45 protected: 35 protected:
46 SecureHash() {} 36 SecureHash() {}
47 37
48 private: 38 private:
49 DISALLOW_COPY_AND_ASSIGN(SecureHash); 39 DISALLOW_COPY_AND_ASSIGN(SecureHash);
50 }; 40 };
51 41
52 } // namespace crypto 42 } // namespace crypto
53 43
54 #endif // CRYPTO_SECURE_HASH_H_ 44 #endif // CRYPTO_SECURE_HASH_H_
OLDNEW
« no previous file with comments | « content/public/test/test_file_error_injector.cc ('k') | crypto/secure_hash_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698