athena: Re-add ui_chromeos resources in athena_resources.pak.
[chromium-blink-merge.git] / crypto / secure_hash.h
blob173fd0a8a3ed877d0a68adcdb47a703b394dbee6
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"
11 class Pickle;
12 class PickleIterator;
14 namespace crypto {
16 // A wrapper to calculate secure hashes incrementally, allowing to
17 // be used when the full input is not known in advance.
18 class CRYPTO_EXPORT SecureHash {
19 public:
20 enum Algorithm {
21 SHA256,
23 virtual ~SecureHash() {}
25 static SecureHash* Create(Algorithm type);
27 virtual void Update(const void* input, size_t len) = 0;
28 virtual void Finish(void* output, size_t len) = 0;
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;
35 // Restore the context that was saved earlier.
36 // |data_iterator| allows this to be used as part of a larger pickle.
37 // |pickle| holds the saved data.
38 // Returns success or failure.
39 virtual bool Deserialize(PickleIterator* data_iterator) = 0;
41 protected:
42 SecureHash() {}
44 private:
45 DISALLOW_COPY_AND_ASSIGN(SecureHash);
48 } // namespace crypto
50 #endif // CRYPTO_SECURE_HASH_H_