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_
12 #include "base/macros.h"
13 #include "crypto/crypto_export.h"
17 // A wrapper to calculate secure hashes incrementally, allowing to
18 // be used when the full input is not known in advance. The end result will the
19 // same as if we have the full input in advance.
20 class CRYPTO_EXPORT SecureHash {
25 virtual ~SecureHash() {}
27 static std::unique_ptr<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;
31 virtual size_t GetHashLength() const = 0;
33 // Create a clone of this SecureHash. The returned clone and this both
34 // represent the same hash state. But from this point on, calling
35 // Update()/Finish() on either doesn't affect the state of the other.
36 virtual std::unique_ptr<SecureHash> Clone() const = 0;
42 DISALLOW_COPY_AND_ASSIGN(SecureHash);
47 #endif // CRYPTO_SECURE_HASH_H_