gpg-interface: introduce new signature format "x509" using gpgsm
This commit allows git to create and check x509 type signatures using gpgsm. Signed-off-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Henning Schild committed
Jul 17, 2018 at 14:50 UTC
1e7adb97566bff7d3431ce64b8d0d854a6863ed5
2 files changed
+18
-2
Documentation/config.txt
+3
-2
@@ -1830,12 +1830,13 @@ gpg.program::
1830
1831
gpg.format::
1832
Specifies which key format to use when signing with `--gpg-sign`.
1833
- Default is "openpgp", that is also the only supported value.
1833
+ Default is "openpgp" and another possible value is "x509".
1834
1835
gpg.<format>.program::
1836
Use this to customize the program used for the signing format you
1837
chose. (see `gpg.program` and `gpg.format`) `gpg.program` can still
1838
- be used as a legacy synonym for `gpg.openpgp.program`.
1838
+ be used as a legacy synonym for `gpg.openpgp.program`. The default
1839
+ value for `gpg.x509.program` is "gpgsm".
1840
1841
gui.commitMsgWidth::
1842
Defines how wide the commit message window is in the
gpg-interface.c
+15
@@ -24,11 +24,23 @@ static const char *openpgp_sigs[] = {
24
NULL
25
};
26
27
+static const char *x509_verify_args[] = {
28
+ NULL
29
+};
30
+static const char *x509_sigs[] = {
31
+ "-----BEGIN SIGNED MESSAGE-----",
32
+ NULL
33
+};
34
+
35
static struct gpg_format gpg_format[] = {
36
{ .name = "openpgp", .program = "gpg",
37
.verify_args = openpgp_verify_args,
38
.sigs = openpgp_sigs
39
},
40
+ { .name = "x509", .program = "gpgsm",
41
+ .verify_args = x509_verify_args,
42
+ .sigs = x509_sigs
43
+ },
44
};
45
46
static struct gpg_format *use_format = &gpg_format[0];
@@ -192,6 +204,9 @@ int git_gpg_config(const char *var, const char *value, void *cb)
204
if (!strcmp(var, "gpg.program") || !strcmp(var, "gpg.openpgp.program"))
205
fmtname = "openpgp";
206
207
+ if (!strcmp(var, "gpg.x509.program"))
208
+ fmtname = "x509";
209
+
210
if (fmtname) {
211
fmt = get_format_by_name(fmtname);
212
return git_config_string(&fmt->program, var, value);