1 // Copyright 2012 The Chromium Authors
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_
12 #include "crypto/crypto_export.h"
16 // A wrapper to calculate secure hashes incrementally, allowing to
17 // be used when the full input is not known in advance. The end result will the
18 // same as if we have the full input in advance.
19 class CRYPTO_EXPORT SecureHash {
26 SecureHash(const SecureHash&) = delete;
27 SecureHash& operator=(const SecureHash&) = delete;
29 virtual ~SecureHash() {}
31 static std::unique_ptr<SecureHash> Create(Algorithm type);
33 virtual void Update(const void* input, size_t len) = 0;
34 virtual void Finish(void* output, size_t len) = 0;
35 virtual size_t GetHashLength() const = 0;
37 // Create a clone of this SecureHash. The returned clone and this both
38 // represent the same hash state. But from this point on, calling
39 // Update()/Finish() on either doesn't affect the state of the other.
40 virtual std::unique_ptr<SecureHash> Clone() const = 0;
48 #endif // CRYPTO_SECURE_HASH_H_