libksba  1.6.0
About: KSBA is a library to make the tasks of working with X.509 certificates, CMS data and related objects more easy.
  Fossies Dox: libksba-1.6.0.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dn.c File Reference
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "util.h"
#include "asn1-func.h"
#include "ber-help.h"
#include "ber-decoder.h"
#include "stringbuf.h"
Include dependency graph for dn.c:

Go to the source code of this file.

Macros

#define N   0x00
 
#define P   0x01
 

Functions

static void append_quoted (struct stringbuf *sb, const unsigned char *value, size_t length, int skip)
 
static void append_utf8_value (const unsigned char *value, size_t length, struct stringbuf *sb)
 
static void append_latin1_value (const unsigned char *value, size_t length, struct stringbuf *sb)
 
static void append_ucs4_value (const unsigned char *value, size_t length, struct stringbuf *sb)
 
static void append_ucs2_value (const unsigned char *value, size_t length, struct stringbuf *sb)
 
static gpg_error_t append_atv (const unsigned char *image, AsnNode root, struct stringbuf *sb)
 
static gpg_error_t dn_to_str (const unsigned char *image, AsnNode root, struct stringbuf *sb)
 
gpg_error_t _ksba_dn_to_str (const unsigned char *image, AsnNode node, char **r_string)
 
static gpg_error_t create_and_run_decoder (ksba_reader_t reader, const char *elem_name, AsnNode *r_root, unsigned char **r_image, size_t *r_imagelen)
 
gpg_error_t _ksba_derdn_to_str (const unsigned char *der, size_t derlen, char **r_string)
 
static const char * count_quoted_string (const char *string, size_t *result, int v2compat, int *stringtype)
 
static gpg_error_t write_escaped (ksba_writer_t w, const unsigned char *buffer, size_t nbytes)
 
static gpg_error_t parse_rdn (const unsigned char *string, const char **endp, ksba_writer_t writer, size_t *roff, size_t *rlen)
 
gpg_error_t _ksba_dn_from_str (const char *string, char **rbuf, size_t *rlength)
 
gpg_error_t _ksba_dn_der2str (const void *der, size_t derlen, char **rstring)
 
gpg_error_t _ksba_dn_str2der (const char *string, unsigned char **rder, size_t *rderlen)
 
gpg_error_t _ksba_dn_teststr (const char *string, int seq, size_t *rerroff, size_t *rerrlen)
 

Variables

struct {
   const char *   name
 
   int   source
 
   const char *   description
 
   size_t   oidlen
 
   const unsigned char *   oid
 
