^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2019 Microsoft Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Author: Jaskaran Singh Khurana <jaskarankhurana@linux.microsoft.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef DM_VERITY_SIG_VERIFICATION_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define DM_VERITY_SIG_VERIFICATION_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define DM_VERITY_ROOT_HASH_VERIFICATION "DM Verity Sig Verification"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define DM_VERITY_ROOT_HASH_VERIFICATION_OPT_SIG_KEY "root_hash_sig_key_desc"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct dm_verity_sig_opts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) unsigned int sig_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) u8 *sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifdef CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define DM_VERITY_ROOT_HASH_VERIFICATION_OPTS 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int verity_verify_root_hash(const void *data, size_t data_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) const void *sig_data, size_t sig_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) bool verity_verify_is_sig_opt_arg(const char *arg_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int verity_verify_sig_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct dm_verity_sig_opts *sig_opts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int *argc, const char *arg_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts *sig_opts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define DM_VERITY_ROOT_HASH_VERIFICATION_OPTS 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static inline int verity_verify_root_hash(const void *data, size_t data_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const void *sig_data, size_t sig_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static inline bool verity_verify_is_sig_opt_arg(const char *arg_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline int verity_verify_sig_parse_opt_args(struct dm_arg_set *as,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct dm_verity *v, struct dm_verity_sig_opts *sig_opts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int *argc, const char *arg_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static inline void verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts *sig_opts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif /* DM_VERITY_SIG_VERIFICATION_H */