]>
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 | |
54887b46 HJI |
10 | enum signature_trust_level { |
11 | TRUST_UNDEFINED, | |
12 | TRUST_NEVER, | |
13 | TRUST_MARGINAL, | |
14 | TRUST_FULLY, | |
15 | TRUST_ULTIMATE, | |
16 | }; | |
17 | ||
ffb6d7d5 | 18 | struct signature_check { |
71c214c8 | 19 | char *payload; |
b5726a5d | 20 | char *output; |
ffb6d7d5 | 21 | char *gpg_status; |
a50e7ca3 JH |
22 | |
23 | /* | |
24 | * possible "result": | |
25 | * 0 (not checked) | |
26 | * N (checked but no further result) | |
a50e7ca3 JH |
27 | * G (good) |
28 | * B (bad) | |
29 | */ | |
30 | char result; | |
ffb6d7d5 SG |
31 | char *signer; |
32 | char *key; | |
3daaaabe | 33 | char *fingerprint; |
4de9394d | 34 | char *primary_key_fingerprint; |
54887b46 | 35 | enum signature_trust_level trust_level; |
ffb6d7d5 SG |
36 | }; |
37 | ||
f80bee27 JK |
38 | void signature_check_clear(struct signature_check *sigc); |
39 | ||
482c1191 | 40 | /* |
41 | * Look at a GPG signed tag object. If such a signature exists, store it in | |
42 | * signature and the signed content in payload. Return 1 if a signature was | |
43 | * found, and 0 otherwise. | |
44 | */ | |
45 | int parse_signature(const char *buf, size_t size, struct strbuf *payload, struct strbuf *signature); | |
46 | ||
f80bee27 JK |
47 | /* |
48 | * Look at GPG signed content (e.g. a signed tag object), whose | |
49 | * payload is followed by a detached signature on it. Return the | |
50 | * offset where the embedded detached signature begins, or the end of | |
51 | * the data when there is no such signature. | |
52 | */ | |
482c1191 | 53 | size_t parse_signed_buffer(const char *buf, size_t size); |
f80bee27 | 54 | |
f80bee27 JK |
55 | /* |
56 | * Create a detached signature for the contents of "buffer" and append | |
57 | * it after "signature"; "buffer" and "signature" can be the same | |
58 | * strbuf instance, which would cause the detached signature appended | |
59 | * at the end. | |
60 | */ | |
61 | int sign_buffer(struct strbuf *buffer, struct strbuf *signature, | |
62 | const char *signing_key); | |
63 | ||
f80bee27 JK |
64 | int git_gpg_config(const char *, const char *, void *); |
65 | void set_signing_key(const char *); | |
66 | const char *get_signing_key(void); | |
4838f62c FS |
67 | |
68 | /* | |
69 | * Returns a textual unique representation of the signing key in use | |
70 | * Either a GPG KeyID or a SSH Key Fingerprint | |
71 | */ | |
72 | const char *get_signing_key_id(void); | |
f80bee27 JK |
73 | int check_signature(const char *payload, size_t plen, |
74 | const char *signature, size_t slen, | |
75 | struct signature_check *sigc); | |
76 | void print_signature_buffer(const struct signature_check *sigc, | |
77 | unsigned flags); | |
2f47eae2 JH |
78 | |
79 | #endif |