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 3 // found in the LICENSE file. 4 5 #ifndef CRYPTO_SECURE_HASH_H_ 6 #define CRYPTO_SECURE_HASH_H_ 7 #pragma once 8 9 #include "base/basictypes.h" 10 11 namespace crypto { 12 13 // A wrapper to calculate secure hashes incrementally, allowing to 14 // be used when the full input is not known in advance. 15 class SecureHash { 16 public: 17 enum Algorithm { 18 SHA256, 19 }; ~SecureHash()20 virtual ~SecureHash() {} 21 22 static SecureHash* Create(Algorithm type); 23 24 virtual void Update(const void* input, size_t len) = 0; 25 virtual void Finish(void* output, size_t len) = 0; 26 27 protected: SecureHash()28 SecureHash() {} 29 30 private: 31 DISALLOW_COPY_AND_ASSIGN(SecureHash); 32 }; 33 34 } // namespace crypto 35 36 #endif // CRYPTO_SECURE_HASH_H_ 37