]> git.ozlabs.org Git - petitboot/blob - lib/security/gpg.h
fb418bb23957c5128b82c68d5f95c1197225714e
[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 };
27
28 #if defined(HAVE_LIBGPGME)
29 #include <gpgme.h>
30 #endif /* HAVE_LIBGPGME */
31
32 int lockdown_status(void);
33
34 struct pb_url * gpg_get_signature_url(void *ctx, struct pb_url *base_file);
35
36 int verify_file_signature(const char *plaintext_filename,
37         const char *signature_filename, FILE *authorized_signatures_handle,
38         const char *keyring_path);
39
40 int gpg_validate_boot_files(struct boot_task *boot_task);
41
42 void gpg_validate_boot_files_cleanup(struct boot_task *boot_task);
43
44 #if !defined(HAVE_LIBGPGME)
45
46 int lockdown_status(void) { return PB_LOCKDOWN_NONE; }
47
48 struct pb_url * gpg_get_signature_url(void *ctx __attribute__((unused)),
49                         struct pb_url *base_file __attribute__((unused)))
50 {
51         return NULL;
52 }
53
54 int verify_file_signature(const char *plaintext_filename __attribute__((unused)),
55         const char *signature_filename __attribute__((unused)),
56         FILE *authorized_signatures_handle __attribute__((unused)),
57         const char *keyring_path __attribute__((unused)))
58 {
59         return -1;
60 }
61
62 int gpg_validate_boot_files(struct boot_task *boot_task __attribute__((unused)))
63 {
64         return 0;
65 }
66
67 void gpg_validate_boot_files_cleanup(struct boot_task *boot_task __attribute__((unused)))
68 {}
69
70 #endif /* HAVE_LIBGPGME */
71
72 #endif /* _PB_GPG_H */