Back to index

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

Go to the source code of this file.

Functions

PR_BEGIN_EXTERN_C NSS_EXTERN
nssASN1Decoder
nssASN1Decoder_Create (NSSArena *arenaOpt, void *destination, const nssASN1Template template[])
NSS_EXTERN PRStatus nssASN1Decoder_Update (nssASN1Decoder *decoder, const void *data, PRUint32 amount)
NSS_EXTERN PRStatus nssASN1Decoder_Finish (nssASN1Decoder *decoder)
NSS_EXTERN PRStatus nssASN1Decoder_SetFilter (nssASN1Decoder *decoder, nssASN1DecoderFilterFunction *callback, void *argument, PRBool noStore)
NSS_EXTERN PRStatus nssASN1Decoder_GetFilter (nssASN1Decoder *decoder, nssASN1DecoderFilterFunction **pCallbackOpt, void **pArgumentOpt, PRBool *pNoStoreOpt)
NSS_EXTERN PRStatus nssASN1Decoder_SetNotify (nssASN1Decoder *decoder, nssASN1NotifyFunction *callback, void *argument)
NSS_EXTERN PRStatus nssASN1Decoder_GetNotify (nssASN1Decoder *decoder, nssASN1NotifyFunction **pCallbackOpt, void **pArgumentOpt)
NSS_EXTERN PRStatus nssASN1_Decode (NSSArena *arenaOpt, void *destination, const nssASN1Template template[], const void *berData, PRUint32 amount)
NSS_EXTERN PRStatus nssASN1_DecodeBER (NSSArena *arenaOpt, void *destination, const nssASN1Template template[], const NSSBER *data)
NSS_EXTERN nssASN1EncodernssASN1Encoder_Create (const void *source, const nssASN1Template template[], NSSASN1EncodingType encoding, nssASN1EncoderWriteFunction *sink, void *argument)
NSS_EXTERN PRStatus nssASN1Encoder_Update (nssASN1Encoder *encoder, const void *data, PRUint32 length)
NSS_EXTERN PRStatus nssASN1Encoder_Finish (nssASN1Encoder *encoder)
NSS_EXTERN PRStatus nssASN1Encoder_SetNotify (nssASN1Encoder *encoder, nssASN1NotifyFunction *callback, void *argument)
NSS_EXTERN PRStatus nssASN1Encoder_GetNotify (nssASN1Encoder *encoder, nssASN1NotifyFunction **pCallbackOpt, void **pArgumentOpt)
NSS_EXTERN PRStatus nssASN1Encoder_SetStreaming (nssASN1Encoder *encoder, PRBool streaming)
NSS_EXTERN PRStatus nssASN1Encoder_GetStreaming (nssASN1Encoder *encoder, PRBool *pStreaming)
NSS_EXTERN PRStatus nssASN1Encoder_SetTakeFromBuffer (nssASN1Encoder *encoder, PRBool takeFromBuffer)
NSS_EXTERN PRStatus nssASN1Encoder_GetTakeFromBuffer (nssASN1Encoder *encoder, PRBool *pTakeFromBuffer)
NSS_EXTERN PRStatus nssASN1_Encode (const void *source, const nssASN1Template template[], NSSASN1EncodingType encoding, nssASN1EncoderWriteFunction *sink, void *argument)
NSS_EXTERN NSSDERnssASN1_EncodeItem (NSSArena *arenaOpt, NSSDER *rvOpt, const void *source, const nssASN1Template template[], NSSASN1EncodingType encoding)
NSS_EXTERN PRStatus nssASN1_CreatePRUint32FromBER (NSSBER *encoded, PRUint32 *pResult)
NSS_EXTERN NSSDERnssASN1_GetDERFromPRUint32 (NSSArena *arenaOpt, NSSDER *rvOpt, PRUint32 value)
NSS_EXTERN PRStatus nssASN1_CreatePRInt32FromBER (NSSBER *encoded, PRInt32 *pResult)
NSS_EXTERN NSSDERnssASN1_GetDERFromPRInt32 (NSSArena *arenaOpt, NSSDER *rvOpt, PRInt32 value)
NSS_EXTERN NSSUTF8nssUTF8_CreateFromBER (NSSArena *arenaOpt, nssStringType type, NSSBER *berData)
NSS_EXTERN NSSDERnssUTF8_GetDEREncoding (NSSArena *arenaOpt, nssStringType type, const NSSUTF8 *string)

