]> git.ozlabs.org Git - petitboot/blob - lib/security/gpg.h
discover: Handle and track plugin_options
[petitboot] / lib / security / gpg.h
1 /*
2  *  Copyright (C) 2016 Raptor Engineering, LLC
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17
18 #ifndef _PB_GPG_H
19 #define _PB_GPG_H
20
21 #include <discover/boot.h>
22
23 enum {
24         PB_LOCKDOWN_NONE        = 0,
25         PB_LOCKDOWN_SIGN        = 1,
26         PB_LOCKDOWN_DECRYPT     = 2,
27 };
28
29 #if defined(HAVE_LIBGPGME)
30 #include <gpgme.h>
31 #endif /* HAVE_LIBGPGME */
32
33 int lockdown_status(void);
34
35 struct pb_url * gpg_get_signature_url(void *ctx, struct pb_url *base_file);
36
37 int verify_file_signature(const char *plaintext_filename,
38         const char *signature_filename, FILE *authorized_signatures_handle,
39         const char *keyring_path);
40
41 int decrypt_file(const char * filename,
42         FILE * authorized_signatures_handle, const char * keyring_path);
43
44 int gpg_validate_boot_files(struct boot_task *boot_task);
45
46 void gpg_validate_boot_files_cleanup(struct boot_task *boot_task);
47
48 #if !defined(HAVE_LIBGPGME)
49
50 int lockdown_status(void) { return PB_LOCKDOWN_NONE; }
51
52 struct pb_url * gpg_get_signature_url(void *ctx __attribute__((unused)),
53                         struct pb_url *base_file __attribute__((unused)))
54 {
55         return NULL;
56 }
57
58 int verify_file_signature(const char *plaintext_filename __attribute__((unused)),
59         const char *signature_filename __attribute__((unused)),
60         FILE *authorized_signatures_handle __attribute__((unused)),
61         const char *keyring_path __attribute__((unused)))
62 {
63         return -1;
64 }
65
66 int decrypt_file(const char * filename __attribute__((unused)),
67         FILE * authorized_signatures_handle __attribute__((unused)),
68         const char * keyring_path __attribute__((unused)))
69 {
70         return -1;
71 }
72
73 int gpg_validate_boot_files(struct boot_task *boot_task __attribute__((unused)))
74 {
75         return 0;
76 }
77
78 void gpg_validate_boot_files_cleanup(struct boot_task *boot_task __attribute__((unused)))
79 {}
80
81 #endif /* HAVE_LIBGPGME */
82
83 #endif /* _PB_GPG_H */