1 #ifndef GPG_INTERFACE_H
2 #define GPG_INTERFACE_H
6 #define GPG_VERIFY_VERBOSE 1
7 #define GPG_VERIFY_RAW 2
8 #define GPG_VERIFY_OMIT_STATUS 4
10 enum signature_trust_level
{
19 SIGNATURE_PAYLOAD_UNDEFINED
,
20 SIGNATURE_PAYLOAD_COMMIT
,
21 SIGNATURE_PAYLOAD_TAG
,
22 SIGNATURE_PAYLOAD_PUSH_CERT
,
25 struct signature_check
{
28 enum payload_type payload_type
;
29 timestamp_t payload_timestamp
;
36 * N (checked but no further result)
44 char *primary_key_fingerprint
;
45 enum signature_trust_level trust_level
;
48 void signature_check_clear(struct signature_check
*sigc
);
51 * Look at a GPG signed tag object. If such a signature exists, store it in
52 * signature and the signed content in payload. Return 1 if a signature was
53 * found, and 0 otherwise.
55 int parse_signature(const char *buf
, size_t size
, struct strbuf
*payload
, struct strbuf
*signature
);
58 * Look at GPG signed content (e.g. a signed tag object), whose
59 * payload is followed by a detached signature on it. Return the
60 * offset where the embedded detached signature begins, or the end of
61 * the data when there is no such signature.
63 size_t parse_signed_buffer(const char *buf
, size_t size
);
66 * Create a detached signature for the contents of "buffer" and append
67 * it after "signature"; "buffer" and "signature" can be the same
68 * strbuf instance, which would cause the detached signature appended
69 * at the end. Returns 0 on success, non-zero on failure.
71 int sign_buffer(struct strbuf
*buffer
, struct strbuf
*signature
,
72 const char *signing_key
);
76 * Returns corresponding string in lowercase for a given member of
77 * enum signature_trust_level. For example, `TRUST_ULTIMATE` will
80 const char *gpg_trust_level_to_str(enum signature_trust_level level
);
82 void set_signing_key(const char *);
83 char *get_signing_key(void);
86 * Returns a textual unique representation of the signing key in use
87 * Either a GPG KeyID or a SSH Key Fingerprint
89 char *get_signing_key_id(void);
90 int check_signature(struct signature_check
*sigc
,
91 const char *signature
, size_t slen
);
92 void print_signature_buffer(const struct signature_check
*sigc
,