summaryrefslogtreecommitdiff
path: root/lib/x509/dn.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-20 00:11:12 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-20 00:11:12 +0100
commitccb7b18b21c199207fe89d63940ca34c420a29a1 (patch)
tree6ff630e013ff3e66eaae4e4f0138f4139e7237d3 /lib/x509/dn.c
parent04975161925c0a5372c4006d553f0263571fda90 (diff)
downloadgnutls-ccb7b18b21c199207fe89d63940ca34c420a29a1.tar.gz
Added gnutls_x509_crt_set_policy()
Diffstat (limited to 'lib/x509/dn.c')
-rw-r--r--lib/x509/dn.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/x509/dn.c b/lib/x509/dn.c
index ee37213426..238e28ed86 100644
--- a/lib/x509/dn.c
+++ b/lib/x509/dn.c
@@ -623,6 +623,17 @@ cleanup:
return result;
}
+static int is_printable(char p)
+{
+ if ((p >= 'a' && p <= 'z') || (p >= 'A' && p <= 'Z') ||
+ (p >= '0' && p <= '9') || p == ' ' || p == '(' || p == ')' ||
+ p == '(' || p == '+' || p == ',' || p == '-' || p == '.' ||
+ p == '/' || p == ':' || p == '=' || p == '?')
+ return 1;
+
+ return 0;
+}
+
/* This will encode and write the AttributeTypeAndValue field.
* 'multi' must be (0) if writing an AttributeTypeAndValue, and 1 if Attribute.
* In all cases only one value is written.
@@ -667,12 +678,12 @@ _gnutls_x509_encode_and_write_attribute (const char *given_oid,
string_type = "printableString";
- /* Check if the data is plain ascii, and use
+ /* Check if the data is ASN.1 printable, and use
* the UTF8 string type if not.
*/
for (i = 0; i < sizeof_data; i++)
{
- if (!isascii (data[i]))
+ if (!is_printable (data[i]))
{
string_type = "utf8String";
break;