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
3 // found in the LICENSE file.
5 #ifndef CRYPTO_SECURE_HASH_H_
6 #define CRYPTO_SECURE_HASH_H_
8 #include "base/basictypes.h"
9 #include "crypto/crypto_export.h"
18 // A wrapper to calculate secure hashes incrementally, allowing to
19 // be used when the full input is not known in advance.
20 class CRYPTO_EXPORT SecureHash
{
25 virtual ~SecureHash() {}
27 static SecureHash
* Create(Algorithm type
);
29 virtual void Update(const void* input
, size_t len
) = 0;
30 virtual void Finish(void* output
, size_t len
) = 0;
32 // Serialize the context, so it can be restored at a later time.
33 // |pickle| will contain the serialized data.
34 // Returns whether or not |pickle| was filled.
35 virtual bool Serialize(base::Pickle
* pickle
) = 0;
37 // Restore the context that was saved earlier.
38 // |data_iterator| allows this to be used as part of a larger pickle.
39 // |pickle| holds the saved data.
40 // Returns success or failure.
41 virtual bool Deserialize(base::PickleIterator
* data_iterator
) = 0;
47 DISALLOW_COPY_AND_ASSIGN(SecureHash
);
52 #endif // CRYPTO_SECURE_HASH_H_