blob: 3987c7141f79af8189b60d4ed0ad8359a1ae8abd [file] [log] [blame]
Jaskaran Khurana88cd3e62019-07-17 17:46:15 -07001// SPDX-License-Identifier: GPL-2.0
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
14struct 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
23int verity_verify_root_hash(const void *data, size_t data_len,
24 const void *sig_data, size_t sig_len);
25bool verity_verify_is_sig_opt_arg(const char *arg_name);
26
27int 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
31void 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
Damien Le Moala84c4302020-07-16 13:38:12 +090037static inline int verity_verify_root_hash(const void *data, size_t data_len,
38 const void *sig_data, size_t sig_len)
Jaskaran Khurana88cd3e62019-07-17 17:46:15 -070039{
40 return 0;
41}
42
Damien Le Moala84c4302020-07-16 13:38:12 +090043static inline bool verity_verify_is_sig_opt_arg(const char *arg_name)
Jaskaran Khurana88cd3e62019-07-17 17:46:15 -070044{
45 return false;
46}
47
Damien Le Moala84c4302020-07-16 13:38:12 +090048static 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)
Jaskaran Khurana88cd3e62019-07-17 17:46:15 -070051{
52 return -EINVAL;
53}
54
Damien Le Moala84c4302020-07-16 13:38:12 +090055static inline void verity_verify_sig_opts_cleanup(struct dm_verity_sig_opts *sig_opts)
Jaskaran Khurana88cd3e62019-07-17 17:46:15 -070056{
57}
58
59#endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */
60#endif /* DM_VERITY_SIG_VERIFICATION_H */