aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2024-08-21 19:44:32 +0000
committerGitHub <noreply@github.com>2024-08-21 19:44:32 +0000
commit060f00f3e2b6fde3ca5e01227fed60d62e349fa5 (patch)
tree96b31e6ef8ed53fd0281bd7b39e4fff601d14b08
parent6d583524d3e1d79c171d4666eee3e1d174c210d0 (diff)
parent9ac14c4ac7c6d1043394c0cc1be5e0c931b8f6c4 (diff)
downloadgo-git-060f00f3e2b6fde3ca5e01227fed60d62e349fa5.tar.gz
Merge pull request #1169 from yoavamit/parse-x509-signed-message
plumbing: signature, support the same x509 signature formats as git
-rw-r--r--plumbing/object/signature.go1
-rw-r--r--plumbing/object/signature_test.go15
2 files changed, 15 insertions, 1 deletions
diff --git a/plumbing/object/signature.go b/plumbing/object/signature.go
index 91cf371..f9c3d30 100644
--- a/plumbing/object/signature.go
+++ b/plumbing/object/signature.go
@@ -19,6 +19,7 @@ var (
// a PKCS#7 (S/MIME) signature.
x509SignatureFormat = signatureFormat{
[]byte("-----BEGIN CERTIFICATE-----"),
+ []byte("-----BEGIN SIGNED MESSAGE-----"),
}
// sshSignatureFormat is the format of an SSH signature.
diff --git a/plumbing/object/signature_test.go b/plumbing/object/signature_test.go
index 3b20cde..732aa09 100644
--- a/plumbing/object/signature_test.go
+++ b/plumbing/object/signature_test.go
@@ -33,7 +33,7 @@ MKEQruIQWJb+8HVXwssA4=
want: signatureTypeSSH,
},
{
- name: "known signature format (X509)",
+ name: "known signature format (X509) CERTIFICATE",
b: []byte(`-----BEGIN CERTIFICATE-----
MIIDZjCCAk6gAwIBAgIJALZ9Z3Z9Z3Z9MA0GCSqGSIb3DQEBCwUAMIGIMQswCQYD
VQQGEwJTRTEOMAwGA1UECAwFVGV4YXMxDjAMBgNVBAcMBVRleGFzMQ4wDAYDVQQK
@@ -46,6 +46,19 @@ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQZ9Z3Z9Z3Z9Z3Z9Z3Z9Z3
want: signatureTypeX509,
},
{
+ name: "known signature format (x509) SIGNED MESSAGE",
+ b: []byte(`-----BEGIN SIGNED MESSAGE-----
+MIIDZjCCAk6gAwIBAgIJALZ9Z3Z9Z3Z9MA0GCSqGSIb3DQEBCwUAMIGIMQswCQYD
+VQQGEwJTRTEOMAwGA1UECAwFVGV4YXMxDjAMBgNVBAcMBVRleGFzMQ4wDAYDVQQK
+DAVUZXhhczEOMAwGA1UECwwFVGV4YXMxGDAWBgNVBAMMD1RleGFzIENlcnRpZmlj
+YXRlMB4XDTE3MDUyNjE3MjY0MloXDTI3MDUyNDE3MjY0MlowgYgxCzAJBgNVBAYT
+AlNFMQ4wDAYDVQQIDAVUZXhhczEOMAwGA1UEBwwFVGV4YXMxDjAMBgNVBAoMBVRl
+eGFzMQ4wDAYDVQQLDAVUZXhhczEYMBYGA1UEAwwPVGV4YXMgQ2VydGlmaWNhdGUw
+ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQZ9Z3Z9Z3Z9Z3Z9Z3Z9Z3
+-----END SIGNED MESSAGE-----`),
+ want: signatureTypeX509,
+ },
+ {
name: "unknown signature format",
b: []byte(`-----BEGIN ARBITRARY SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgij/EfHS8tCjolj5uEANXgKzFfp