summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_strex.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2000-08-24 23:24:18 +0000
committerDr. Stephen Henson <steve@openssl.org>2000-08-24 23:24:18 +0000
commitd428bf8c568c617bb3c3bd0ac3b326298e7b34b9 (patch)
treeb2941d622c7d4dbd526afa82a9308016a04321fe /crypto/asn1/a_strex.c
parentd096b524afbdc371032d96d22f1686d88bfba0e9 (diff)
New option to CA.pl to sign request using CA extensions.
This allows intermediate CAs to be created more easily. PKCS12_create() now checks private key matches certificate. Fix typo in x509 app. Update docs. New function ASN1_STRING_to_UTF8() converts any ASN1_STRING type to UTF8.
Diffstat (limited to 'crypto/asn1/a_strex.c')
-rw-r--r--crypto/asn1/a_strex.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c
index 02fe2bad1c..af77b09194 100644
--- a/crypto/asn1/a_strex.c
+++ b/crypto/asn1/a_strex.c
@@ -509,3 +509,24 @@ int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags)
{
return do_print_ex(send_fp_chars, fp, flags, str);
}
+
+/* Utility function: convert any string type to UTF8, returns number of bytes
+ * in output string or a negative error code
+ */
+
+int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
+{
+ ASN1_STRING stmp, *str = &stmp;
+ int mbflag, type, ret;
+ if(!*out || !in) return -1;
+ type = in->type;
+ if((type < 0) || (type > 30)) return -1;
+ mbflag = tag2nbyte[type];
+ if(mbflag == -1) return -1;
+ mbflag |= MBSTRING_FLAG;
+ stmp.data = NULL;
+ ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
+ if(ret < 0) return ret;
+ if(out) *out = stmp.data;
+ return stmp.length;
+}