Skip to content

Commit 1e7adb9

Browse files
henning-schildgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b02f51b commit 1e7adb9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Documentation/config.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,12 +1830,13 @@ gpg.program::
18301830

18311831
gpg.format::
18321832
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".
18341834

18351835
gpg.<format>.program::
18361836
Use this to customize the program used for the signing format you
18371837
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".
18391840

18401841
gui.commitMsgWidth::
18411842
Defines how wide the commit message window is in the

gpg-interface.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@ static const char *openpgp_sigs[] = {
2424
NULL
2525
};
2626

27+
static const char *x509_verify_args[] = {
28+
NULL
29+
};
30+
static const char *x509_sigs[] = {
31+
"-----BEGIN SIGNED MESSAGE-----",
32+
NULL
33+
};
34+
2735
static struct gpg_format gpg_format[] = {
2836
{ .name = "openpgp", .program = "gpg",
2937
.verify_args = openpgp_verify_args,
3038
.sigs = openpgp_sigs
3139
},
40+
{ .name = "x509", .program = "gpgsm",
41+
.verify_args = x509_verify_args,
42+
.sigs = x509_sigs
43+
},
3244
};
3345

3446
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)
192204
if (!strcmp(var, "gpg.program") || !strcmp(var, "gpg.openpgp.program"))
193205
fmtname = "openpgp";
194206

207+
if (!strcmp(var, "gpg.x509.program"))
208+
fmtname = "x509";
209+
195210
if (fmtname) {
196211
fmt = get_format_by_name(fmtname);
197212
return git_config_string(&fmt->program, var, value);

0 commit comments

Comments
 (0)