1#ifndef GPG_INTERFACE_H
2#define GPG_INTERFACE_H
34
struct strbuf;
56
#define GPG_VERIFY_VERBOSE 1
7#define GPG_VERIFY_RAW 2
8#define GPG_VERIFY_OMIT_STATUS 4
910
struct signature_check {
11char *payload;
12char *gpg_output;
13char *gpg_status;
1415
/*
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*/
23char result;
24char *signer;
25char *key;
26char *fingerprint;
27char *primary_key_fingerprint;
28};
2930
void signature_check_clear(struct signature_check *sigc);
3132
/*
33* Look at GPG signed content (e.g. a signed tag object), whose
34* payload is followed by a detached signature on it. Return the
35* offset where the embedded detached signature begins, or the end of
36* the data when there is no such signature.
37*/
38size_t parse_signature(const char *buf, size_t size);
3940
/*
41* Create a detached signature for the contents of "buffer" and append
42* it after "signature"; "buffer" and "signature" can be the same
43* strbuf instance, which would cause the detached signature appended
44* at the end.
45*/
46int sign_buffer(struct strbuf *buffer, struct strbuf *signature,
47const char *signing_key);
4849
/*
50* Run "gpg" to see if the payload matches the detached signature.
51* gpg_output, when set, receives the diagnostic output from GPG.
52* gpg_status, when set, receives the status output from GPG.
53*/
54int verify_signed_buffer(const char *payload, size_t payload_size,
55const char *signature, size_t signature_size,
56struct strbuf *gpg_output, struct strbuf *gpg_status);
5758
int git_gpg_config(const char *, const char *, void *);
59void set_signing_key(const char *);
60const char *get_signing_key(void);
61int check_signature(const char *payload, size_t plen,
62const char *signature, size_t slen,
63struct signature_check *sigc);
64void print_signature_buffer(const struct signature_check *sigc,
65unsigned flags);
6667
#endif