Add accessors for request and CRL signatures
authorDr. Stephen Henson <steve@openssl.org>
Mon, 7 Sep 2015 15:51:05 +0000 (16:51 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 22 Sep 2015 11:28:45 +0000 (12:28 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/x509/x509_req.c
crypto/x509/x509cset.c
include/openssl/x509.h

index 34336941e5b8977873742feab698c1eda6a4c904..a2d70c013c2eb67a9269c7084b05d0c0d0d2b1d8 100644 (file)
@@ -314,3 +314,23 @@ X509_NAME *X509_REQ_get_subject_name(X509_REQ *req)
 {
     return req->req_info.subject;
 }
+
+void X509_REQ_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
+                             X509_REQ *req)
+{
+    if (psig == NULL)
+        *psig = req->signature;
+    if (palg == NULL)
+        *palg = &req->sig_alg;
+}
+
+int X509_REQ_get_signature_nid(const X509_REQ *req)
+{
+    return OBJ_obj2nid(req->sig_alg.algorithm);
+}
+
+int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp)
+{
+    req->req_info.enc.modified = 1;
+    return i2d_X509_REQ_INFO(&req->req_info, pp);
+}
index 6215cf0123ba348032f3c27d83758a1ca87d2a08..4dbe6d087f759a22002a7fce25269a21db6cabd5 100644 (file)
@@ -166,12 +166,17 @@ STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl)
 void X509_CRL_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
                              X509_CRL *crl)
 {
-    if (psig)
+    if (psig == NULL)
         *psig = crl->signature;
-    if (palg)
+    if (palg == NULL)
         *palg = &crl->sig_alg;
 }
 
+int X509_CRL_get_signature_nid(const X509_CRL *crl)
+{
+    return OBJ_obj2nid(crl->sig_alg.algorithm);
+}
+
 int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm)
 {
     ASN1_TIME *in;
@@ -205,3 +210,9 @@ int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial)
     }
     return (in != NULL);
 }
+
+int i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp)
+{
+    crl->crl.enc.modified = 1;
+    return i2d_X509_CRL_INFO(&crl->crl, pp);
+}
index f809d38e1a84a8b0e9b239a6ab846cfe77e6baeb..eb9e3b44534ee245e9b4d7153f4b9fe73511f008 100644 (file)
@@ -753,6 +753,10 @@ long X509_REQ_get_version(X509_REQ *req);
 int X509_REQ_set_version(X509_REQ *x, long version);
 X509_NAME *X509_REQ_get_subject_name(X509_REQ *req);
 int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
+void X509_REQ_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
+                             X509_REQ *req);
+int X509_REQ_get_signature_nid(const X509_REQ *req);
+int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
 EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
 int X509_REQ_extension_nid(int nid);
@@ -793,6 +797,8 @@ X509_NAME *X509_CRL_get_issuer(X509_CRL *crl);
 STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
 void X509_CRL_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
                              X509_CRL *crl);
+int X509_CRL_get_signature_nid(const X509_CRL *crl);
+int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
 
 int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
 int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);