aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/x509/x_name.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-09-22 16:05:33 +0100
committerDr. Stephen Henson <steve@openssl.org>2015-09-22 16:05:33 +0100
commit0d0099ea3b1825fe51bce11e076292e408b55feb (patch)
treeab8f54fdbc335fbe23b15a791a72c478640776ee /crypto/x509/x_name.c
parent035014cd22c502bca93c73e6475da73ee31f1078 (diff)
downloadopenssl-0d0099ea3b1825fe51bce11e076292e408b55feb.tar.gz
Move functions.
Move various functions tagged onto t_x509.c to more appropriate places. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/x509/x_name.c')
-rw-r--r--crypto/x509/x_name.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c
index 4c8d57b600..1a2daaaca5 100644
--- a/crypto/x509/x_name.c
+++ b/crypto/x509/x_name.c
@@ -514,3 +514,59 @@ int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
}
return (*xn != NULL);
}
+
+int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
+{
+ char *s, *c, *b;
+ int l, i;
+
+ l = 80 - 2 - obase;
+
+ b = X509_NAME_oneline(name, NULL, 0);
+ if (!b)
+ return 0;
+ if (!*b) {
+ OPENSSL_free(b);
+ return 1;
+ }
+ s = b + 1; /* skip the first slash */
+
+ c = s;
+ for (;;) {
+#ifndef CHARSET_EBCDIC
+ if (((*s == '/') &&
+ ((s[1] >= 'A') && (s[1] <= 'Z') && ((s[2] == '=') ||
+ ((s[2] >= 'A')
+ && (s[2] <= 'Z')
+ && (s[3] == '='))
+ ))) || (*s == '\0'))
+#else
+ if (((*s == '/') &&
+ (isupper(s[1]) && ((s[2] == '=') ||
+ (isupper(s[2]) && (s[3] == '='))
+ ))) || (*s == '\0'))
+#endif
+ {
+ i = s - c;
+ if (BIO_write(bp, c, i) != i)
+ goto err;
+ c = s + 1; /* skip following slash */
+ if (*s != '\0') {
+ if (BIO_write(bp, ", ", 2) != 2)
+ goto err;
+ }
+ l--;
+ }
+ if (*s == '\0')
+ break;
+ s++;
+ l--;
+ }
+
+ OPENSSL_free(b);
+ return 1;
+ err:
+ X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB);
+ OPENSSL_free(b);
+ return 0;
+}