Remove X509_to_X509_REQ.

The manual construction of the version integer is odd. The default is
already zero, and as of
https://boringssl-review.googlesource.com/c/boringssl/+/51632, we've
settled on the empty string as the ASN1_INTEGER representation of zero.

But there don't seem to be any uses of this function, so just remove it.

Update-Note: Removed seemingly unused public API.
Change-Id: I75f8bcdadb8ffefb0b2da0fcb0a87a8cb6398f70
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52585
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/x509/x509_req.c b/crypto/x509/x509_req.c
index 99eabfe..5a69a5f 100644
--- a/crypto/x509/x509_req.c
+++ b/crypto/x509/x509_req.c
@@ -68,48 +68,6 @@
 #include "internal.h"
 
 
-X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
-{
-    X509_REQ *ret;
-    X509_REQ_INFO *ri;
-    int i;
-    EVP_PKEY *pktmp;
-
-    ret = X509_REQ_new();
-    if (ret == NULL) {
-        OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
-        goto err;
-    }
-
-    ri = ret->req_info;
-
-    ri->version->length = 1;
-    ri->version->data = (unsigned char *)OPENSSL_malloc(1);
-    if (ri->version->data == NULL)
-        goto err;
-    ri->version->data[0] = 0;   /* version == 0 */
-
-    if (!X509_REQ_set_subject_name(ret, X509_get_subject_name(x)))
-        goto err;
-
-    pktmp = X509_get_pubkey(x);
-    if (pktmp == NULL)
-        goto err;
-    i = X509_REQ_set_pubkey(ret, pktmp);
-    EVP_PKEY_free(pktmp);
-    if (!i)
-        goto err;
-
-    if (pkey != NULL) {
-        if (!X509_REQ_sign(ret, pkey, md))
-            goto err;
-    }
-    return (ret);
- err:
-    X509_REQ_free(ret);
-    return (NULL);
-}
-
 long X509_REQ_get_version(const X509_REQ *req)
 {
     return ASN1_INTEGER_get(req->req_info->version);
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index 7e67080..314a0e5 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -817,9 +817,6 @@
 OPENSSL_EXPORT const char *X509_get_default_cert_file_env(void);
 OPENSSL_EXPORT const char *X509_get_default_private_dir(void);
 
-OPENSSL_EXPORT X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey,
-                                          const EVP_MD *md);
-
 DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
 
 DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)