| 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 // Implementation of FileHasher | 5 // Implementation of FileHasher |
| 6 | 6 |
| 7 #define __STDC_LIMIT_MACROS 1 | 7 #define __STDC_LIMIT_MACROS 1 |
| 8 #define __STDC_FORMAT_MACROS 1 | 8 #define __STDC_FORMAT_MACROS 1 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <inttypes.h> | 10 #include <inttypes.h> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 block_limit_ = blocks; | 77 block_limit_ = blocks; |
| 78 | 78 |
| 79 // Now we initialize the tree | 79 // Now we initialize the tree |
| 80 if (dm_bht_create(&tree_, depth_, block_limit_, alg_)) { | 80 if (dm_bht_create(&tree_, depth_, block_limit_, alg_)) { |
| 81 LOG(ERROR) << "Could not create the BH tree"; | 81 LOG(ERROR) << "Could not create the BH tree"; |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 dm_bht_set_write_cb(&tree_, FileHasher::WriteCallback); | 84 dm_bht_set_write_cb(&tree_, FileHasher::WriteCallback); |
| 85 // No reading is needed. | 85 // No reading is needed. |
| 86 dm_bht_set_read_cb(&tree_, dm_bht_zeroread_callback); | 86 dm_bht_set_read_cb(&tree_, dm_bht_zeroread_callback); |
| 87 // Ensure that we don't use the bitmaps otherwise the | |
| 88 // hashes will be wrong in intermediate nodes. | |
| 89 dm_bht_set_verify_mode(&tree_, DM_BHT_FULL_REVERIFY); | |
| 90 | 87 |
| 91 return true; | 88 return true; |
| 92 } | 89 } |
| 93 | 90 |
| 94 bool FileHasher::Store() { | 91 bool FileHasher::Store() { |
| 95 return !dm_bht_sync(&tree_, reinterpret_cast<void *>(destination_)); | 92 return !dm_bht_sync(&tree_, reinterpret_cast<void *>(destination_)); |
| 96 } | 93 } |
| 97 | 94 |
| 98 bool FileHasher::Hash() { | 95 bool FileHasher::Hash() { |
| 99 // TODO(wad) abstract size when dm-bht needs to do break from PAGE_SIZE | 96 // TODO(wad) abstract size when dm-bht needs to do break from PAGE_SIZE |
| (...skipping 23 matching lines...) Expand all Loading... |
| 123 unsigned int hash_start = 0; | 120 unsigned int hash_start = 0; |
| 124 unsigned int root_end = to_sector(block_limit_ << PAGE_SHIFT); | 121 unsigned int root_end = to_sector(block_limit_ << PAGE_SHIFT); |
| 125 if (colocated) hash_start = root_end; | 122 if (colocated) hash_start = root_end; |
| 126 printf("0 %u verity ROOT_DEV HASH_DEV %u %u %s %s\n", | 123 printf("0 %u verity ROOT_DEV HASH_DEV %u %u %s %s\n", |
| 127 root_end, hash_start, depth_, alg_, digest); | 124 root_end, hash_start, depth_, alg_, digest); |
| 128 } | 125 } |
| 129 | 126 |
| 130 } // namespace verity | 127 } // namespace verity |
| 131 | 128 |
| 132 | 129 |
| OLD | NEW |