From: Jes Sorensen <jsorensen@xxxxxx> Signed-off-by: Jes Sorensen <jsorensen@xxxxxx> --- libfsverity.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/libfsverity.h b/libfsverity.h index a2abdb3..f6c4b13 100644 --- a/libfsverity.h +++ b/libfsverity.h @@ -64,18 +64,63 @@ struct fsverity_hash_alg { struct hash_ctx *(*create_ctx)(const struct fsverity_hash_alg *alg); }; +/* + * libfsverity_compute_digest - Compute digest of a file + * @fd: open file descriptor of file to compute digest for + * @params: struct libfsverity_merkle_tree_params specifying hash algorithm, + * block size, version, and optional salt parameters. + * reserved parameters must be zero. + * @digest_ret: Pointer to pointer for computed digest + * + * Returns: + * * 0 for success, -EINVAL for invalid input arguments, -ENOMEM if failed + * to allocate memory, -EBADF if fd is invalid, and -EAGAIN if root hash + * fails to compute. + * * digest_ret returns a pointer to the digest on success. + */ int libfsverity_compute_digest(int fd, const struct libfsverity_merkle_tree_params *params, struct libfsverity_digest **digest_ret); +/* + * libfsverity_sign_digest - Sign previously computed digest of a file + * @digest: pointer to previously computed digest + * @sig_params: struct libfsverity_signature_params providing filenames of + * the keyfile and certificate file. Reserved parameters must be zero. + * @sig_ret: Pointer to pointer for signed digest + * @sig_size_ret: Pointer to size of signed return digest + * + * Returns: + * * 0 for success, -EINVAL for invalid input arguments, -EAGAIN if key or + * certificate files fail to read, or if signing the digest fails. + * * sig_ret returns a pointer to the signed digest on success. + * * sig_size_ret returns the size of the signed digest on success. + */ int libfsverity_sign_digest(const struct libfsverity_digest *digest, const struct libfsverity_signature_params *sig_params, uint8_t **sig_ret, size_t *sig_size_ret); +/* + * libfsverity_find_hash_alg_by_name - Find hash algorithm by name + * @name: Pointer to name of hash algorithm + * + * Returns: + * struct fsverity_hash_alg success + * NULL on error + */ const struct fsverity_hash_alg * libfsverity_find_hash_alg_by_name(const char *name); + +/* + * libfsverity_find_hash_alg_by_num - Find hash algorithm by number + * @name: Number of hash algorithm + * + * Returns: + * struct fsverity_hash_alg success + * NULL on error + */ const struct fsverity_hash_alg * libfsverity_find_hash_alg_by_num(unsigned int num); -- 2.24.1