Junio C Hamano | 2f47eae | 2011-09-07 21:19:47 -0700 | [diff] [blame] | 1 | #ifndef GPG_INTERFACE_H |
| 2 | #define GPG_INTERFACE_H |
| 3 | |
Elijah Newren | ef3ca95 | 2018-08-15 10:54:05 -0700 | [diff] [blame] | 4 | struct strbuf; |
| 5 | |
Lukas Puehringer | 94240b9 | 2017-01-17 18:37:18 -0500 | [diff] [blame] | 6 | #define GPG_VERIFY_VERBOSE 1 |
| 7 | #define GPG_VERIFY_RAW 2 |
| 8 | #define GPG_VERIFY_OMIT_STATUS 4 |
brian m. carlson | ca194d5 | 2015-06-21 23:14:41 +0000 | [diff] [blame] | 9 | |
Hans Jerry Illikainen | 54887b4 | 2019-12-27 13:55:57 +0000 | [diff] [blame] | 10 | enum signature_trust_level { |
| 11 | TRUST_UNDEFINED, |
| 12 | TRUST_NEVER, |
| 13 | TRUST_MARGINAL, |
| 14 | TRUST_FULLY, |
| 15 | TRUST_ULTIMATE, |
| 16 | }; |
| 17 | |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 18 | struct signature_check { |
Michael J Gruber | 71c214c | 2014-06-23 09:05:48 +0200 | [diff] [blame] | 19 | char *payload; |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 20 | char *gpg_output; |
| 21 | char *gpg_status; |
Junio C Hamano | a50e7ca | 2014-08-14 15:31:13 -0700 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * possible "result": |
| 25 | * 0 (not checked) |
| 26 | * N (checked but no further result) |
Junio C Hamano | a50e7ca | 2014-08-14 15:31:13 -0700 | [diff] [blame] | 27 | * G (good) |
| 28 | * B (bad) |
| 29 | */ |
| 30 | char result; |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 31 | char *signer; |
| 32 | char *key; |
Michał Górny | 3daaaab | 2018-10-22 18:38:20 +0200 | [diff] [blame] | 33 | char *fingerprint; |
Michał Górny | 4de9394 | 2018-10-22 18:38:21 +0200 | [diff] [blame] | 34 | char *primary_key_fingerprint; |
Hans Jerry Illikainen | 54887b4 | 2019-12-27 13:55:57 +0000 | [diff] [blame] | 35 | enum signature_trust_level trust_level; |
Sebastian Götte | ffb6d7d | 2013-03-31 18:00:14 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
Jeff King | f80bee2 | 2018-04-13 15:18:31 -0600 | [diff] [blame] | 38 | void 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 King | e6fa6cd | 2018-04-13 15:18:32 -0600 | [diff] [blame] | 46 | size_t parse_signature(const char *buf, size_t size); |
Jeff King | f80bee2 | 2018-04-13 15:18:31 -0600 | [diff] [blame] | 47 | |
Jeff King | f80bee2 | 2018-04-13 15:18:31 -0600 | [diff] [blame] | 48 | /* |
| 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 | */ |
| 54 | int sign_buffer(struct strbuf *buffer, struct strbuf *signature, |
| 55 | const char *signing_key); |
| 56 | |
Jeff King | f80bee2 | 2018-04-13 15:18:31 -0600 | [diff] [blame] | 57 | int git_gpg_config(const char *, const char *, void *); |
| 58 | void set_signing_key(const char *); |
| 59 | const char *get_signing_key(void); |
| 60 | int check_signature(const char *payload, size_t plen, |
| 61 | const char *signature, size_t slen, |
| 62 | struct signature_check *sigc); |
| 63 | void print_signature_buffer(const struct signature_check *sigc, |
| 64 | unsigned flags); |
Junio C Hamano | 2f47eae | 2011-09-07 21:19:47 -0700 | [diff] [blame] | 65 | |
| 66 | #endif |