1*3bd94003SHeinz Mauelshagen /* SPDX-License-Identifier: GPL-2.0-only */
288cd3e6cSJaskaran Khurana /*
388cd3e6cSJaskaran Khurana * Copyright (C) 2019 Microsoft Corporation.
488cd3e6cSJaskaran Khurana *
588cd3e6cSJaskaran Khurana * Author: Jaskaran Singh Khurana <jaskarankhurana@linux.microsoft.com>
688cd3e6cSJaskaran Khurana *
788cd3e6cSJaskaran Khurana */
888cd3e6cSJaskaran Khurana #ifndef DM_VERITY_SIG_VERIFICATION_H
988cd3e6cSJaskaran Khurana #define DM_VERITY_SIG_VERIFICATION_H
1088cd3e6cSJaskaran Khurana
1188cd3e6cSJaskaran Khurana #define DM_VERITY_ROOT_HASH_VERIFICATION "DM Verity Sig Verification"
1288cd3e6cSJaskaran Khurana #define DM_VERITY_ROOT_HASH_VERIFICATION_OPT_SIG_KEY "root_hash_sig_key_desc"
1388cd3e6cSJaskaran Khurana
1488cd3e6cSJaskaran Khurana struct dm_verity_sig_opts {
1588cd3e6cSJaskaran Khurana unsigned int sig_size;
1688cd3e6cSJaskaran Khurana u8 *sig;
1788cd3e6cSJaskaran Khurana };
1888cd3e6cSJaskaran Khurana
1988cd3e6cSJaskaran Khurana #ifdef CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG
2088cd3e6cSJaskaran Khurana
2188cd3e6cSJaskaran Khurana #define DM_VERITY_ROOT_HASH_VERIFICATION_OPTS 2
2288cd3e6cSJaskaran Khurana
2388cd3e6cSJaskaran Khurana int verity_verify_root_hash(const void *data, size_t data_len,
2488cd3e6cSJaskaran Khurana const void *sig_data, size_t sig_len);
2588cd3e6cSJaskaran Khurana bool verity_verify_is_sig_opt_arg(const char *arg_name);
2688cd3e6cSJaskaran Khurana
2788cd3e6cSJaskaran Khurana int verity_verify_sig_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
2888cd3e6cSJaskaran Khurana struct dm_verity_sig_opts *sig_opts,
2988cd3e6cSJaskaran Khurana unsigned int *argc, const char *arg_name);
3088cd3e6cSJaskaran Khurana
3188cd3e6cSJaskaran Khurana void verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts *sig_opts);
3288cd3e6cSJaskaran Khurana
3388cd3e6cSJaskaran Khurana #else
3488cd3e6cSJaskaran Khurana
3588cd3e6cSJaskaran Khurana #define DM_VERITY_ROOT_HASH_VERIFICATION_OPTS 0
3688cd3e6cSJaskaran Khurana
verity_verify_root_hash(const void * data,size_t data_len,const void * sig_data,size_t sig_len)37a84c4308SDamien Le Moal static inline int verity_verify_root_hash(const void *data, size_t data_len,
3888cd3e6cSJaskaran Khurana const void *sig_data, size_t sig_len)
3988cd3e6cSJaskaran Khurana {
4088cd3e6cSJaskaran Khurana return 0;
4188cd3e6cSJaskaran Khurana }
4288cd3e6cSJaskaran Khurana
verity_verify_is_sig_opt_arg(const char * arg_name)43a84c4308SDamien Le Moal static inline bool verity_verify_is_sig_opt_arg(const char *arg_name)
4488cd3e6cSJaskaran Khurana {
4588cd3e6cSJaskaran Khurana return false;
4688cd3e6cSJaskaran Khurana }
4788cd3e6cSJaskaran Khurana
verity_verify_sig_parse_opt_args(struct dm_arg_set * as,struct dm_verity * v,struct dm_verity_sig_opts * sig_opts,unsigned int * argc,const char * arg_name)48a84c4308SDamien Le Moal static inline int verity_verify_sig_parse_opt_args(struct dm_arg_set *as,
49a84c4308SDamien Le Moal struct dm_verity *v, struct dm_verity_sig_opts *sig_opts,
5088cd3e6cSJaskaran Khurana unsigned int *argc, const char *arg_name)
5188cd3e6cSJaskaran Khurana {
5288cd3e6cSJaskaran Khurana return -EINVAL;
5388cd3e6cSJaskaran Khurana }
5488cd3e6cSJaskaran Khurana
verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts * sig_opts)55a84c4308SDamien Le Moal static inline void verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts *sig_opts)
5688cd3e6cSJaskaran Khurana {
5788cd3e6cSJaskaran Khurana }
5888cd3e6cSJaskaran Khurana
5988cd3e6cSJaskaran Khurana #endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */
6088cd3e6cSJaskaran Khurana #endif /* DM_VERITY_SIG_VERIFICATION_H */
61