Lines Matching refs:node
22 * ubifs_node_calc_hash - calculate the hash of a UBIFS node
24 * @node: the node to calculate a hash for
29 int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node,
32 const struct ubifs_ch *ch = node;
34 return crypto_shash_tfm_digest(c->hash_tfm, node, le32_to_cpu(ch->len),
41 * @hash: the node to calculate a HMAC for
53 * ubifs_prepare_auth_node - Prepare an authentication node
55 * @node: the node to calculate a hash for
58 * This function prepares an authentication node for writing onto flash.
59 * It creates a HMAC from the given input hash and writes it to the node.
63 int ubifs_prepare_auth_node(struct ubifs_info *c, void *node,
66 struct ubifs_auth_node *auth = node;
115 * __ubifs_hash_get_desc - get a descriptor suitable for hashing a node
118 * This function returns a descriptor suitable for hashing a node. Free after use
129 * @node: the node
131 * @lnum: the LEB @node was read from
132 * @offs: offset in LEB @node was read from
134 * This function reports a hash mismatch when a node has a different hash than
137 void ubifs_bad_hash(const struct ubifs_info *c, const void *node, const u8 *hash,
146 __ubifs_node_calc_hash(c, node, calc);
148 ubifs_err(c, "hash mismatch on node at LEB %d:%d", lnum, offs);
154 * __ubifs_node_check_hash - check the hash of a node against given hash
156 * @node: the node
159 * This function calculates a hash over a node and compares it to the given hash.
163 int __ubifs_node_check_hash(const struct ubifs_info *c, const void *node,
169 err = __ubifs_node_calc_hash(c, node, calc);
182 * @sup: The superblock node
186 * node in an ubifs_sig_node.
206 ubifs_err(c, "Unable to find signature node");
214 ubifs_err(c, "Signature node is of wrong type");
219 signode = snod->node;
377 * ubifs_node_calc_hmac - calculate the HMAC of a UBIFS node
379 * @node: the node to insert a HMAC into.
380 * @len: the length of the node
381 * @ofs_hmac: the offset in the node where the HMAC is inserted
384 * This function calculates a HMAC of a UBIFS node. The HMAC is expected to be
385 * embedded into the node, so this area is not covered by the HMAC. Also not
386 * covered is the UBIFS_NODE_MAGIC and the CRC of the node.
388 static int ubifs_node_calc_hmac(const struct ubifs_info *c, const void *node,
404 /* behind common node header CRC up to HMAC begin */
405 err = crypto_shash_update(shash, node + 8, ofs_hmac - 8);
411 err = crypto_shash_update(shash, node + ofs_hmac + hmac_len,
421 * __ubifs_node_insert_hmac - insert a HMAC into a UBIFS node
423 * @node: the node to insert a HMAC into.
424 * @len: the length of the node
425 * @ofs_hmac: the offset in the node where the HMAC is inserted
427 * This function inserts a HMAC at offset @ofs_hmac into the node given in
428 * @node.
432 int __ubifs_node_insert_hmac(const struct ubifs_info *c, void *node, int len,
435 return ubifs_node_calc_hmac(c, node, len, ofs_hmac, node + ofs_hmac);
439 * __ubifs_node_verify_hmac - verify the HMAC of UBIFS node
441 * @node: the node to insert a HMAC into.
442 * @len: the length of the node
443 * @ofs_hmac: the offset in the node where the HMAC is inserted
445 * This function verifies the HMAC at offset @ofs_hmac of the node given in
446 * @node. Returns 0 if successful or a negative error code otherwise.
448 int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node,
459 err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac);
465 err = crypto_memneq(hmac, node + ofs_hmac, hmac_len);