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

Side by Side Diff: crypto/secure_hash.h

Issue 8588057: Added serialization to SecureHash. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added a serialization unit test for SecureHash. Created 9 years, 1 month 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 | « no previous file | crypto/secure_hash_default.cc » ('j') | crypto/secure_hash_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "crypto/crypto_export.h" 10 #include "crypto/crypto_export.h"
11 11
12 class Pickle;
13
12 namespace crypto { 14 namespace crypto {
13 15
14 // A wrapper to calculate secure hashes incrementally, allowing to 16 // A wrapper to calculate secure hashes incrementally, allowing to
15 // be used when the full input is not known in advance. 17 // be used when the full input is not known in advance.
16 class CRYPTO_EXPORT SecureHash { 18 class CRYPTO_EXPORT SecureHash {
17 public: 19 public:
18 enum Algorithm { 20 enum Algorithm {
19 SHA256, 21 SHA256,
20 }; 22 };
21 virtual ~SecureHash() {} 23 virtual ~SecureHash() {}
22 24
23 static SecureHash* Create(Algorithm type); 25 static SecureHash* Create(Algorithm type);
24 26
25 virtual void Update(const void* input, size_t len) = 0; 27 virtual void Update(const void* input, size_t len) = 0;
26 virtual void Finish(void* output, size_t len) = 0; 28 virtual void Finish(void* output, size_t len) = 0;
27 29
30 // Serialize the context, so it can be restored at a later time.
31 // |pickle| will contain the serialized data.
32 // Returns whether or not |pickle| was filled.
33 virtual bool Serialize(Pickle* pickle) = 0;
34
35 // Restore the context that was saved earlier.
Randy Smith (Not in Mondays) 2011/11/18 19:01:47 Maybe worthwhile indicating that it will wipe out
ahendrickson 2011/11/18 19:47:00 I don't believe that we can currently have both NS
36 // |pickle| holds the saved data.
37 // Returns success or failure.
38 virtual bool Deserialize(Pickle* pickle) = 0;
39
28 protected: 40 protected:
29 SecureHash() {} 41 SecureHash() {}
30 42
31 private: 43 private:
32 DISALLOW_COPY_AND_ASSIGN(SecureHash); 44 DISALLOW_COPY_AND_ASSIGN(SecureHash);
33 }; 45 };
34 46
35 } // namespace crypto 47 } // namespace crypto
36 48
37 #endif // CRYPTO_SECURE_HASH_H_ 49 #endif // CRYPTO_SECURE_HASH_H_
OLDNEW
« no previous file with comments | « no previous file | crypto/secure_hash_default.cc » ('j') | crypto/secure_hash_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698