| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by the GPL v2 license that can | 2 // Use of this source code is governed by the GPL v2 license that can |
| 3 // be found in the LICENSE file. | 3 // be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Defines FileHasher, a class that creates a Verity-specific file of | 5 // Defines FileHasher, a class that creates a Verity-specific file of |
| 6 // per-block hashes from a given simple_file::File. | 6 // per-block hashes from a given simple_file::File. |
| 7 #ifndef VERITY_FILE_HASHER_H__ | 7 #ifndef VERITY_FILE_HASHER_H__ |
| 8 #define VERITY_FILE_HASHER_H__ 1 | 8 #define VERITY_FILE_HASHER_H__ 1 |
| 9 | 9 |
| 10 extern "C" { | 10 extern "C" { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class FileHasher { | 21 class FileHasher { |
| 22 public: | 22 public: |
| 23 FileHasher() : source_(NULL), | 23 FileHasher() : source_(NULL), |
| 24 destination_(NULL), | 24 destination_(NULL), |
| 25 block_limit_(0), | 25 block_limit_(0), |
| 26 alg_(NULL) { } | 26 alg_(NULL) { } |
| 27 // TODO(wad) add initialized_ variable to check. | 27 // TODO(wad) add initialized_ variable to check. |
| 28 virtual ~FileHasher() { dm_bht_destroy(&tree_); } | 28 virtual ~FileHasher() { dm_bht_destroy(&tree_); } |
| 29 virtual bool Initialize(simple_file::File *source, | 29 virtual bool Initialize(simple_file::File *source, |
| 30 simple_file::File *destination, | 30 simple_file::File *destination, |
| 31 unsigned int depth, | |
| 32 unsigned int blocks, | 31 unsigned int blocks, |
| 33 const char *alg); | 32 const char *alg); |
| 34 virtual bool Hash(); | 33 virtual bool Hash(); |
| 35 virtual bool Store(); | 34 virtual bool Store(); |
| 36 // Print a table to stdout which contains a dmsetup compatible format | 35 // Print a table to stdout which contains a dmsetup compatible format |
| 37 virtual void PrintTable(bool colocated); | 36 virtual void PrintTable(bool colocated); |
| 38 | 37 |
| 39 static int WriteCallback(void *file, | 38 static int WriteCallback(void *file, |
| 40 sector_t start, | 39 sector_t start, |
| 41 u8 *dst, | 40 u8 *dst, |
| 42 sector_t count, | 41 sector_t count, |
| 43 struct dm_bht_entry *entry); | 42 struct dm_bht_entry *entry); |
| 44 private: | 43 private: |
| 45 simple_file::File *source_; | 44 simple_file::File *source_; |
| 46 simple_file::File *destination_; | 45 simple_file::File *destination_; |
| 47 unsigned int depth_; | |
| 48 unsigned int block_limit_; | 46 unsigned int block_limit_; |
| 49 const char *alg_; | 47 const char *alg_; |
| 50 struct dm_bht tree_; | 48 struct dm_bht tree_; |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 } // namespace verity | 51 } // namespace verity |
| 54 | 52 |
| 55 #endif // VERITY_FILE_HASHER_H__ | 53 #endif // VERITY_FILE_HASHER_H__ |
| OLD | NEW |