]>
Commit | Line | Data |
---|---|---|
2f47eae2 JH |
1 | #ifndef GPG_INTERFACE_H |
2 | #define GPG_INTERFACE_H | |
3 | ||
ef3ca954 EN |
4 | struct strbuf; |
5 | ||
94240b91 LP |
6 | #define GPG_VERIFY_VERBOSE 1 |
7 | #define GPG_VERIFY_RAW 2 | |
8 | #define GPG_VERIFY_OMIT_STATUS 4 | |
ca194d50 | 9 | |
ffb6d7d5 | 10 | struct signature_check { |
71c214c8 | 11 | char *payload; |
ffb6d7d5 SG |
12 | char *gpg_output; |
13 | char *gpg_status; | |
a50e7ca3 JH |
14 | |
15 | /* | |
16 | * possible "result": | |
17 | * 0 (not checked) | |
18 | * N (checked but no further result) | |
19 | * U (untrusted good) | |
20 | * G (good) | |
21 | * B (bad) | |
22 | */ | |
23 | char result; | |
ffb6d7d5 SG |
24 | char *signer; |
25 | char *key; | |
26 | }; | |
27 | ||
f80bee27 JK |
28 | void signature_check_clear(struct signature_check *sigc); |
29 | ||
30 | /* | |
31 | * Look at GPG signed content (e.g. a signed tag object), whose | |
32 | * payload is followed by a detached signature on it. Return the | |
33 | * offset where the embedded detached signature begins, or the end of | |
34 | * the data when there is no such signature. | |
35 | */ | |
e6fa6cde | 36 | size_t parse_signature(const char *buf, size_t size); |
f80bee27 | 37 | |
f80bee27 JK |
38 | /* |
39 | * Create a detached signature for the contents of "buffer" and append | |
40 | * it after "signature"; "buffer" and "signature" can be the same | |
41 | * strbuf instance, which would cause the detached signature appended | |
42 | * at the end. | |
43 | */ | |
44 | int sign_buffer(struct strbuf *buffer, struct strbuf *signature, | |
45 | const char *signing_key); | |
46 | ||
47 | /* | |
48 | * Run "gpg" to see if the payload matches the detached signature. | |
49 | * gpg_output, when set, receives the diagnostic output from GPG. | |
50 | * gpg_status, when set, receives the status output from GPG. | |
51 | */ | |
52 | int verify_signed_buffer(const char *payload, size_t payload_size, | |
53 | const char *signature, size_t signature_size, | |
54 | struct strbuf *gpg_output, struct strbuf *gpg_status); | |
55 | ||
56 | int git_gpg_config(const char *, const char *, void *); | |
57 | void set_signing_key(const char *); | |
58 | const char *get_signing_key(void); | |
59 | int check_signature(const char *payload, size_t plen, | |
60 | const char *signature, size_t slen, | |
61 | struct signature_check *sigc); | |
62 | void print_signature_buffer(const struct signature_check *sigc, | |
63 | unsigned flags); | |
2f47eae2 JH |
64 | |
65 | #endif |