Variables

const NSSError NSS_ERROR_NO_MEMORY
const NSSError NSS_ERROR_INVALID_ARENA
const NSSError NSS_ERROR_INVALID_POINTER
const NSSError NSS_ERROR_INVALID_ASN1DECODER
const NSSError NSS_ERROR_INVALID_BER
const NSSError NSS_ERROR_ENCODING_NOT_SUPPORTED
const NSSError NSS_ERROR_INVALID_ASN1ENCODER
const nssASN1TemplatenssASN1Template_Any
const nssASN1TemplatenssASN1Template_BitString
const nssASN1TemplatenssASN1Template_BMPString
const nssASN1TemplatenssASN1Template_Boolean
const nssASN1TemplatenssASN1Template_Enumerated
const nssASN1TemplatenssASN1Template_GeneralizedTime
const nssASN1TemplatenssASN1Template_IA5String
const nssASN1TemplatenssASN1Template_Integer
const nssASN1TemplatenssASN1Template_Null
const nssASN1TemplatenssASN1Template_ObjectID
const nssASN1TemplatenssASN1Template_OctetString
const nssASN1TemplatenssASN1Template_PrintableString
const nssASN1TemplatenssASN1Template_T61String
const nssASN1TemplatenssASN1Template_UniversalString
const nssASN1TemplatenssASN1Template_UTCTime
const nssASN1TemplatenssASN1Template_UTF8String
const nssASN1TemplatenssASN1Template_VisibleString
const nssASN1TemplatenssASN1Template_PointerToAny
const nssASN1TemplatenssASN1Template_PointerToBitString
const nssASN1TemplatenssASN1Template_PointerToBMPString
const nssASN1TemplatenssASN1Template_PointerToBoolean
const nssASN1TemplatenssASN1Template_PointerToEnumerated
const nssASN1TemplatenssASN1Template_PointerToGeneralizedTime
const nssASN1TemplatenssASN1Template_PointerToIA5String
const nssASN1TemplatenssASN1Template_PointerToInteger
const nssASN1TemplatenssASN1Template_PointerToNull
const nssASN1TemplatenssASN1Template_PointerToObjectID
const nssASN1TemplatenssASN1Template_PointerToOctetString
const nssASN1TemplatenssASN1Template_PointerToPrintableString
const nssASN1TemplatenssASN1Template_PointerToT61String
const nssASN1TemplatenssASN1Template_PointerToUniversalString
const nssASN1TemplatenssASN1Template_PointerToUTCTime
const nssASN1TemplatenssASN1Template_PointerToUTF8String
const nssASN1TemplatenssASN1Template_PointerToVisibleString
const nssASN1TemplatenssASN1Template_SetOfAny
const nssASN1TemplatenssASN1Template_SetOfBitString
const nssASN1TemplatenssASN1Template_SetOfBMPString
const nssASN1TemplatenssASN1Template_SetOfBoolean
const nssASN1TemplatenssASN1Template_SetOfEnumerated
const nssASN1TemplatenssASN1Template_SetOfGeneralizedTime
const nssASN1TemplatenssASN1Template_SetOfIA5String
const nssASN1TemplatenssASN1Template_SetOfInteger
const nssASN1TemplatenssASN1Template_SetOfNull
const nssASN1TemplatenssASN1Template_SetOfObjectID
const nssASN1TemplatenssASN1Template_SetOfOctetString
const nssASN1TemplatenssASN1Template_SetOfPrintableString
const nssASN1TemplatenssASN1Template_SetOfT61String
const nssASN1TemplatenssASN1Template_SetOfUniversalString
const nssASN1TemplatenssASN1Template_SetOfUTCTime
const nssASN1TemplatenssASN1Template_SetOfUTF8String
const nssASN1TemplatenssASN1Template_SetOfVisibleString

Function Documentation

Definition at line 1330 of file asn1.c.

Here is the call graph for this function:

Definition at line 1267 of file asn1.c.

Here is the call graph for this function:

NSS_EXTERN PRStatus nssASN1_Decode ( NSSArena *  arenaOpt,
void destination,
const nssASN1Template  template[],
const void berData,
PRUint32  amount 
)

