Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/gpg-interface.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / gpg-interface.h` 135 lines ยท 3645 bytes Raw Blame History 1 #ifndef GPG_INTERFACE_H 2 #define GPG_INTERFACE_H 3 4 struct strbuf; 5 6 #define GPG_VERIFY_VERBOSE (1<<0) 7 #define GPG_VERIFY_RAW (1<<1) 8 #define GPG_VERIFY_OMIT_STATUS (1<<2) 9 10 enum signature_trust_level { 11 TRUST_UNDEFINED, 12 TRUST_NEVER, 13 TRUST_MARGINAL, 14 TRUST_FULLY, 15 TRUST_ULTIMATE, 16 }; 17 18 enum payload_type { 19 SIGNATURE_PAYLOAD_UNDEFINED, 20 SIGNATURE_PAYLOAD_COMMIT, 21 SIGNATURE_PAYLOAD_TAG, 22 SIGNATURE_PAYLOAD_PUSH_CERT, 23 }; 24 25 struct signature_check { 26 char *payload; 27 size_t payload_len; 28 enum payload_type payload_type; 29 timestamp_t payload_timestamp; 30 char *output; 31 char *gpg_status; 32 33 /* 34 * possible "result": 35 * 0 (not checked) 36 * N (checked but no further result) 37 * G (good) 38 * B (bad) 39 */ 40 char result; 41 char *signer; 42 char *key; 43 char *fingerprint; 44 char *primary_key_fingerprint; 45 enum signature_trust_level trust_level; 46 }; 47 48 void signature_check_clear(struct signature_check *sigc); 49 50 /* 51 * Return the format of the signature (like "openpgp", "x509", "ssh" 52 * or "unknown"). 53 */ 54 const char *get_signature_format(const char *buf); 55 56 /* 57 * Is the signature format valid (like "openpgp", "x509", "ssh" or 58 * "unknown") 59 */ 60 int valid_signature_format(const char *format); 61 62 /* 63 * Look at a GPG signed tag object. If such a signature exists, store it in 64 * signature and the signed content in payload. Return 1 if a signature was 65 * found, and 0 otherwise. 66 */ 67 int parse_signature(const char *buf, size_t size, struct strbuf *payload, struct strbuf *signature); 68 69 /* 70 * Look at GPG signed content (e.g. a signed tag object), whose 71 * payload is followed by a detached signature on it. Return the 72 * offset where the embedded detached signature begins, or the end of 73 * the data when there is no such signature. 74 */ 75 size_t parse_signed_buffer(const char *buf, size_t size); 76 77 /* Flags for sign_buffer(). */ 78 enum sign_buffer_flags { 79 /* 80 * Use the default configured signing key as returned by `get_signing_key()` 81 * when the provided "signing_key" is NULL or empty. 82 */ 83 SIGN_BUFFER_USE_DEFAULT_KEY = (1 << 0), 84 }; 85 86 /* 87 * Create a detached signature for the contents of "buffer" and append 88 * it after "signature"; "buffer" and "signature" can be the same 89 * strbuf instance, which would cause the detached signature appended 90 * at the end. Returns 0 on success, non-zero on failure. 91 */ 92 int sign_buffer(struct strbuf *buffer, struct strbuf *signature, 93 const char *signing_key, enum sign_buffer_flags flags); 94 95 /* 96 * Returns corresponding string in lowercase for a given member of 97 * enum signature_trust_level. For example, `TRUST_ULTIMATE` will 98 * return "ultimate". 99 */ 100 const char *gpg_trust_level_to_str(enum signature_trust_level level); 101 102 void set_signing_key(const char *); 103 char *get_signing_key(void); 104 105 /* 106 * Returns a textual unique representation of the signing key in use 107 * Either a GPG KeyID or a SSH Key Fingerprint 108 */ 109 char *get_signing_key_id(void); 110 int check_signature(struct signature_check *sigc, 111 const char *signature, size_t slen); 112 void print_signature_buffer(const struct signature_check *sigc, 113 unsigned flags); 114 115 /* Modes for --signed-tags= and --signed-commits= options. */ 116 enum sign_mode { 117 SIGN_ABORT, 118 SIGN_ABORT_IF_INVALID, 119 SIGN_WARN_VERBATIM, 120 SIGN_VERBATIM, 121 SIGN_WARN_STRIP, 122 SIGN_STRIP, 123 SIGN_STRIP_IF_INVALID, 124 SIGN_SIGN_IF_INVALID, 125 }; 126 127 /* 128 * Return 0 if `arg` can be parsed into an `enum sign_mode`. Return -1 129 * otherwise. If the parsed mode is SIGN_SIGN_IF_INVALID and GPG key provided in 130 * the arguments in the form `sign-if-invalid=`, the key-ID is parsed 131 * into `char **keyid`. 132 */ 133 int parse_sign_mode(const char *arg, enum sign_mode *mode, const char **keyid); 134 135 #endif