Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
pki1.h File Reference
#include "pki1t.h"
#include "nsspki1.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NSS_EXTERN NSSOID * nssOID_CreateFromBER (NSSBER *berOid)
NSS_EXTERN NSSOID * nssOID_CreateFromUTF8 (NSSUTF8 *stringOid)
NSS_EXTERN NSSDERnssOID_GetDEREncoding (const NSSOID *oid, NSSDER *rvOpt, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssOID_GetUTF8Encoding (const NSSOID *oid, NSSArena *arenaOpt)
NSS_EXTERN NSSATAV * nssATAV_CreateFromBER (NSSArena *arenaOpt, const NSSBER *berATAV)
NSS_EXTERN NSSATAV * nssATAV_CreateFromUTF8 (NSSArena *arenaOpt, const NSSUTF8 *stringATAV)
NSS_EXTERN NSSATAV * nssATAV_Create (NSSArena *arenaOpt, const NSSOID *oid, const void *data, PRUint32 length)
NSS_EXTERN PRStatus nssATAV_Destroy (NSSATAV *atav)
NSS_EXTERN NSSDERnssATAV_GetDEREncoding (NSSATAV *atav, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssATAV_GetUTF8Encoding (NSSATAV *atav, NSSArena *arenaOpt)
NSS_EXTERN const NSSOID * nssATAV_GetType (NSSATAV *atav)
NSS_EXTERN NSSUTF8nssATAV_GetValue (NSSATAV *atav, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssATAV_Compare (NSSATAV *atav1, NSSATAV *atav2, PRBool *equalp)
NSS_EXTERN NSSATAV * nssATAV_Duplicate (NSSATAV *atav, NSSArena *arenaOpt)
NSS_EXTERN NSSRDN * nssRDN_CreateFromBER (NSSArena *arenaOpt, NSSBER *berRDN)
NSS_EXTERN NSSRDN * nssRDN_CreateFromUTF8 (NSSArena *arenaOpt, NSSUTF8 *stringRDN)
NSS_EXTERN NSSRDN * nssRDN_Create (NSSArena *arenaOpt, NSSATAV *atav1,...)
NSS_EXTERN NSSRDN * nssRDN_CreateSimple (NSSArena *arenaOpt, NSSATAV *atav)
NSS_EXTERN PRStatus nssRDN_Destroy (NSSRDN *rdn)
NSS_EXTERN NSSDERnssRDN_GetDEREncoding (NSSRDN *rdn, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssRDN_GetUTF8Encoding (NSSRDN *rdn, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssRDN_AddATAV (NSSRDN *rdn, NSSATAV *atav)
NSS_EXTERN PRUint32 nssRDN_GetATAVCount (NSSRDN *rdn)
NSS_EXTERN NSSATAV * nssRDN_GetATAV (NSSRDN *rdn, NSSArena *arenaOpt, PRUint32 i)
NSS_EXTERN NSSATAV * nssRDN_GetSimpleATAV (NSSRDN *rdn, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssRDN_Compare (NSSRDN *rdn1, NSSRDN *rdn2, PRBool *equalp)
NSS_EXTERN NSSRDN * nssRDN_Duplicate (NSSRDN *rdn, NSSArena *arenaOpt)
NSS_EXTERN NSSRDNSeq * nssRDNSeq_CreateFromBER (NSSArena *arenaOpt, NSSBER *berRDNSeq)
NSS_EXTERN NSSRDNSeq * nssRDNSeq_CreateFromUTF8 (NSSArena *arenaOpt, NSSUTF8 *stringRDNSeq)
NSS_EXTERN NSSRDNSeq * nssRDNSeq_Create (NSSArena *arenaOpt, NSSRDN *rdn1,...)
NSS_EXTERN PRStatus nssRDNSeq_Destroy (NSSRDNSeq *rdnseq)
NSS_EXTERN NSSDERnssRDNSeq_GetDEREncoding (NSSRDNSeq *rdnseq, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssRDNSeq_GetUTF8Encoding (NSSRDNSeq *rdnseq, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssRDNSeq_AppendRDN (NSSRDNSeq *rdnseq, NSSRDN *rdn)
NSS_EXTERN PRUint32 nssRDNSeq_GetRDNCount (NSSRDNSeq *rdnseq)
NSS_EXTERN NSSRDN * nssRDNSeq_GetRDN (NSSRDNSeq *rdnseq, NSSArena *arenaOpt, PRUint32 i)
NSS_EXTERN PRStatus nssRDNSeq_Compare (NSSRDNSeq *rdnseq1, NSSRDNSeq *rdnseq2, PRBool *equalp)
NSS_EXTERN NSSRDNSeq * nssRDNSeq_Duplicate (NSSRDNSeq *rdnseq, NSSArena *arenaOpt)
NSS_EXTERN PRBool nssRDNSeq_EvaluateUTF8 (NSSUTF8 *str)
NSS_EXTERN NSSName * nssName_CreateFromBER (NSSArena *arenaOpt, NSSBER *berName)
NSS_EXTERN NSSName * nssName_CreateFromUTF8 (NSSArena *arenaOpt, NSSUTF8 *stringName)
NSS_EXTERN NSSName * nssName_Create (NSSArena *arenaOpt, NSSNameChoice choice, void *arg)
NSS_EXTERN PRStatus nssName_Destroy (NSSName *name)
NSS_EXTERN NSSDERnssName_GetDEREncoding (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetUTF8Encoding (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSNameChoice nssName_GetChoice (NSSName *name)
NSS_EXTERN NSSRDNSeq * nssName_GetRDNSequence (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN voidnssName_GetSpecifiedChoice (NSSName *name, NSSNameChoice choice, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssName_Compare (NSSName *name1, NSSName *name2, PRBool *equalp)
NSS_EXTERN NSSName * nssName_Duplicate (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetUID (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetEmail (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetCommonName (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetOrganization (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8 ** nssName_GetOrganizationalUnits (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetStateOrProvince (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetLocality (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetCountry (NSSName *name, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssName_GetAttribute (NSSName *name, NSSOID *attribute, NSSArena *arenaOpt)
NSS_EXTERN PRBool nssName_EvaluateUTF8 (NSSUTF8 *str)
NSS_EXTERN NSSGeneralName * nssGeneralName_CreateFromBER (NSSArena *arenaOpt, NSSBER *berGeneralName)
NSS_EXTERN NSSGeneralName * nssGeneralName_CreateFromUTF8 (NSSArena *arenaOpt, NSSUTF8 *stringGeneralName)
NSS_EXTERN NSSGeneralName * nssGeneralName_Create (NSSGeneralNameChoice choice, void *arg)
NSS_EXTERN PRStatus nssGeneralName_Destroy (NSSGeneralName *generalName)
NSS_EXTERN NSSDERnssGeneralName_GetDEREncoding (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetUTF8Encoding (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSGeneralNameChoice nssGeneralName_GetChoice (NSSGeneralName *generalName)
NSS_EXTERN NSSOtherName * nssGeneralName_GetOtherName (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSRFC822Name * nssGeneralName_GetRfc822Name (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSDNSName * nssGeneralName_GetDNSName (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSX400Address * nssGeneralName_GetX400Address (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSName * nssGeneralName_GetName (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSEdiPartyName * nssGeneralName_GetEdiPartyName (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSURI * nssGeneralName_GetUniformResourceIdentifier (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSIPAddress * nssGeneralName_GetIPAddress (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSRegisteredID * nssGeneralName_GetRegisteredID (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN voidnssGeneralName_GetSpecifiedChoice (NSSGeneralName *generalName, NSSGeneralNameChoice choice, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssGeneralName_Compare (NSSGeneralName *generalName1, NSSGeneralName *generalName2, PRBool *equalp)
NSS_EXTERN NSSGeneralName * nssGeneralName_Duplicate (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetUID (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetEmail (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetCommonName (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetOrganization (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8 ** nssGeneralName_GetOrganizationalUnits (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetStateOrProvince (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetLocality (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetCountry (NSSGeneralName *generalName, NSSArena *arenaOpt)
NSS_EXTERN NSSUTF8nssGeneralName_GetAttribute (NSSGeneralName *generalName, NSSOID *attribute, NSSArena *arenaOpt)
NSS_EXTERN NSSGeneralNameSeq * nssGeneralNameSeq_CreateFromBER (NSSArena *arenaOpt, NSSBER *berGeneralNameSeq)
NSS_EXTERN NSSGeneralNameSeq * nssGeneralNameSeq_Create (NSSArena *arenaOpt, NSSGeneralName *generalName1,...)
NSS_EXTERN PRStatus nssGeneralNameSeq_Destroy (NSSGeneralNameSeq *generalNameSeq)
NSS_EXTERN NSSDERnssGeneralNameSeq_GetDEREncoding (NSSGeneralNameSeq *generalNameSeq, NSSArena *arenaOpt)
NSS_EXTERN PRStatus nssGeneralNameSeq_AppendGeneralName (NSSGeneralNameSeq *generalNameSeq, NSSGeneralName *generalName)
NSS_EXTERN PRUint32 nssGeneralNameSeq_GetGeneralNameCount (NSSGeneralNameSeq *generalNameSeq)
NSS_EXTERN NSSGeneralName * nssGeneralNameSeq_GetGeneralName (NSSGeneralNameSeq *generalNameSeq, NSSArena *arenaOpt, PRUint32 i)
NSS_EXTERN PRStatus nssGeneralNameSeq_Compare (NSSGeneralNameSeq *generalNameSeq1, NSSGeneralNameSeq *generalNameSeq2, PRBool *equalp)
NSS_EXTERN NSSGeneralNameSeq * nssGeneralNameSeq_Duplicate (NSSGeneralNameSeq *generalNameSeq, NSSArena *arenaOpt)

Variables

PR_BEGIN_EXTERN_C const NSSOID nss_builtin_oids []
const PRUint32 nss_builtin_oid_count
const nssAttributeTypeAliasTable nss_attribute_type_aliases []
const PRUint32 nss_attribute_type_alias_count
const NSSError NSS_ERROR_INVALID_BER
const NSSError NSS_ERROR_NO_MEMORY
const NSSError NSS_ERROR_INVALID_UTF8

Function Documentation

NSS_EXTERN PRStatus nssATAV_Compare ( NSSATAV *  atav1,
NSSATAV *  atav2,
PRBool equalp 
)

Definition at line 1662 of file atav.c.

{
  nssStringType comparison;
  PRUint32 len1;
  PRUint32 len2;
  PRStatus status;

#ifdef DEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav1) ) {
    return PR_FAILURE;
  }

  if( PR_SUCCESS != nssATAV_verifyPointer(atav2) ) {
    return PR_FAILURE;
  }

  if( (PRBool *)NULL == equalp ) {
    nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
    return PR_FAILURE;
  }
#endif /* DEBUG */

  if( atav1->oid != atav2->oid ) {
    *equalp = PR_FALSE;
    return PR_SUCCESS;
  }

  if( atav1->stringForm != atav2->stringForm ) {
    if( (nssStringType_PrintableString == atav1->stringForm) ||
        (nssStringType_PrintableString == atav2->stringForm) ) {
      comparison = nssStringType_PrintableString;
    } else if( (nssStringType_PHGString == atav1->stringForm) ||
               (nssStringType_PHGString == atav2->stringForm) ) {
      comparison = nssStringType_PHGString;
    } else {
      comparison = atav1->stringForm;
    }
  } else {
    comparison = atav1->stringForm;
  }

  switch( comparison ) {
  case nssStringType_DirectoryString:
    nss_SetError(NSS_ERROR_INTERNAL_ERROR);
    return PR_FAILURE;
  case nssStringType_TeletexString:
    break;
  case nssStringType_PrintableString:
    *equalp = nssUTF8_PrintableMatch(atav1->value, atav2->value, &status);
    return status;
    /* Case-insensitive, with whitespace reduction */
    break;
  case nssStringType_UniversalString:
    break;
  case nssStringType_BMPString:
    break;
  case nssStringType_GeneralString:
    /* what to do here? */
    break;
  case nssStringType_UTF8String:
    break;
  case nssStringType_PHGString:
    /* Case-insensitive (XXX fgmr, actually see draft-11 pg. 21) */
    *equalp = nssUTF8_CaseIgnoreMatch(atav1->value, atav2->value, &status);
    return status;
  case nssStringType_Unknown:
    break;
  }
  
  len1 = nssUTF8_Size(atav1->value, &status);
  if( PR_SUCCESS != status ) {
    return PR_FAILURE;
  }

  len2 = nssUTF8_Size(atav2->value, &status);
  if( PR_SUCCESS != status ) {
    return PR_FAILURE;
  }

  if( len1 != len2 ) {
    *equalp = PR_FALSE;
    return PR_SUCCESS;
  }

  *equalp = nsslibc_memequal(atav1->value, atav2->value, len1, &status);
  return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSATAV* nssATAV_Create ( NSSArena *  arenaOpt,
const NSSOID *  oid,
const void data,
PRUint32  length 
)

Definition at line 1333 of file atav.c.

{
#ifdef NSSDEBUG
  if( (NSSArena *)NULL != arenaOpt ) {
    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
      return (NSSATAV *)NULL;
    }
  }

  if( PR_SUCCESS != nssOID_verifyPointer(oid) ) {
    return (NSSATAV *)NULL;
  }

  if( (const void *)NULL == data ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSATAV *)NULL;
  }
#endif /* NSSDEBUG */

  /* XXX fgmr-- oops, forgot this one */
  return (NSSATAV *)NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSATAV* nssATAV_CreateFromBER ( NSSArena *  arenaOpt,
const NSSBER berATAV 
)

Definition at line 857 of file atav.c.

{
  atav_holder holder;
  PRStatus status;
  NSSATAV *rv;

#ifdef NSSDEBUG
  if( (NSSArena *)NULL != arenaOpt ) {
    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
      return (NSSATAV *)NULL;
    }
  }

  /* 
   * NSSBERs can be created by the user, 
   * so no pointer-tracking can be checked.
   */

  if( (NSSBER *)NULL == berATAV ) {
    nss_SetError(NSS_ERROR_INVALID_BER);
    return (NSSATAV *)NULL;
  }

  if( (void *)NULL == berATAV->data ) {
    nss_SetError(NSS_ERROR_INVALID_BER);
    return (NSSATAV *)NULL;
  }
#endif /* NSSDEBUG */

  status = nssASN1_DecodeBER(arenaOpt, &holder, 
                             nss_atav_template, berATAV);
  if( PR_SUCCESS != status ) {
    return (NSSATAV *)NULL;
  }

  rv = nss_ZNEW(arenaOpt, NSSATAV);
  if( (NSSATAV *)NULL == rv ) {
    nss_ZFreeIf(holder.oid.data);
    nss_ZFreeIf(holder.value.data);
    return (NSSATAV *)NULL;
  }

  rv->oid = nssOID_CreateFromBER(&holder.oid);
  if( (NSSOID *)NULL == rv->oid ) {
    nss_ZFreeIf(rv);
    nss_ZFreeIf(holder.oid.data);
    nss_ZFreeIf(holder.value.data);
    return (NSSATAV *)NULL;
  }

  nss_ZFreeIf(holder.oid.data);

  rv->ber.data = nss_ZAlloc(arenaOpt, berATAV->size);
  if( (void *)NULL == rv->ber.data ) {
    nss_ZFreeIf(rv);
    nss_ZFreeIf(holder.value.data);
    return (NSSATAV *)NULL;
  }

  rv->ber.size = berATAV->size;
  (void)nsslibc_memcpy(rv->ber.data, berATAV->data, berATAV->size);

  rv->value = nss_attr_to_utf8(arenaOpt, rv->oid, &holder.value,
                               &rv->stringForm);
  if( (NSSUTF8 *)NULL == rv->value ) {
    nss_ZFreeIf(rv->ber.data);
    nss_ZFreeIf(rv);
    nss_ZFreeIf(holder.value.data);
    return (NSSATAV *)NULL;
  }

  nss_ZFreeIf(holder.value.data);

#ifdef DEBUG
  if( PR_SUCCESS != atav_add_pointer(rv) ) {
    nss_ZFreeIf(rv->ber.data);
    nss_ZFreeIf(rv->value);
    nss_ZFreeIf(rv);
    return (NSSATAV *)NULL;
  }
#endif /* DEBUG */

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSATAV* nssATAV_CreateFromUTF8 ( NSSArena *  arenaOpt,
const NSSUTF8 stringATAV 
)

Definition at line 1018 of file atav.c.

{
  char *c;
  NSSUTF8 *type;
  NSSUTF8 *value;
  PRUint32 i;
  const NSSOID *oid = (NSSOID *)NULL;
  NSSATAV *rv;
  NSSItem xitem;

  xitem.data = (void *)NULL;

  for( c = (char *)stringATAV; '\0' != *c; c++ ) {
    if( '=' == *c ) {
#ifdef PEDANTIC
      /*
       * Theoretically, one could have an '=' in an 
       * attribute string alias.  We don't, yet, though.
       */
      if( (char *)stringATAV == c ) {
        nss_SetError(NSS_ERROR_INVALID_STRING);
        return (NSSATAV *)NULL;
      } else {
        if( '\\' == c[-1] ) {
          continue;
        }
      }
#endif /* PEDANTIC */
      break;
    }
  }

  if( '\0' == *c ) {
    nss_SetError(NSS_ERROR_INVALID_UTF8);
    return (NSSATAV *)NULL;
  } else {
    c++;
    value = (NSSUTF8 *)c;
  }

  i = ((NSSUTF8 *)c - stringATAV);
  type = (NSSUTF8 *)nss_ZAlloc((NSSArena *)NULL, i);
  if( (NSSUTF8 *)NULL == type ) {
    return (NSSATAV *)NULL;
  }

  (void)nsslibc_memcpy(type, stringATAV, i-1);

  c = (char *)stringATAV;
  if( (('0' <= *c) && (*c <= '9')) || ('#' == *c) ) {
    oid = nssOID_CreateFromUTF8(type);
    if( (NSSOID *)NULL == oid ) {
      nss_ZFreeIf(type);
      return (NSSATAV *)NULL;
    }
  } else {
    for( i = 0; i < nss_attribute_type_alias_count; i++ ) {
      PRStatus status;
      const nssAttributeTypeAliasTable *e = &nss_attribute_type_aliases[i];
      PRBool match = nssUTF8_CaseIgnoreMatch(type, e->alias, &status);
      if( PR_SUCCESS != status ) {
        nss_ZFreeIf(type);
        return (NSSATAV *)NULL;
      }
      if( PR_TRUE == match ) {
        oid = *(e->oid);
        break;
      }
    }

    if( (NSSOID *)NULL == oid ) {
      nss_ZFreeIf(type);
      nss_SetError(NSS_ERROR_UNKNOWN_ATTRIBUTE);
      return (NSSATAV *)NULL;
    }
  }

  nss_ZFreeIf(type);
  type = (NSSUTF8 *)NULL;

  rv = nss_ZNEW(arenaOpt, NSSATAV);
  if( (NSSATAV *)NULL == rv ) {
    return (NSSATAV *)NULL;
  }

  rv->oid = oid;

  if( '#' == *value ) { /* XXX fgmr.. was it '#'?  or backslash? */
    PRUint32 size;
    PRUint32 len;
    NSSUTF8 *c;
    NSSUTF8 *d;
    PRStatus status;
    /* It's in hex */

    value++;
    if( PR_TRUE != nss_atav_utf8_string_is_hex(value) ) {
      (void)nss_ZFreeIf(rv);
      nss_SetError(NSS_ERROR_INVALID_STRING);
      return (NSSATAV *)NULL;
    }

    size = nssUTF8_Size(value, &status);
    if( PR_SUCCESS != status ) {
      /* 
       * Only returns an error on bad pointer (nope) or string
       * too long.  The defined limits for known attributes are
       * small enough to fit in PRUint32, and when undefined we
       * get to apply our own practical limits.  Ergo, I say the 
       * string is invalid.
       */
      (void)nss_ZFreeIf(rv);
      nss_SetError(NSS_ERROR_INVALID_STRING);
      return (NSSATAV *)NULL;
    }

    if( ((size-1) & 1) ) {
      /* odd length */
      (void)nss_ZFreeIf(rv);
      nss_SetError(NSS_ERROR_INVALID_STRING);
      return (NSSATAV *)NULL;
    }

    len = (size-1)/2;

    rv->value = (NSSUTF8 *)nss_ZAlloc(arenaOpt, len+1);
    if( (NSSUTF8 *)NULL == rv->value ) {
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    xitem.size = len;
    xitem.data = (void *)rv->value;

    for( c = rv->value, d = value; len--; c++, d += 2 ) {
      *c = nss_atav_fromhex(d);
    }

    *c = 0;
  } else {
    PRStatus status;
    PRUint32 i, len;
    PRUint8 *s;

    /*
     * XXX fgmr-- okay, this is a little wasteful, and should
     * probably be abstracted out a bit.  Later.
     */

    rv->value = nssUTF8_Duplicate(value, arenaOpt);
    if( (NSSUTF8 *)NULL == rv->value ) {
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    len = nssUTF8_Size(rv->value, &status);
    if( PR_SUCCESS != status ) {
      (void)nss_ZFreeIf(rv->value);
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    s = (PRUint8 *)rv->value;
    for( i = 0; i < len; i++ ) {
      if( '\\' == s[i] ) {
        (void)nsslibc_memcpy(&s[i], &s[i+1], len-i-1);
      }
    }
  }

  /* Now just BER-encode the baby and we're through.. */
  {
    const struct nss_attribute_data_str *which = 
      (struct nss_attribute_data_str *)NULL;
    PRUint32 i;
    NSSArena *a;
    NSSDER *oidder;
    NSSItem *vitem;
    atav_holder ah;
    NSSDER *status;

    for( i = 0; i < nss_attribute_data_quantity; i++ ) {
      if( *(nss_attribute_data[ i ].oid) == rv->oid ) {
        which = &nss_attribute_data[i];
        break;
      }
    }

    a = NSSArena_Create();
    if( (NSSArena *)NULL == a ) {
      (void)nss_ZFreeIf(rv->value);
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    oidder = nssOID_GetDEREncoding(rv->oid, (NSSDER *)NULL, a);
    if( (NSSDER *)NULL == oidder ) {
      (void)NSSArena_Destroy(a);
      (void)nss_ZFreeIf(rv->value);
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    if( (struct nss_attribute_data_str *)NULL == which ) {
      /*
       * We'll just have to take the user data as an octet stream.
       */
      if( (void *)NULL == xitem.data ) {
        /*
         * This means that an ATTR entry has been added to oids.txt,
         * but no corresponding entry has been added to the array
         * ns_attribute_data[] above.
         */
        nss_SetError(NSS_ERROR_INTERNAL_ERROR);
        (void)NSSArena_Destroy(a);
        (void)nss_ZFreeIf(rv->value);
        (void)nss_ZFreeIf(rv);
        return (NSSATAV *)NULL;
      }

      vitem = nssASN1_EncodeItem(a, (NSSDER *)NULL, &xitem, 
                                 nssASN1Template_OctetString, NSSASN1DER);
      if( (NSSItem *)NULL == vitem ) {
        (void)NSSArena_Destroy(a);
        (void)nss_ZFreeIf(rv->value);
        (void)nss_ZFreeIf(rv);
        return (NSSATAV *)NULL;
      }

      rv->stringForm = nssStringType_Unknown;
    } else {
      PRUint32 length = 0;
      PRStatus stat;
      
      length = nssUTF8_Length(rv->value, &stat);
      if( PR_SUCCESS != stat ) {
        (void)NSSArena_Destroy(a);
        (void)nss_ZFreeIf(rv->value);
        (void)nss_ZFreeIf(rv);
        return (NSSATAV *)NULL;
      }

      if( ((0 != which->minStringLength) && 
           (length < which->minStringLength)) ||
          ((0 != which->maxStringLength) &&
           (length > which->maxStringLength)) ) {
        nss_SetError(NSS_ERROR_INVALID_STRING);
        (void)NSSArena_Destroy(a);
        (void)nss_ZFreeIf(rv->value);
        (void)nss_ZFreeIf(rv);
        return (NSSATAV *)NULL;
      }

      vitem = nssUTF8_GetDEREncoding(a, which->stringType, rv->value);
      if( (NSSItem *)NULL == vitem ) {
        (void)NSSArena_Destroy(a);
        (void)nss_ZFreeIf(rv->value);
        (void)nss_ZFreeIf(rv);
        return (NSSATAV *)NULL;
      }

      if( nssStringType_DirectoryString == which->stringType ) {
        rv->stringForm = nssStringType_UTF8String;
      } else {
        rv->stringForm = which->stringType;
      }
    }

    ah.oid = *oidder;
    ah.value = *vitem;

    status = nssASN1_EncodeItem(arenaOpt, &rv->ber, &ah, 
                                nss_atav_template, NSSASN1DER);

    if( (NSSDER *)NULL == status ) {
      (void)NSSArena_Destroy(a);
      (void)nss_ZFreeIf(rv->value);
      (void)nss_ZFreeIf(rv);
      return (NSSATAV *)NULL;
    }

    (void)NSSArena_Destroy(a);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssATAV_Destroy ( NSSATAV *  atav)

Definition at line 1381 of file atav.c.

{
#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return PR_FAILURE;
  }
#endif /* NSSDEBUG */

  (void)nss_ZFreeIf(atav->ber.data);
  (void)nss_ZFreeIf(atav->value);

#ifdef DEBUG
  if( PR_SUCCESS != atav_remove_pointer(atav) ) {
    return PR_FAILURE;
  }
#endif /* DEBUG */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSATAV* nssATAV_Duplicate ( NSSATAV *  atav,
NSSArena *  arenaOpt 
)

Definition at line 1775 of file atav.c.

{
  NSSATAV *rv;

#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return (NSSATAV *)NULL;
  }

  if( (NSSArena *)NULL != arenaOpt ) {
    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
      return (NSSATAV *)NULL;
    }
  }
#endif /* NSSDEBUG */

  rv = nss_ZNEW(arenaOpt, NSSATAV);
  if( (NSSATAV *)NULL == rv ) {
    return (NSSATAV *)NULL;
  }

  rv->oid = atav->oid;
  rv->stringForm = atav->stringForm;
  rv->value = nssUTF8_Duplicate(atav->value, arenaOpt);
  if( (NSSUTF8 *)NULL == rv->value ) {
    (void)nss_ZFreeIf(rv);
    return (NSSATAV *)NULL;
  }

  rv->ber.data = nss_ZAlloc(arenaOpt, atav->ber.size);
  if( (void *)NULL == rv->ber.data ) {
    (void)nss_ZFreeIf(rv->value);
    (void)nss_ZFreeIf(rv);
    return (NSSATAV *)NULL;
  }

  rv->ber.size = atav->ber.size;
  if( NULL == nsslibc_memcpy(rv->ber.data, atav->ber.data, 
                                   atav->ber.size) ) {
    (void)nss_ZFreeIf(rv->ber.data);
    (void)nss_ZFreeIf(rv->value);
    (void)nss_ZFreeIf(rv);
    return (NSSATAV *)NULL;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSDER* nssATAV_GetDEREncoding ( NSSATAV *  atav,
NSSArena *  arenaOpt 
)

Definition at line 1423 of file atav.c.

{
  NSSDER *rv;

#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return (NSSDER *)NULL;
  }
#endif /* NSSDEBUG */

  rv = nss_ZNEW(arenaOpt, NSSDER);
  if( (NSSDER *)NULL == rv ) {
    return (NSSDER *)NULL;
  }

  rv->data = nss_ZAlloc(arenaOpt, atav->ber.size);
  if( (void *)NULL == rv->data ) {
    (void)nss_ZFreeIf(rv);
    return (NSSDER *)NULL;
  }

  rv->size = atav->ber.size;
  if( NULL == nsslibc_memcpy(rv->data, atav->ber.data, rv->size) ) {
    (void)nss_ZFreeIf(rv->data);
    (void)nss_ZFreeIf(rv);
    return (NSSDER *)NULL;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN const NSSOID* nssATAV_GetType ( NSSATAV *  atav)

Definition at line 1592 of file atav.c.

{
#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return (NSSOID *)NULL;
  }
#endif /* NSSDEBUG */

  return atav->oid;
}

Here is the caller graph for this function:

NSS_EXTERN NSSUTF8* nssATAV_GetUTF8Encoding ( NSSATAV *  atav,
NSSArena *  arenaOpt 
)

Definition at line 1479 of file atav.c.

{
  NSSUTF8 *rv;
  PRUint32 i;
  const NSSUTF8 *alias = (NSSUTF8 *)NULL;
  NSSUTF8 *oid;
  NSSUTF8 *value;
  PRUint32 oidlen;
  PRUint32 valuelen;
  PRUint32 totallen;
  PRStatus status;

#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return (NSSUTF8 *)NULL;
  }
#endif /* NSSDEBUG */

  for( i = 0; i < nss_attribute_type_alias_count; i++ ) {
    if( *(nss_attribute_type_aliases[i].oid) == atav->oid ) {
      alias = nss_attribute_type_aliases[i].alias;
      break;
    }
  }

  if( (NSSUTF8 *)NULL == alias ) {
    oid = nssOID_GetUTF8Encoding(atav->oid, (NSSArena *)NULL);
    if( (NSSUTF8 *)NULL == oid ) {
      return (NSSUTF8 *)NULL;
    }

    oidlen = nssUTF8_Size(oid, &status);
    if( PR_SUCCESS != status ) {
      (void)nss_ZFreeIf(oid);
      return (NSSUTF8 *)NULL;
    }
  } else {
    oidlen = nssUTF8_Size(alias, &status);
    if( PR_SUCCESS != status ) {
      return (NSSUTF8 *)NULL;
    }
    oid = (NSSUTF8 *)NULL;
  }

  value = nssATAV_GetValue(atav, (NSSArena *)NULL);
  if( (NSSUTF8 *)NULL == value ) {
    (void)nss_ZFreeIf(oid);
    return (NSSUTF8 *)NULL;
  }

  valuelen = nssUTF8_Size(value, &status);
  if( PR_SUCCESS != status ) {
    (void)nss_ZFreeIf(value);
    (void)nss_ZFreeIf(oid);
    return (NSSUTF8 *)NULL;
  }

  totallen = oidlen + valuelen - 1 + 1;
  rv = (NSSUTF8 *)nss_ZAlloc(arenaOpt, totallen);
  if( (NSSUTF8 *)NULL == rv ) {
    (void)nss_ZFreeIf(value);
    (void)nss_ZFreeIf(oid);
    return (NSSUTF8 *)NULL;
  }

  if( (NSSUTF8 *)NULL == alias ) {
    if( (void *)NULL == nsslibc_memcpy(rv, oid, oidlen-1) ) {
      (void)nss_ZFreeIf(rv);
      (void)nss_ZFreeIf(value);
      (void)nss_ZFreeIf(oid);
      return (NSSUTF8 *)NULL;
    }
  } else {
    if( (void *)NULL == nsslibc_memcpy(rv, alias, oidlen-1) ) {
      (void)nss_ZFreeIf(rv);
      (void)nss_ZFreeIf(value);
      return (NSSUTF8 *)NULL;
    }
  }

  rv[ oidlen-1 ] = '=';

  if( (void *)NULL == nsslibc_memcpy(&rv[oidlen], value, valuelen) ) {
    (void)nss_ZFreeIf(rv);
    (void)nss_ZFreeIf(value);
    (void)nss_ZFreeIf(oid);
    return (NSSUTF8 *)NULL;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSUTF8* nssATAV_GetValue ( NSSATAV *  atav,
NSSArena *  arenaOpt 
)

Definition at line 1626 of file atav.c.

{
#ifdef NSSDEBUG
  if( PR_SUCCESS != nssATAV_verifyPointer(atav) ) {
    return (NSSUTF8 *)NULL;
  }
#endif /* NSSDEBUG */

  return nssUTF8_Duplicate(atav->value, arenaOpt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssGeneralName_Compare ( NSSGeneralName *  generalName1,
NSSGeneralName *  generalName2,
PRBool equalp 
)
NSS_EXTERN NSSGeneralName* nssGeneralName_Create ( NSSGeneralNameChoice  choice,
void arg 
)
NSS_EXTERN NSSGeneralName* nssGeneralName_CreateFromBER ( NSSArena *  arenaOpt,
NSSBER berGeneralName 
)
NSS_EXTERN NSSGeneralName* nssGeneralName_CreateFromUTF8 ( NSSArena *  arenaOpt,
NSSUTF8 stringGeneralName 
)
NSS_EXTERN PRStatus nssGeneralName_Destroy ( NSSGeneralName *  generalName)
NSS_EXTERN NSSGeneralName* nssGeneralName_Duplicate ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetAttribute ( NSSGeneralName *  generalName,
NSSOID *  attribute,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSGeneralNameChoice nssGeneralName_GetChoice ( NSSGeneralName *  generalName)
NSS_EXTERN NSSUTF8* nssGeneralName_GetCommonName ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetCountry ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSDER* nssGeneralName_GetDEREncoding ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSDNSName* nssGeneralName_GetDNSName ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSEdiPartyName* nssGeneralName_GetEdiPartyName ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetEmail ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSIPAddress* nssGeneralName_GetIPAddress ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetLocality ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSName* nssGeneralName_GetName ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetOrganization ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8** nssGeneralName_GetOrganizationalUnits ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSOtherName* nssGeneralName_GetOtherName ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSRegisteredID* nssGeneralName_GetRegisteredID ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSRFC822Name* nssGeneralName_GetRfc822Name ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN void* nssGeneralName_GetSpecifiedChoice ( NSSGeneralName *  generalName,
NSSGeneralNameChoice  choice,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetStateOrProvince ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetUID ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSURI* nssGeneralName_GetUniformResourceIdentifier ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssGeneralName_GetUTF8Encoding ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSX400Address* nssGeneralName_GetX400Address ( NSSGeneralName *  generalName,
NSSArena *  arenaOpt 
)
NSS_EXTERN PRStatus nssGeneralNameSeq_AppendGeneralName ( NSSGeneralNameSeq *  generalNameSeq,
NSSGeneralName *  generalName 
)
NSS_EXTERN PRStatus nssGeneralNameSeq_Compare ( NSSGeneralNameSeq *  generalNameSeq1,
NSSGeneralNameSeq *  generalNameSeq2,
PRBool equalp 
)
NSS_EXTERN NSSGeneralNameSeq* nssGeneralNameSeq_Create ( NSSArena *  arenaOpt,
NSSGeneralName *  generalName1,
  ... 
)
NSS_EXTERN NSSGeneralNameSeq* nssGeneralNameSeq_CreateFromBER ( NSSArena *  arenaOpt,
NSSBER berGeneralNameSeq 
)
NSS_EXTERN PRStatus nssGeneralNameSeq_Destroy ( NSSGeneralNameSeq *  generalNameSeq)
NSS_EXTERN NSSGeneralNameSeq* nssGeneralNameSeq_Duplicate ( NSSGeneralNameSeq *  generalNameSeq,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSDER* nssGeneralNameSeq_GetDEREncoding ( NSSGeneralNameSeq *  generalNameSeq,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSGeneralName* nssGeneralNameSeq_GetGeneralName ( NSSGeneralNameSeq *  generalNameSeq,
NSSArena *  arenaOpt,
PRUint32  i 
)
NSS_EXTERN PRUint32 nssGeneralNameSeq_GetGeneralNameCount ( NSSGeneralNameSeq *  generalNameSeq)
NSS_EXTERN PRStatus nssName_Compare ( NSSName *  name1,
NSSName *  name2,
PRBool equalp 
)
NSS_EXTERN NSSName* nssName_Create ( NSSArena *  arenaOpt,
NSSNameChoice  choice,
void arg 
)
NSS_EXTERN NSSName* nssName_CreateFromBER ( NSSArena *  arenaOpt,
NSSBER berName 
)
NSS_EXTERN NSSName* nssName_CreateFromUTF8 ( NSSArena *  arenaOpt,
NSSUTF8 stringName 
)
NSS_EXTERN PRStatus nssName_Destroy ( NSSName *  name)
NSS_EXTERN NSSName* nssName_Duplicate ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetAttribute ( NSSName *  name,
NSSOID *  attribute,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSNameChoice nssName_GetChoice ( NSSName *  name)
NSS_EXTERN NSSUTF8* nssName_GetCommonName ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetCountry ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSDER* nssName_GetDEREncoding ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetEmail ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetLocality ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetOrganization ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8** nssName_GetOrganizationalUnits ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSRDNSeq* nssName_GetRDNSequence ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN void* nssName_GetSpecifiedChoice ( NSSName *  name,
NSSNameChoice  choice,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetStateOrProvince ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetUID ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssName_GetUTF8Encoding ( NSSName *  name,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSOID* nssOID_CreateFromBER ( NSSBER berOid)

Definition at line 644 of file oid.c.

{
  NSSOID *rv;
  PLHashEntry *e;
  
  if( PR_SUCCESS != oid_init() ) {
    return (NSSOID *)NULL;
  }

  if( PR_SUCCESS != oid_sanity_check_ber(berOid) ) {
    nss_SetError(NSS_ERROR_INVALID_BER);
    return (NSSOID *)NULL;
  }

  /*
   * Does it exist?
   */
  PZ_Lock(oid_hash_lock);
  rv = (NSSOID *)PL_HashTableLookup(oid_hash_table, berOid);
  (void)PZ_Unlock(oid_hash_lock);
  if( (NSSOID *)NULL != rv ) {
    /* Found it! */
    return rv;
  }

  /*
   * Doesn't exist-- create it.
   */
  rv = nss_ZNEW(oid_arena, NSSOID);
  if( (NSSOID *)NULL == rv ) {
    return (NSSOID *)NULL;
  }

  rv->data.data = nss_ZAlloc(oid_arena, berOid->size);
  if( (void *)NULL == rv->data.data ) {
    return (NSSOID *)NULL;
  }

  rv->data.size = berOid->size;
  nsslibc_memcpy(rv->data.data, berOid->data, berOid->size);

#ifdef DEBUG
  rv->tag = "<runtime>";
  rv->expl = "(OID registered at runtime)";
#endif /* DEBUG */

  PZ_Lock(oid_hash_lock);
  e = PL_HashTableAdd(oid_hash_table, &rv->data, rv);
  (void)PZ_Unlock(oid_hash_lock);
  if( (PLHashEntry *)NULL == e ) {
    nss_ZFreeIf(rv->data.data);
    nss_ZFreeIf(rv);
    nss_SetError(NSS_ERROR_NO_MEMORY);
    return (NSSOID *)NULL;
  }

#ifdef DEBUG
  {
    PRStatus st;
    st = oid_add_pointer(rv);
    if( PR_SUCCESS != st ) {
      PZ_Lock(oid_hash_lock);
      (void)PL_HashTableRemove(oid_hash_table, &rv->data);
      (void)PZ_Unlock(oid_hash_lock);
      (void)nss_ZFreeIf(rv->data.data);
      (void)nss_ZFreeIf(rv);
      return (NSSOID *)NULL;
    }
  }
#endif /* DEBUG */

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSOID* nssOID_CreateFromUTF8 ( NSSUTF8 stringOid)

Definition at line 1102 of file oid.c.

{
  NSSOID *rv = (NSSOID *)NULL;
  NSSOID *candidate = (NSSOID *)NULL;
  PLHashEntry *e;

  if( PR_SUCCESS != oid_init() ) {
    return (NSSOID *)NULL;
  }

  if( PR_SUCCESS != oid_sanity_check_utf8(stringOid) ) {
    nss_SetError(NSS_ERROR_INVALID_STRING);
    return (NSSOID *)NULL;
  }

  candidate = oid_encode_string(stringOid);
  if( (NSSOID *)NULL == candidate ) {
    /* Internal error only */
    return rv;
  }

  /*
   * Does it exist?
   */
  PZ_Lock(oid_hash_lock);
  rv = (NSSOID *)PL_HashTableLookup(oid_hash_table, &candidate->data);
  (void)PZ_Unlock(oid_hash_lock);
  if( (NSSOID *)NULL != rv ) {
    /* Already exists.  Delete my copy and return the original. */
    (void)nss_ZFreeIf(candidate->data.data);
    (void)nss_ZFreeIf(candidate);
    return rv;
  }

  /* 
   * Nope.  Add it.  Remember to allocate it out of the oid arena.
   */

  rv = nss_ZNEW(oid_arena, NSSOID);
  if( (NSSOID *)NULL == rv ) {
    goto loser;
  }

  rv->data.data = nss_ZAlloc(oid_arena, candidate->data.size);
  if( (void *)NULL == rv->data.data ) {
    goto loser;
  }

  rv->data.size = candidate->data.size;
  nsslibc_memcpy(rv->data.data, candidate->data.data, rv->data.size);

  (void)nss_ZFreeIf(candidate->data.data);
  (void)nss_ZFreeIf(candidate);

#ifdef DEBUG
  rv->tag = "<runtime>";
  rv->expl = "(OID registered at runtime)";
#endif /* DEBUG */

  PZ_Lock(oid_hash_lock);
  e = PL_HashTableAdd(oid_hash_table, &rv->data, rv);
  (void)PZ_Unlock(oid_hash_lock);
  if( (PLHashEntry *)NULL == e ) {
    nss_SetError(NSS_ERROR_NO_MEMORY);
    goto loser;
  }

#ifdef DEBUG
  {
    PRStatus st;
    st = oid_add_pointer(rv);
    if( PR_SUCCESS != st ) {
      PZ_Lock(oid_hash_lock);
      (void)PL_HashTableRemove(oid_hash_table, &rv->data);
      (void)PZ_Unlock(oid_hash_lock);
      goto loser;
    }
  }
#endif /* DEBUG */

  return rv;

 loser:
  if( (NSSOID *)NULL != candidate ) {
    (void)nss_ZFreeIf(candidate->data.data);
  }
  (void)nss_ZFreeIf(candidate);

  if( (NSSOID *)NULL != rv ) {
    (void)nss_ZFreeIf(rv->data.data);
  }
  (void)nss_ZFreeIf(rv);

  return (NSSOID *)NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSDER* nssOID_GetDEREncoding ( const NSSOID *  oid,
NSSDER rvOpt,
NSSArena *  arenaOpt 
)

Definition at line 1220 of file oid.c.

{
  const NSSItem *it;
  NSSDER *rv;

  if( PR_SUCCESS != oid_init() ) {
    return (NSSDER *)NULL;
  }

#ifdef NSSDEBUG
  if( PR_SUCCESS != nssOID_verifyPointer(oid) ) {
    return (NSSDER *)NULL;
  }

  if( (NSSArena *)NULL != arenaOpt ) {
    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
      return (NSSDER *)NULL;
    }
  }
#endif /* NSSDEBUG */

  it = &oid->data;

  if( (NSSDER *)NULL == rvOpt ) {
    rv = nss_ZNEW(arenaOpt, NSSDER);
    if( (NSSDER *)NULL == rv ) {
      return (NSSDER *)NULL;
    }
  } else {
    rv = rvOpt;
  }

  rv->data = nss_ZAlloc(arenaOpt, it->size);
  if( (void *)NULL == rv->data ) {
    if( rv != rvOpt ) {
      (void)nss_ZFreeIf(rv);
    }
    return (NSSDER *)NULL;
  }

  rv->size = it->size;
  nsslibc_memcpy(rv->data, it->data, it->size);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSUTF8* nssOID_GetUTF8Encoding ( const NSSOID *  oid,
NSSArena *  arenaOpt 
)

Definition at line 1292 of file oid.c.

{
  NSSUTF8 *rv;
  PRUint8 *end;
  PRUint8 *d;
  PRUint8 *e;
  char *a;
  char *b;
  PRUint32 len;

  if( PR_SUCCESS != oid_init() ) {
    return (NSSUTF8 *)NULL;
  }

#ifdef NSSDEBUG
  if( PR_SUCCESS != nssOID_verifyPointer(oid) ) {
    return (NSSUTF8 *)NULL;
  }

  if( (NSSArena *)NULL != arenaOpt ) {
    if( PR_SUCCESS != nssArena_verifyPointer(arenaOpt) ) {
      return (NSSUTF8 *)NULL;
    }
  }
#endif /* NSSDEBUG */

  a = (char *)NULL;

  /* d will point to the next sequence of bytes to decode */
  d = (PRUint8 *)oid->data.data;
  /* end points to one past the legitimate data */
  end = &d[ oid->data.size ];

#ifdef NSSDEBUG
  /*
   * Guarantee that the for(e=d;e<end;e++) loop below will
   * terminate.  Our BER sanity-checking code above will prevent
   * such a BER from being registered, so the only other way one
   * might show up is if our dotted-decimal encoder above screws
   * up or our generated list is wrong.  So I'll wrap it with
   * #ifdef NSSDEBUG and #endif.
   */
  if( end[-1] & 0x80 ) {
    nss_SetError(NSS_ERROR_INTERNAL_ERROR);
    return (NSSUTF8 *)NULL;
  }
#endif /* NSSDEBUG */

  /*
   * Check for our pseudo-encoded single-digit OIDs
   */
  if( (*d == 0x80) && (2 == oid->data.size) ) {
    /* Funky encoding.  The second byte is the number */
    a = PR_smprintf("%lu", (PRUint32)d[1]);
    if( (char *)NULL == a ) {
      nss_SetError(NSS_ERROR_NO_MEMORY);
      return (NSSUTF8 *)NULL;
    }
    goto done;
  }

  for( ; d < end; d = &e[1] ) {
    
    for( e = d; e < end; e++ ) {
      if( 0 == (*e & 0x80) ) {
        break;
      }
    }
    
    if( ((e-d) > 4) || (((e-d) == 4) && (*d & 0x70)) ) {
      /* More than a 32-bit number */
    } else {
      PRUint32 n = 0;
      
      switch( e-d ) {
      case 4:
        n |= ((PRUint32)(e[-4] & 0x0f)) << 28;
      case 3:
        n |= ((PRUint32)(e[-3] & 0x7f)) << 21;
      case 2:
        n |= ((PRUint32)(e[-2] & 0x7f)) << 14;
      case 1:
        n |= ((PRUint32)(e[-1] & 0x7f)) <<  7;
      case 0:
        n |= ((PRUint32)(e[-0] & 0x7f))      ;
      }
      
      if( (char *)NULL == a ) {
        /* This is the first number.. decompose it */
        PRUint32 one = (n/40), two = (n%40);
        
        a = PR_smprintf("%lu.%lu", one, two);
        if( (char *)NULL == a ) {
          nss_SetError(NSS_ERROR_NO_MEMORY);
          return (NSSUTF8 *)NULL;
        }
      } else {
        b = PR_smprintf("%s.%lu", a, n);
        if( (char *)NULL == b ) {
          PR_smprintf_free(a);
          nss_SetError(NSS_ERROR_NO_MEMORY);
          return (NSSUTF8 *)NULL;
        }
        
        PR_smprintf_free(a);
        a = b;
      }
    }
  }

 done:
  /*
   * Even if arenaOpt is NULL, we have to copy the data so that
   * it'll be freed with the right version of free: ours, not
   * PR_smprintf_free's.
   */
  len = PL_strlen(a);
  rv = (NSSUTF8 *)nss_ZAlloc(arenaOpt, len);
  if( (NSSUTF8 *)NULL == rv ) {
    PR_smprintf_free(a);
    return (NSSUTF8 *)NULL;
  }

  nsslibc_memcpy(rv, a, len);
  PR_smprintf_free(a);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssRDN_AddATAV ( NSSRDN *  rdn,
NSSATAV *  atav 
)
NSS_EXTERN PRStatus nssRDN_Compare ( NSSRDN *  rdn1,
NSSRDN *  rdn2,
PRBool equalp 
)
NSS_EXTERN NSSRDN* nssRDN_Create ( NSSArena *  arenaOpt,
NSSATAV *  atav1,
  ... 
)
NSS_EXTERN NSSRDN* nssRDN_CreateFromBER ( NSSArena *  arenaOpt,
NSSBER berRDN 
)
NSS_EXTERN NSSRDN* nssRDN_CreateFromUTF8 ( NSSArena *  arenaOpt,
NSSUTF8 stringRDN 
)
NSS_EXTERN NSSRDN* nssRDN_CreateSimple ( NSSArena *  arenaOpt,
NSSATAV *  atav 
)
NSS_EXTERN PRStatus nssRDN_Destroy ( NSSRDN *  rdn)
NSS_EXTERN NSSRDN* nssRDN_Duplicate ( NSSRDN *  rdn,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSATAV* nssRDN_GetATAV ( NSSRDN *  rdn,
NSSArena *  arenaOpt,
PRUint32  i 
)
NSS_EXTERN NSSDER* nssRDN_GetDEREncoding ( NSSRDN *  rdn,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSATAV* nssRDN_GetSimpleATAV ( NSSRDN *  rdn,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSUTF8* nssRDN_GetUTF8Encoding ( NSSRDN *  rdn,
NSSArena *  arenaOpt 
)
NSS_EXTERN PRStatus nssRDNSeq_AppendRDN ( NSSRDNSeq *  rdnseq,
NSSRDN *  rdn 
)
NSS_EXTERN PRStatus nssRDNSeq_Compare ( NSSRDNSeq *  rdnseq1,
NSSRDNSeq *  rdnseq2,
PRBool equalp 
)
NSS_EXTERN NSSRDNSeq* nssRDNSeq_Create ( NSSArena *  arenaOpt,
NSSRDN *  rdn1,
  ... 
)
NSS_EXTERN NSSRDNSeq* nssRDNSeq_CreateFromBER ( NSSArena *  arenaOpt,
NSSBER berRDNSeq 
)
NSS_EXTERN NSSRDNSeq* nssRDNSeq_CreateFromUTF8 ( NSSArena *  arenaOpt,
NSSUTF8 stringRDNSeq 
)
NSS_EXTERN PRStatus nssRDNSeq_Destroy ( NSSRDNSeq *  rdnseq)
NSS_EXTERN NSSRDNSeq* nssRDNSeq_Duplicate ( NSSRDNSeq *  rdnseq,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSDER* nssRDNSeq_GetDEREncoding ( NSSRDNSeq *  rdnseq,
NSSArena *  arenaOpt 
)
NSS_EXTERN NSSRDN* nssRDNSeq_GetRDN ( NSSRDNSeq *  rdnseq,
NSSArena *  arenaOpt,
PRUint32  i 
)
NSS_EXTERN PRUint32 nssRDNSeq_GetRDNCount ( NSSRDNSeq *  rdnseq)
NSS_EXTERN NSSUTF8* nssRDNSeq_GetUTF8Encoding ( NSSRDNSeq *  rdnseq,
NSSArena *  arenaOpt 
)

Variable Documentation

Definition at line 2936 of file oiddata.c.

const nssAttributeTypeAliasTable nss_attribute_type_aliases[]

Definition at line 2869 of file oiddata.c.

Definition at line 2702 of file oiddata.c.

Definition at line 46 of file oiddata.c.

Definition at line 73 of file errorval.c.

Definition at line 76 of file errorval.c.

Definition at line 136 of file pki1.h.