blob: f4e9b4f3715a0b0d4be3ef526388bf6b87b56fda [file] [log] [blame]
Junio C Hamano2f47eae2011-09-07 21:19:47 -07001#ifndef GPG_INTERFACE_H
2#define GPG_INTERFACE_H
3
Elijah Newrenef3ca952018-08-15 10:54:05 -07004struct strbuf;
5
Lukas Puehringer94240b92017-01-17 18:37:18 -05006#define GPG_VERIFY_VERBOSE 1
7#define GPG_VERIFY_RAW 2
8#define GPG_VERIFY_OMIT_STATUS 4
brian m. carlsonca194d52015-06-21 23:14:41 +00009
Hans Jerry Illikainen54887b42019-12-27 13:55:57 +000010enum signature_trust_level {
11 TRUST_UNDEFINED,
12 TRUST_NEVER,
13 TRUST_MARGINAL,
14 TRUST_FULLY,
15 TRUST_ULTIMATE,
16};
17
Sebastian Götteffb6d7d2013-03-31 18:00:14 +020018struct signature_check {
Michael J Gruber71c214c2014-06-23 09:05:48 +020019 char *payload;
Sebastian Götteffb6d7d2013-03-31 18:00:14 +020020 char *gpg_output;
21 char *gpg_status;
Junio C Hamanoa50e7ca2014-08-14 15:31:13 -070022
23 /*
24 * possible "result":
25 * 0 (not checked)
26 * N (checked but no further result)
Junio C Hamanoa50e7ca2014-08-14 15:31:13 -070027 * G (good)
28 * B (bad)
29 */
30 char result;
Sebastian Götteffb6d7d2013-03-31 18:00:14 +020031 char *signer;
32 char *key;
Michał Górny3daaaab2018-10-22 18:38:20 +020033 char *fingerprint;
Michał Górny4de93942018-10-22 18:38:21 +020034 char *primary_key_fingerprint;
Hans Jerry Illikainen54887b42019-12-27 13:55:57 +000035 enum signature_trust_level trust_level;
Sebastian Götteffb6d7d2013-03-31 18:00:14 +020036};
37
Jeff Kingf80bee22018-04-13 15:18:31 -060038void signature_check_clear(struct signature_check *sigc);
39
40/*
41 * Look at GPG signed content (e.g. a signed tag object), whose
42 * payload is followed by a detached signature on it. Return the
43 * offset where the embedded detached signature begins, or the end of
44 * the data when there is no such signature.
45 */
Jeff Kinge6fa6cd2018-04-13 15:18:32 -060046size_t parse_signature(const char *buf, size_t size);
Jeff Kingf80bee22018-04-13 15:18:31 -060047
Jeff Kingf80bee22018-04-13 15:18:31 -060048/*
49 * Create a detached signature for the contents of "buffer" and append
50 * it after "signature"; "buffer" and "signature" can be the same
51 * strbuf instance, which would cause the detached signature appended
52 * at the end.
53 */
54int sign_buffer(struct strbuf *buffer, struct strbuf *signature,
55 const char *signing_key);
56
Jeff Kingf80bee22018-04-13 15:18:31 -060057int git_gpg_config(const char *, const char *, void *);
58void set_signing_key(const char *);
59const char *get_signing_key(void);
60int check_signature(const char *payload, size_t plen,
61 const char *signature, size_t slen,
62 struct signature_check *sigc);
63void print_signature_buffer(const struct signature_check *sigc,
64 unsigned flags);
Junio C Hamano2f47eae2011-09-07 21:19:47 -070065
66#endif