Definition at line 612 of file asn1.c.

{
  PRStatus rv;
  nssASN1Decoder *decoder;

  /* This call will do our pointer-checking for us! */
  decoder = nssASN1Decoder_Create(arenaOpt, destination, template);
  if( (nssASN1Decoder *)NULL == decoder ) {
    return PR_FAILURE;
  }

  rv = nssASN1Decoder_Update(decoder, berData, amount);
  if( PR_SUCCESS != nssASN1Decoder_Finish(decoder) ) {
    rv = PR_FAILURE;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssASN1_DecodeBER ( NSSArena *  arenaOpt,
void destination,
const nssASN1Template  template[],
const NSSBER data 
)

Definition at line 659 of file asn1.c.

{
  return nssASN1_Decode(arenaOpt, destination, template, 
                        data->data, data->size);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssASN1_Encode ( const void source,
const nssASN1Template  template[],
NSSASN1EncodingType  encoding,
nssASN1EncoderWriteFunction sink,
void argument 
)

Definition at line 1091 of file asn1.c.

{
  PRStatus rv;
  nssASN1Encoder *encoder;

  encoder = nssASN1Encoder_Create(source, template, encoding, sink, argument);
  if( (nssASN1Encoder *)NULL == encoder ) {
    return PR_FAILURE;
  }

  rv = nssASN1Encoder_Update(encoder, (const void *)NULL, 0);
  if( PR_SUCCESS != nssASN1Encoder_Finish(encoder) ) {
    rv = PR_FAILURE;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSDER* nssASN1_EncodeItem ( NSSArena *  arenaOpt,
NSSDER rvOpt,
const void source,
const nssASN1Template  template[],
NSSASN1EncodingType  encoding 
)

Definition at line 1187 of file asn1.c.

{
  NSSDER *rv;
  PRUint32 len = 0;
  PRStatus status;

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

  if( (void *)NULL == source ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSDER *)NULL;
  }

  if( (nssASN1Template *)NULL == template ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSDER *)NULL;
  }
#endif /* DEBUG */

  status = nssASN1_Encode(source, template, encoding, 
                          (nssASN1EncoderWriteFunction *)nssasn1_encode_item_count, 
                          &len);
  if( PR_SUCCESS != status ) {
    return (NSSDER *)NULL;
  }

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

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

  rv->size = 0; /* for nssasn1_encode_item_store */

  status = nssASN1_Encode(source, template, encoding,
                          (nssASN1EncoderWriteFunction *)nssasn1_encode_item_store, 
                          rv);
  if( PR_SUCCESS != status ) {
    nss_ZFreeIf(rv->data);
    if( (NSSDER *)NULL == rvOpt ) {
      nss_ZFreeIf(rv);
    }
    return (NSSDER *)NULL;
  }

  PR_ASSERT(rv->size == len);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSDER* nssASN1_GetDERFromPRInt32 ( NSSArena *  arenaOpt,
NSSDER rvOpt,
PRInt32  value 
)

Definition at line 1346 of file asn1.c.

{
  NSSDER *rv;
  PLArenaPool *hack = (PLArenaPool *)arenaOpt;
  SECItem *item;

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

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

  item = SEC_ASN1EncodeInteger(hack, (SECItem *)rv, value);
  if( (SECItem *)NULL == item ) {
    if( (NSSDER *)NULL == rvOpt ) {
      (void)nss_ZFreeIf(rv);
    }

    nss_SetError(PORT_GetError()); /* ugly */
    return (NSSDER *)NULL;
  }

  /* 
   * I happen to know that these things look alike.. but I'm only
   * doing it for these "temporary" wrappers.  This is an evil thing.
   */
  return (NSSDER *)item;
}

Here is the call graph for this function:

NSS_EXTERN NSSDER* nssASN1_GetDERFromPRUint32 ( NSSArena *  arenaOpt,
NSSDER rvOpt,
PRUint32  value 
)

Definition at line 1283 of file asn1.c.

{
  NSSDER *rv;
  PLArenaPool *hack = (PLArenaPool *)arenaOpt;
  SECItem *item;

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

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

  item = SEC_ASN1EncodeUnsignedInteger(hack, (SECItem *)rv, value);
  if( (SECItem *)NULL == item ) {
    if( (NSSDER *)NULL == rvOpt ) {
      (void)nss_ZFreeIf(rv);
    }

    nss_SetError(PORT_GetError()); /* ugly */
    return (NSSDER *)NULL;
  }

  /* 
   * I happen to know that these things look alike.. but I'm only
   * doing it for these "temporary" wrappers.  This is an evil thing.
   */
  return (NSSDER *)item;
}

Here is the call graph for this function:

PR_BEGIN_EXTERN_C NSS_EXTERN nssASN1Decoder* nssASN1Decoder_Create ( NSSArena *  arenaOpt,
void destination,
const nssASN1Template  template[] 
)

Definition at line 253 of file asn1.c.

{
  SEC_ASN1DecoderContext *rv;
  PLArenaPool *hack = (PLArenaPool *)arenaOpt;

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

  /* 
   * May destination be NULL?  I'd think so, since one might
   * have only a filter proc.  But if not, check the pointer here.
   */

  if( (nssASN1Template *)NULL == template ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (nssASN1Decoder *)NULL;
  }
#endif /* DEBUG */

  rv = SEC_ASN1DecoderStart(hack, destination, template);
  if( (SEC_ASN1DecoderContext *)NULL == rv ) {
    nss_SetError(PORT_GetError()); /* also evil */
    return (nssASN1Decoder *)NULL;
  }

#ifdef DEBUG
  if( PR_SUCCESS != decoder_add_pointer(rv) ) {
    (void)SEC_ASN1DecoderFinish(rv);
    return (nssASN1Decoder *)NULL;
  }
#endif /* DEBUG */

  return (nssASN1Decoder *)rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 363 of file asn1.c.

{
  PRStatus rv = PR_SUCCESS;
  SECStatus srv;

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

  srv = SEC_ASN1DecoderFinish((SEC_ASN1DecoderContext *)decoder);

  if( SECSuccess != srv ) {
    nss_SetError(PORT_GetError()); /* ugly */
    rv = PR_FAILURE;
  }

#ifdef DEBUG
  {
    PRStatus rv2 = decoder_remove_pointer(decoder);
    if( PR_SUCCESS == rv ) {
      rv = rv2;
    }
  }
#endif /* DEBUG */

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssASN1Decoder_GetFilter ( nssASN1Decoder decoder,
nssASN1DecoderFilterFunction **  pCallbackOpt,
void **  pArgumentOpt,
PRBool pNoStoreOpt 
)

Definition at line 470 of file asn1.c.

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

  if( (nssASN1DecoderFilterFunction **)NULL != pCallbackOpt ) {
    *pCallbackOpt = (nssASN1DecoderFilterFunction *)NULL;
  }

  if( (void **)NULL != pArgumentOpt ) {
    *pArgumentOpt = (void *)NULL;
  }

  if( (PRBool *)NULL != pNoStoreOpt ) {
    *pNoStoreOpt = PR_FALSE;
  }

  /* Error because it's unimplemented */
  nss_SetError(NSS_ERROR_INTERNAL_ERROR);
  return PR_FAILURE;
}

Here is the call graph for this function:

NSS_EXTERN PRStatus nssASN1Decoder_GetNotify ( nssASN1Decoder decoder,
nssASN1NotifyFunction **  pCallbackOpt,
void **  pArgumentOpt 
)

Definition at line 566 of file asn1.c.

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

  if( (nssASN1NotifyFunction **)NULL != pCallbackOpt ) {
    *pCallbackOpt = (nssASN1NotifyFunction *)NULL;
  }

  if( (void **)NULL != pArgumentOpt ) {
    *pArgumentOpt = (void *)NULL;
  }

  /* Error because it's unimplemented */
  nss_SetError(NSS_ERROR_INTERNAL_ERROR);
  return PR_FAILURE;
}

Here is the call graph for this function:

NSS_EXTERN PRStatus nssASN1Decoder_SetFilter ( nssASN1Decoder decoder,
nssASN1DecoderFilterFunction callback,
void argument,
PRBool  noStore 
)

Definition at line 418 of file asn1.c.

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

  if( (nssASN1DecoderFilterFunction *)NULL == callback ) {
     SEC_ASN1DecoderClearFilterProc((SEC_ASN1DecoderContext *)decoder);
  } else {
     SEC_ASN1DecoderSetFilterProc((SEC_ASN1DecoderContext *)decoder,
                                  (SEC_ASN1WriteProc)callback,
                                  argument, noStore);
  }

  /* No error returns defined for those routines */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 520 of file asn1.c.

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

  if( (nssASN1NotifyFunction *)NULL == callback ) {
    SEC_ASN1DecoderClearNotifyProc((SEC_ASN1DecoderContext *)decoder);
  } else {
    SEC_ASN1DecoderSetNotifyProc((SEC_ASN1DecoderContext *)decoder,
                                 (SEC_ASN1NotifyProc)callback,
                                 argument);
  }

  /* No error returns defined for those routines */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 316 of file asn1.c.

{
  SECStatus rv;

#ifdef DEBUG
  if( PR_SUCCESS != nssASN1Decoder_verify(decoder) ) {
    return PR_FAILURE;
  }

  if( (void *)NULL == data ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return PR_FAILURE;
  }
#endif /* DEBUG */

  rv = SEC_ASN1DecoderUpdate((SEC_ASN1DecoderContext *)decoder, 
                             (const char *)data,
                             (unsigned long)amount);
  if( SECSuccess != rv ) {
    nss_SetError(PORT_GetError()); /* ugly */
    return PR_FAILURE;
  }

  return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 690 of file asn1.c.

{
  SEC_ASN1EncoderContext *rv;

#ifdef DEBUG
  if( (void *)NULL == source ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (nssASN1Encoder *)NULL;
  }

  if( (nssASN1Template *)NULL == template ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (nssASN1Encoder *)NULL;
  }

  if( (nssASN1EncoderWriteFunction *)NULL == sink ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (nssASN1Encoder *)NULL;
  }
#endif /* DEBUG */

  switch( encoding ) {
  case NSSASN1BER:
  case NSSASN1DER:
    break;
  case NSSASN1CER:
  case NSSASN1LWER:
  case NSSASN1PER:
  case NSSASN1UnknownEncoding:
  default:
    nss_SetError(NSS_ERROR_ENCODING_NOT_SUPPORTED);
    return (nssASN1Encoder *)NULL;
  }

  rv = SEC_ASN1EncoderStart((void *)source, template, 
                            (SEC_ASN1WriteProc)sink, argument);
  if( (SEC_ASN1EncoderContext *)NULL == rv ) {
    nss_SetError(PORT_GetError()); /* ugly */
    return (nssASN1Encoder *)NULL;
  }

  if( NSSASN1DER == encoding ) {
    sec_ASN1EncoderSetDER(rv);
  }

#ifdef DEBUG
  if( PR_SUCCESS != encoder_add_pointer(rv) ) {
    (void)SEC_ASN1EncoderFinish(rv);
    return (nssASN1Encoder *)NULL;
  }
#endif /* DEBUG */

  return (nssASN1Encoder *)rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 809 of file asn1.c.

{
  PRStatus rv;

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

  SEC_ASN1EncoderFinish((SEC_ASN1EncoderContext *)encoder);
  rv = PR_SUCCESS; /* no error return defined for that call */

#ifdef DEBUG
  {
    PRStatus rv2 = encoder_remove_pointer(encoder);
    if( PR_SUCCESS == rv ) {
      rv = rv2;
    }
  }
#endif /* DEBUG */

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN PRStatus nssASN1Encoder_GetNotify ( nssASN1Encoder encoder,
nssASN1NotifyFunction **  pCallbackOpt,
void **  pArgumentOpt 
)

Definition at line 902 of file asn1.c.

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

  if( (nssASN1NotifyFunction **)NULL != pCallbackOpt ) {
    *pCallbackOpt = (nssASN1NotifyFunction *)NULL;
  }

  if( (void **)NULL != pArgumentOpt ) {
    *pArgumentOpt = (void *)NULL;
  }

  /* Error because it's unimplemented */
  nss_SetError(NSS_ERROR_INTERNAL_ERROR);
  return PR_FAILURE;
}

Here is the call graph for this function:

Definition at line 980 of file asn1.c.

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

  if( (PRBool *)NULL != pStreaming ) {
    *pStreaming = PR_FALSE;
  }

  /* Error because it's unimplemented */
  nss_SetError(NSS_ERROR_INTERNAL_ERROR);
  return PR_FAILURE;
}

Here is the call graph for this function:

Definition at line 1053 of file asn1.c.

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

  if( (PRBool *)NULL != pTakeFromBuffer ) {
    *pTakeFromBuffer = PR_FALSE;
  }

  /* Error because it's unimplemented */
  nss_SetError(NSS_ERROR_INTERNAL_ERROR);
  return PR_FAILURE;
}

Here is the call graph for this function:

Definition at line 856 of file asn1.c.

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

  if( (nssASN1NotifyFunction *)NULL == callback ) {
    SEC_ASN1EncoderClearNotifyProc((SEC_ASN1EncoderContext *)encoder);
  } else {
    SEC_ASN1EncoderSetNotifyProc((SEC_ASN1EncoderContext *)encoder,
                                 (SEC_ASN1NotifyProc)callback,
                                 argument);
  }

  /* no error return defined for those routines */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 941 of file asn1.c.

{
  SEC_ASN1EncoderContext *cx = (SEC_ASN1EncoderContext *)encoder;

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

  if( streaming ) {
    SEC_ASN1EncoderSetStreaming(cx);
  } else {
    SEC_ASN1EncoderClearStreaming(cx);
  }

  /* no error return defined for those routines */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 1014 of file asn1.c.

{
  SEC_ASN1EncoderContext *cx = (SEC_ASN1EncoderContext *)encoder;

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

  if( takeFromBuffer ) {
    SEC_ASN1EncoderSetTakeFromBuf(cx);
  } else {
    SEC_ASN1EncoderClearTakeFromBuf(cx);
  }

  /* no error return defined for those routines */

  return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 765 of file asn1.c.

{
  SECStatus rv;

#ifdef DEBUG
  if( PR_SUCCESS != nssASN1Encoder_verify(encoder) ) {
    return PR_FAILURE;
  }

  /*
   * Can data legitimately be NULL?  If not, verify..
   */
#endif /* DEBUG */

  rv = SEC_ASN1EncoderUpdate((SEC_ASN1EncoderContext *)encoder,
                             (const char *)data, 
                             (unsigned long)length);
  if( SECSuccess != rv ) {
    nss_SetError(PORT_GetError()); /* ugly */
    return PR_FAILURE;
  }

  return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSUTF8* nssUTF8_CreateFromBER ( NSSArena *  arenaOpt,
nssStringType  type,
NSSBER berData 
)

Definition at line 1460 of file asn1.c.

{
  NSSUTF8 *rv = NULL;
  PRUint8 tag;
  NSSArena *a;
  NSSItem in;
  NSSItem out;
  PRStatus st;
  const nssASN1Template *templ;

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

  if( (NSSBER *)NULL == berData ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSUTF8 *)NULL;
  }

  if( (void *)NULL == berData->data ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSUTF8 *)NULL;
  }
#endif /* NSSDEBUG */

  a = NSSArena_Create();
  if( (NSSArena *)NULL == a ) {
    return (NSSUTF8 *)NULL;
  }

  in = *berData;

  /*
   * By the way, at first I succumbed to the temptation to make
   * this an incestuous nested switch statement.  Count yourself
   * lucky I cleaned it up.
   */

  switch( type ) {
  case nssStringType_DirectoryString:
    /*
     * draft-ietf-pkix-ipki-part1-11 says in part:
     *
     * DirectoryString { INTEGER:maxSize } ::= CHOICE {
     *   teletexString           TeletexString (SIZE (1..maxSize)),
     *   printableString         PrintableString (SIZE (1..maxSize)),
     *   universalString         UniversalString (SIZE (1..maxSize)),
     *   bmpString               BMPString (SIZE(1..maxSize)),
     *   utf8String              UTF8String (SIZE(1..maxSize))
     *                       }
     *
     * The tags are:
     *  TeletexString       UNIVERSAL 20
     *  PrintableString     UNIVERSAL 19
     *  UniversalString     UNIVERSAL 28
     *  BMPString           UNIVERSAL 30
     *  UTF8String          UNIVERSAL 12
     *
     * "UNIVERSAL" tags have bits 8 and 7 zero, bit 6 is zero for
     * primitive encodings, and if the tag value is less than 30,
     * the tag value is directly encoded in bits 5 through 1.
     */
    in.data = (void *)&(((PRUint8 *)berData->data)[1]);
    in.size = berData->size-1;
    
    tag = *(PRUint8 *)berData->data;
    switch( tag & nssASN1_TAGNUM_MASK ) {
    case 20:
      /*
       * XXX fgmr-- we have to accept Latin-1 for Teletex; (see
       * below) but is T61 a suitable value for "Latin-1"?
       */
      templ = nssASN1Template_T61String;
      type = nssStringType_TeletexString;
      break;
    case 19:
      templ = nssASN1Template_PrintableString;
      type = nssStringType_PrintableString;
      break;
    case 28:
      templ = nssASN1Template_UniversalString;
      type = nssStringType_UniversalString;
      break;
    case 30:
      templ = nssASN1Template_BMPString;
      type = nssStringType_BMPString;
      break;
    case 12:
      templ = nssASN1Template_UTF8String;
      type = nssStringType_UTF8String;
      break;
    default:
      nss_SetError(NSS_ERROR_INVALID_POINTER); /* "pointer"? */
      (void)NSSArena_Destroy(a);
      return (NSSUTF8 *)NULL;
    }

    break;

  case nssStringType_TeletexString:
    /*
     * XXX fgmr-- we have to accept Latin-1 for Teletex; (see
     * below) but is T61 a suitable value for "Latin-1"?
     */
    templ = nssASN1Template_T61String;
    break;
   
  case nssStringType_PrintableString:
    templ = nssASN1Template_PrintableString;
    break;

  case nssStringType_UniversalString:
    templ = nssASN1Template_UniversalString;
    break;

  case nssStringType_BMPString:
    templ = nssASN1Template_BMPString;
    break;

  case nssStringType_UTF8String:
    templ = nssASN1Template_UTF8String;
    break;

  case nssStringType_PHGString:
    templ = nssASN1Template_IA5String;
    break;

  default:
    nss_SetError(NSS_ERROR_UNSUPPORTED_TYPE);
    (void)NSSArena_Destroy(a);
    return (NSSUTF8 *)NULL;
  }
    
  st = nssASN1_DecodeBER(a, &out, templ, &in);
  
  if( PR_SUCCESS == st ) {
    rv = nssUTF8_Create(arenaOpt, type, out.data, out.size);
  }
  (void)NSSArena_Destroy(a);
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NSS_EXTERN NSSDER* nssUTF8_GetDEREncoding ( NSSArena *  arenaOpt,
nssStringType  type,
const NSSUTF8 string 
)

Definition at line 1612 of file asn1.c.

{
  NSSDER *rv = (NSSDER *)NULL;
  NSSItem str;
  NSSDER *der;
  const nssASN1Template *templ;
  NSSArena *a;

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

  if( (const NSSUTF8 *)NULL == string ) {
    nss_SetError(NSS_ERROR_INVALID_POINTER);
    return (NSSDER *)NULL;
  }
#endif /* NSSDEBUG */

  str.data = (void *)string;
  str.size = nssUTF8_Size(string, (PRStatus *)NULL);
  if( 0 == str.size ) {
    return (NSSDER *)NULL;
  }

  a = NSSArena_Create();
  if( (NSSArena *)NULL == a ) {
    return (NSSDER *)NULL;
  }

  switch( type ) {
  case nssStringType_DirectoryString:
    {
      NSSDER *utf;
      PRUint8 *c;

      utf = nssASN1_EncodeItem(a, (NSSDER *)NULL, &str, 
                               nssASN1Template_UTF8String,
                               NSSASN1DER);
      if( (NSSDER *)NULL == utf ) {
        (void)NSSArena_Destroy(a);
        return (NSSDER *)NULL;
      }

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

      rv->size = utf->size + 1;
      rv->data = nss_ZAlloc(arenaOpt, rv->size);
      if( (void *)NULL == rv->data ) {
        (void)nss_ZFreeIf(rv);
        (void)NSSArena_Destroy(a);
        return (NSSDER *)NULL;
      }
      
      c = (PRUint8 *)rv->data;
      (void)nsslibc_memcpy(&c[1], utf->data, utf->size);
      *c = 12; /* UNIVERSAL primitive encoding tag for UTF8String */

      (void)NSSArena_Destroy(a);
      return rv;
    }
  case nssStringType_TeletexString:
    /*
     * XXX fgmr-- we have to accept Latin-1 for Teletex; (see
     * below) but is T61 a suitable value for "Latin-1"?
     */
    templ = nssASN1Template_T61String;
    break;
  case nssStringType_PrintableString:
    templ = nssASN1Template_PrintableString;
    break;

  case nssStringType_UniversalString:
    templ = nssASN1Template_UniversalString;
    break;

  case nssStringType_BMPString:
    templ = nssASN1Template_BMPString;
    break;

  case nssStringType_UTF8String:
    templ = nssASN1Template_UTF8String;
    break;

  case nssStringType_PHGString:
    templ = nssASN1Template_IA5String;
    break;

  default:
    nss_SetError(NSS_ERROR_UNSUPPORTED_TYPE);
    (void)NSSArena_Destroy(a);
    return (NSSDER *)NULL;
  }

  der = nssUTF8_GetDEREncoding(a, type, string);
  if( (NSSItem *)NULL == der ) {
    (void)NSSArena_Destroy(a);
    return (NSSDER *)NULL;
  }

  rv = nssASN1_EncodeItem(arenaOpt, (NSSDER *)NULL, der, templ, NSSASN1DER);
  if( (NSSDER *)NULL == rv ) {
    (void)NSSArena_Destroy(a);
    return (NSSDER *)NULL;
  }

  (void)NSSArena_Destroy(a);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 695 of file asn1.h.

Definition at line 353 of file asn1.h.

Definition at line 172 of file asn1.h.

Definition at line 492 of file asn1.h.

Definition at line 355 of file asn1.h.

Definition at line 354 of file asn1.h.

Definition at line 147 of file asn1.h.

Definition at line 1400 of file asn1.c.

Definition at line 1401 of file asn1.c.

Definition at line 1402 of file asn1.c.

Definition at line 1403 of file asn1.c.

Definition at line 1404 of file asn1.c.

Definition at line 1405 of file asn1.c.

Definition at line 1406 of file asn1.c.

Definition at line 1407 of file asn1.c.

Definition at line 1408 of file asn1.c.

Definition at line 1409 of file asn1.c.

Definition at line 1410 of file asn1.c.

Definition at line 1418 of file asn1.c.

Definition at line 1419 of file asn1.c.

Definition at line 1420 of file asn1.c.

Definition at line 1421 of file asn1.c.

Definition at line 1422 of file asn1.c.

Definition at line 1423 of file asn1.c.

Definition at line 1424 of file asn1.c.

Definition at line 1425 of file asn1.c.

Definition at line 1426 of file asn1.c.

Definition at line 1427 of file asn1.c.

Definition at line 1428 of file asn1.c.

Definition at line 1429 of file asn1.c.

Definition at line 1430 of file asn1.c.

Definition at line 1431 of file asn1.c.

Definition at line 1432 of file asn1.c.

Definition at line 1433 of file asn1.c.

Definition at line 1434 of file asn1.c.

Definition at line 1411 of file asn1.c.

Definition at line 1436 of file asn1.c.

Definition at line 1437 of file asn1.c.

Definition at line 1438 of file asn1.c.

Definition at line 1439 of file asn1.c.

Definition at line 1440 of file asn1.c.

Definition at line 1441 of file asn1.c.

Definition at line 1442 of file asn1.c.

Definition at line 1443 of file asn1.c.

Definition at line 1444 of file asn1.c.

Definition at line 1445 of file asn1.c.

Definition at line 1446 of file asn1.c.

Definition at line 1447 of file asn1.c.

Definition at line 1448 of file asn1.c.

Definition at line 1449 of file asn1.c.

Definition at line 1450 of file asn1.c.

Definition at line 1451 of file asn1.c.

Definition at line 1452 of file asn1.c.

Definition at line 1412 of file asn1.c.

Definition at line 1413 of file asn1.c.

Definition at line 1414 of file asn1.c.

Definition at line 1415 of file asn1.c.

Definition at line 1416 of file asn1.c.