Skip to content

Commit 1142ed2

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 4b14a2f commit 1142ed2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-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) gpg.openpgp.program is a synonym for the
1838-
legacy gpg.program.
1838+
legacy gpg.program, while the default gpg.x509.program is "gpgsm".
1839+
18391840

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

gpg-interface.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ static const char *openpgp_verify_args[] = { "--keyid-format=long", NULL };
1818
static const char *openpgp_sigs[] = {
1919
"-----BEGIN PGP SIGNATURE-----",
2020
"-----BEGIN PGP MESSAGE-----", NULL };
21+
static const char *x509_verify_args[] = { NULL };
22+
static const char *x509_sigs[] = { "-----BEGIN SIGNED MESSAGE-----", NULL };
2123

2224
static struct gpg_format gpg_formats[] = {
2325
{ .name = "openpgp", .program = "gpg",
2426
.extra_args_verify = openpgp_verify_args,
2527
.sigs = openpgp_sigs
2628
},
29+
{ .name = "x509", .program = "gpgsm",
30+
.extra_args_verify = x509_verify_args,
31+
.sigs = x509_sigs
32+
},
2733
};
2834
static struct gpg_format *current_format = &gpg_formats[0];
2935

@@ -185,6 +191,9 @@ int git_gpg_config(const char *var, const char *value, void *cb)
185191
if (!strcmp(var, "gpg.program") || !strcmp(var, "gpg.openpgp.program"))
186192
fmtname = "openpgp";
187193

194+
if (!strcmp(var, "gpg.x509.program"))
195+
fmtname = "x509";
196+
188197
if (fmtname) {
189198
fmt = get_format_by_name(fmtname);
190199
return git_config_string(&fmt->program, var, value);

0 commit comments

Comments
 (0)