[gcr: 1/2] gcr: add support for "NEW CERTIFICATE REQUEST" header



commit eef0ee7a5bf1fc0a530fb228707978a569a410f8
Author: Dmitry Baryshkov <dbaryshkov gmail com>
Date:   Thu Jan 30 12:40:38 2020 +0300

    gcr: add support for "NEW CERTIFICATE REQUEST" header
    
    According to RFC 7468 parsers MAY treat "NEW CERTIFICATE REQUEST" as
    equivalent to "CERTIFICATE REQUEST", so act accordingly.
    
    Signed-off-by: Dmitry Baryshkov <dbaryshkov gmail com>

 gcr/fixtures/new_cert_request.csr | 7 +++++++
 gcr/gcr-parser.c                  | 5 +++++
 2 files changed, 12 insertions(+)
---
diff --git a/gcr/fixtures/new_cert_request.csr b/gcr/fixtures/new_cert_request.csr
new file mode 100644
index 0000000..f5bdc2e
--- /dev/null
+++ b/gcr/fixtures/new_cert_request.csr
@@ -0,0 +1,7 @@
+-----BEGIN NEW CERTIFICATE REQUEST-----
+MIHTMIGBAgEAMBIxEDAOBgNVBAMTB0V4YW1wbGUwZjAfBggqhQMHAQEBATATBgcq
+hQMCAiMABggqhQMHAQECAgNDAARAC9hv5djbiWaPeJtOHbqFhcVQi0XsW1nYkG3b
+cOJJK3/ad/+HGhD73ydm0pPF0WSvuzx7lzpByIXRHXDWibTxJqAAMAoGCCqFAwcB
+AQMCA0EAaqqzjjXUqqUXlAMBeZEi2FVIT1efTLuW1jzf3zrMQypBqijS8asUgoDN
+ntVv7aQZdAU1VKQnZ7g60EP9OdwEkw==
+-----END NEW CERTIFICATE REQUEST-----
diff --git a/gcr/gcr-parser.c b/gcr/gcr-parser.c
index 8fa36a1..288a3f1 100644
--- a/gcr/gcr-parser.c
+++ b/gcr/gcr-parser.c
@@ -178,6 +178,7 @@ static GQuark PEM_PRIVATE_KEY;
 static GQuark PEM_PKCS7;
 static GQuark PEM_PKCS12;
 static GQuark PEM_CERTIFICATE_REQUEST;
+static GQuark PEM_NEW_CERTIFICATE_REQUEST;
 static GQuark PEM_PUBLIC_KEY;
 
 static GQuark ARMOR_PGP_PUBLIC_KEY_BLOCK;
@@ -203,6 +204,7 @@ init_quarks (void)
                QUARK (PEM_PKCS7, "PKCS7");
                QUARK (PEM_PKCS12, "PKCS12");
                QUARK (PEM_CERTIFICATE_REQUEST, "CERTIFICATE REQUEST");
+               QUARK (PEM_NEW_CERTIFICATE_REQUEST, "NEW CERTIFICATE REQUEST");
                QUARK (PEM_PUBLIC_KEY, "PUBLIC KEY");
 
                QUARK (ARMOR_PGP_PRIVATE_KEY_BLOCK, "PGP PRIVATE KEY BLOCK");
@@ -1880,6 +1882,9 @@ formats_for_armor_type (GQuark armor_type,
        } else if (armor_type == PEM_CERTIFICATE_REQUEST) {
                *inner_format = GCR_FORMAT_DER_PKCS10;
                *outer_format = GCR_FORMAT_PEM_PKCS10;
+       } else if (armor_type == PEM_NEW_CERTIFICATE_REQUEST) {
+               *inner_format = GCR_FORMAT_DER_PKCS10;
+               *outer_format = GCR_FORMAT_PEM_PKCS10;
        } else if (armor_type == PEM_PKCS12) {
                *inner_format = GCR_FORMAT_DER_PKCS12;
                *outer_format = GCR_FORMAT_PEM_PKCS12;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]