Back to index

lightning-sunbird  0.9+nobinonly
Functions
secasn1u.c File Reference
#include "secasn1.h"

Go to the source code of this file.

Functions

int SEC_ASN1LengthLength (unsigned long len)
const SEC_ASN1TemplateSEC_ASN1GetSubtemplate (const SEC_ASN1Template *theTemplate, void *thing, PRBool encoding)
PRBool SEC_ASN1IsTemplateSimple (const SEC_ASN1Template *theTemplate)

Function Documentation

const SEC_ASN1Template* SEC_ASN1GetSubtemplate ( const SEC_ASN1Template theTemplate,
void thing,
PRBool  encoding 
)

Definition at line 88 of file secasn1u.c.

{
    const SEC_ASN1Template *subt = NULL;

    PORT_Assert (theTemplate->sub != NULL);
    if (theTemplate->sub != NULL) {
       if (theTemplate->kind & SEC_ASN1_DYNAMIC) {
           SEC_ASN1TemplateChooserPtr chooserp;

           chooserp = *(SEC_ASN1TemplateChooserPtr *) theTemplate->sub;
           if (chooserp) {
              if (thing != NULL)
                  thing = (char *)thing - theTemplate->offset;
              subt = (* chooserp)(thing, encoding);
           }
       } else {
           subt = (SEC_ASN1Template*)theTemplate->sub;
       }
    }
    return subt;
}

Definition at line 111 of file secasn1u.c.

{
    if (!theTemplate) {
       return PR_TRUE; /* it doesn't get any simpler than NULL */
    }
    /* only templates made of one primitive type or a choice of primitive
       types are considered simple */
    if (! (theTemplate->kind & (~SEC_ASN1_TAGNUM_MASK))) {
       return PR_TRUE; /* primitive type */
    }
    if (!theTemplate->kind & SEC_ASN1_CHOICE) {
       return PR_FALSE; /* no choice means not simple */
    }
    while (++theTemplate && theTemplate->kind) {
       if (theTemplate->kind & (~SEC_ASN1_TAGNUM_MASK)) {
           return PR_FALSE; /* complex type */
       }
    }
    return PR_TRUE; /* choice of primitive types */
}
int SEC_ASN1LengthLength ( unsigned long  len)

Definition at line 55 of file secasn1u.c.

{
    int lenlen = 1;

    if (len > 0x7f) {
       do {
           lenlen++;
           len >>= 8;
       } while (len);
    }

    return lenlen;
}