   const char *   oidstr
 
oid_name_tbl []
 
static unsigned char charclasses [128]
 

Macro Definition Documentation

◆ N

#define N   0x00

Definition at line 85 of file dn.c.

◆ P

#define P   0x01

Definition at line 86 of file dn.c.

Function Documentation

◆ _ksba_derdn_to_str()

gpg_error_t _ksba_derdn_to_str ( const unsigned char *  der,
size_t  derlen,
char **  r_string 
)

◆ _ksba_dn_der2str()

gpg_error_t _ksba_dn_der2str ( const void *  der,
size_t  derlen,
char **  rstring 
)

Definition at line 1150 of file dn.c.

References _ksba_derdn_to_str(), der, and derlen.

◆ _ksba_dn_from_str()

◆ _ksba_dn_str2der()

gpg_error_t _ksba_dn_str2der ( const char *  string,
unsigned char **  rder,
size_t *  rderlen 
)

Definition at line 1157 of file dn.c.

References _ksba_dn_from_str().

◆ _ksba_dn_teststr()

gpg_error_t _ksba_dn_teststr ( const char *  string,
int  seq,
size_t *  rerroff,
size_t *  rerrlen 
)

Definition at line 1174 of file dn.c.

References GPG_ERR_SYNTAX, gpg_error, stringbuf::len, and parse_rdn().

◆ _ksba_dn_to_str()

gpg_error_t _ksba_dn_to_str ( const unsigned char *  image,
AsnNode  node,
char **  r_string 
)

◆ append_atv()

◆ append_latin1_value()

static void append_latin1_value ( const unsigned char *  value,
size_t  length,
struct stringbuf sb 
)
static

Definition at line 220 of file dn.c.

References append_quoted(), and put_stringbuf_mem().

Referenced by append_atv().

◆ append_quoted()

static void append_quoted ( struct stringbuf sb,
const unsigned char *  value,
size_t  length,
int  skip 
)
static

◆ append_ucs2_value()

static void append_ucs2_value ( const unsigned char *  value,
size_t  length,
struct stringbuf sb 
)
static

Definition at line 351 of file dn.c.

References append_quoted(), and put_stringbuf_mem().

Referenced by append_atv().

◆ append_ucs4_value()

static void append_ucs4_value ( const unsigned char *  value,
size_t  length,
struct stringbuf sb 
)
static

Definition at line 262 of file dn.c.

References append_quoted(), and put_stringbuf_mem().

Referenced by append_atv().

◆ append_utf8_value()

static void append_utf8_value ( const unsigned char *  value,
size_t  length,
struct stringbuf sb 
)
static

Definition at line 148 of file dn.c.

References append_quoted(), and put_stringbuf_mem().

Referenced by append_atv().

◆ count_quoted_string()

static const char* count_quoted_string ( const char *  string,
size_t *  result,
int  v2compat,
int *  stringtype 
)
static

Definition at line 664 of file dn.c.

References charclasses, hexdigitp, TYPE_IA5_STRING, TYPE_PRINTABLE_STRING, TYPE_UTF8_STRING, and xtoi_2.

Referenced by parse_rdn().

◆ create_and_run_decoder()

static gpg_error_t create_and_run_decoder ( ksba_reader_t  reader,
const char *  elem_name,
AsnNode r_root,
unsigned char **  r_image,
size_t *  r_imagelen 
)
static

◆ dn_to_str()

static gpg_error_t dn_to_str ( const unsigned char *  image,
AsnNode  root,
struct stringbuf sb 
)
static

◆ parse_rdn()

◆ write_escaped()

static gpg_error_t write_escaped ( ksba_writer_t  w,
const unsigned char *  buffer,
size_t  nbytes 
)
static

Definition at line 746 of file dn.c.

References stringbuf::buf, hexdigitp, ksba_writer_write(), and xtoi_2.

Referenced by parse_rdn().

Variable Documentation

◆ charclasses

unsigned char charclasses[128]
static
Initial value:
= {
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 , 0x01 , 0x00 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x01 , 0x00 , 0x01 ,
0x00 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 ,
0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
}

Definition at line 87 of file dn.c.

Referenced by count_quoted_string(), and parse_rdn().

◆ description

const char* description

Definition at line 54 of file dn.c.

◆ name

◆ oid

const unsigned char* oid

Definition at line 56 of file dn.c.

Referenced by parse_rdn().

◆ 

oid_name_tbl[] { ... } const struct
Initial value:
= {
{"CN", 1, "CommonName", 3, "\x55\x04\x03", "2.5.4.3" },
{"SN", 2, "Surname", 3, "\x55\x04\x04", "2.5.4.4" },
{"SERIALNUMBER", 2, "SerialNumber",3, "\x55\x04\x05", "2.5.4.5" },
{"C", 1, "CountryName", 3, "\x55\x04\x06", "2.5.4.6" },
{"L" , 1, "LocalityName", 3, "\x55\x04\x07", "2.5.4.7" },
{"ST", 1, "StateOrProvince", 3, "\x55\x04\x08", "2.5.4.8" },
{"STREET", 1, "StreetAddress", 3, "\x55\x04\x09", "2.5.4.9" },
{"O", 1, "OrganizationName", 3, "\x55\x04\x0a", "2.5.4.10" },
{"OU", 1, "OrganizationalUnit", 3, "\x55\x04\x0b", "2.5.4.11" },
{"T", 2, "Title", 3, "\x55\x04\x0c", "2.5.4.12" },
{"D", 3, "Description", 3, "\x55\x04\x0d", "2.5.4.13" },
{"BC", 3, "BusinessCategory", 3, "\x55\x04\x0f", "2.5.4.15" },
{"ADDR", 2, "PostalAddress", 3, "\x55\x04\x11", "2.5.4.16" },
{"POSTALCODE" , 0, "PostalCode", 3, "\x55\x04\x11", "2.5.4.17" },
{"GN", 2, "GivenName", 3, "\x55\x04\x2a", "2.5.4.42" },
{"PSEUDO", 2, "Pseudonym", 3, "\x55\x04\x41", "2.5.4.65" },
{"DC", 1, "domainComponent", 10,
"\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x19", "0.9.2342.19200300.100.1.25" },
{"UID", 1, "userid", 10,
"\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x01", "0.9.2342.19200300.100.1.1 " },
{"EMAIL", 3, "emailAddress", 9,
"\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01", "1.2.840.113549.1.9.1" },
{ NULL }
}

Referenced by append_atv(), and parse_rdn().

◆ oidlen

◆ oidstr

const char* oidstr

Definition at line 57 of file dn.c.

Referenced by _ksba_der_add_oid(), and append_atv().

◆ source

int source

Definition at line 48 of file dn.c.

Referenced by append_atv().