Lines Matching refs:node
23 * ubifs_node_calc_hash - calculate the hash of a UBIFS node
25 * @node: the node to calculate a hash for
30 int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node,
33 const struct ubifs_ch *ch = node;
35 return crypto_shash_tfm_digest(c->hash_tfm, node, le32_to_cpu(ch->len),
42 * @hash: the node to calculate a HMAC for
54 * ubifs_prepare_auth_node - Prepare an authentication node
56 * @node: the node to calculate a hash for
59 * This function prepares an authentication node for writing onto flash.
60 * It creates a HMAC from the given input hash and writes it to the node.
64 int ubifs_prepare_auth_node(struct ubifs_info *c, void *node,
67 struct ubifs_auth_node *auth = node;
116 * __ubifs_hash_get_desc - get a descriptor suitable for hashing a node
119 * This function returns a descriptor suitable for hashing a node. Free after use
130 * @node: the node
132 * @lnum: the LEB @node was read from
133 * @offs: offset in LEB @node was read from
135 * This function reports a hash mismatch when a node has a different hash than
138 void ubifs_bad_hash(const struct ubifs_info *c, const void *node, const u8 *hash,
147 __ubifs_node_calc_hash(c, node, calc);
149 ubifs_err(c, "hash mismatch on node at LEB %d:%d", lnum, offs);
155 * __ubifs_node_check_hash - check the hash of a node against given hash
157 * @node: the node
160 * This function calculates a hash over a node and compares it to the given hash.
164 int __ubifs_node_check_hash(const struct ubifs_info *c, const void *node,
170 err = __ubifs_node_calc_hash(c, node, calc);
183 * @sup: The superblock node
187 * node in an ubifs_sig_node.
207 ubifs_err(c, "Unable to find signature node");
215 ubifs_err(c, "Signature node is of wrong type");
220 signode = snod->node;
378 * ubifs_node_calc_hmac - calculate the HMAC of a UBIFS node
380 * @node: the node to insert a HMAC into.
381 * @len: the length of the node
382 * @ofs_hmac: the offset in the node where the HMAC is inserted
385 * This function calculates a HMAC of a UBIFS node. The HMAC is expected to be
386 * embedded into the node, so this area is not covered by the HMAC. Also not
387 * covered is the UBIFS_NODE_MAGIC and the CRC of the node.
389 static int ubifs_node_calc_hmac(const struct ubifs_info *c, const void *node,
405 /* behind common node header CRC up to HMAC begin */
406 err = crypto_shash_update(shash, node + 8, ofs_hmac - 8);
412 err = crypto_shash_update(shash, node + ofs_hmac + hmac_len,
422 * __ubifs_node_insert_hmac - insert a HMAC into a UBIFS node
424 * @node: the node to insert a HMAC into.
425 * @len: the length of the node
426 * @ofs_hmac: the offset in the node where the HMAC is inserted
428 * This function inserts a HMAC at offset @ofs_hmac into the node given in
429 * @node.
433 int __ubifs_node_insert_hmac(const struct ubifs_info *c, void *node, int len,
436 return ubifs_node_calc_hmac(c, node, len, ofs_hmac, node + ofs_hmac);
440 * __ubifs_node_verify_hmac - verify the HMAC of UBIFS node
442 * @node: the node to insert a HMAC into.
443 * @len: the length of the node
444 * @ofs_hmac: the offset in the node where the HMAC is inserted
446 * This function verifies the HMAC at offset @ofs_hmac of the node given in
447 * @node. Returns 0 if successful or a negative error code otherwise.
449 int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node,
460 err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac);
466 err = crypto_memneq(hmac, node + ofs_hmac, hmac_len);