/* * Implementation limit: maximum depth of the Merkle tree. For now 8 is plenty; * it's enough for over U64_MAX bytes of data using SHA-256 and 4K blocks.
*/ #define FS_VERITY_MAX_LEVELS 8
/* A hash algorithm supported by fs-verity */ struct fsverity_hash_alg { constchar *name; /* crypto API name, e.g. sha256 */ unsignedint digest_size; /* digest size in bytes, e.g. 32 for SHA-256 */ unsignedint block_size; /* block size in bytes, e.g. 64 for SHA-256 */ /* * The HASH_ALGO_* constant for this algorithm. This is different from * FS_VERITY_HASH_ALG_*, which uses a different numbering scheme.
*/ enum hash_algo algo_id;
};
union fsverity_hash_ctx { struct sha256_ctx sha256; struct sha512_ctx sha512;
};
/* Merkle tree parameters: hash algorithm, initial hash state, and topology */ struct merkle_tree_params { conststruct fsverity_hash_alg *hash_alg; /* the hash algorithm */ /* initial hash state if salted, NULL if unsalted */ constunion fsverity_hash_ctx *hashstate; unsignedint digest_size; /* same as hash_alg->digest_size */ unsignedint block_size; /* size of data and tree blocks */ unsignedint hashes_per_block; /* number of hashes per tree block */ unsignedint blocks_per_page; /* PAGE_SIZE / block_size */
u8 log_digestsize; /* log2(digest_size) */
u8 log_blocksize; /* log2(block_size) */
u8 log_arity; /* log2(hashes_per_block) */
u8 log_blocks_per_page; /* log2(blocks_per_page) */ unsignedint num_levels; /* number of levels in Merkle tree */
u64 tree_size; /* Merkle tree size in bytes */ unsignedlong tree_pages; /* Merkle tree size in pages */
/* * Starting block index for each tree level, ordered from leaf level (0) * to root level ('num_levels - 1')
*/ unsignedlong level_start[FS_VERITY_MAX_LEVELS];
};
/* * fsverity_info - cached verity metadata for an inode * * When a verity file is first opened, an instance of this struct is allocated * and stored in ->i_verity_info; it remains until the inode is evicted. It * caches information about the Merkle tree that's needed to efficiently verify * data read from the file. It also caches the file digest. The Merkle tree * pages themselves are not cached here, but the filesystem may cache them.
*/ struct fsverity_info { struct merkle_tree_params tree_params;
u8 root_hash[FS_VERITY_MAX_DIGEST_SIZE];
u8 file_digest[FS_VERITY_MAX_DIGEST_SIZE]; conststruct inode *inode; unsignedlong *hash_block_verified;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.