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