Back to index

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

Go to the source code of this file.

Functions

SECStatus SEC_PKCS12PutPFX (SECItem *der_pfx, SECItem *pwitem, SEC_PKCS12NicknameCollisionCallback ncCall, PK11SlotInfo *slot, void *wincx)
PRBool SEC_PKCS12ValidData (char *buf, int bufLen, long int totalLength)

Variables

SEC_BEGIN_PROTOS typedef
SECItem *(* 
SEC_PKCS12GetPassword )(void *arg)

Function Documentation

SECStatus SEC_PKCS12PutPFX ( SECItem *  der_pfx,
SECItem *  pwitem,
SEC_PKCS12NicknameCollisionCallback  ncCall,
PK11SlotInfo *  slot,
void wincx 
)

Definition at line 589 of file p12dec.c.

{
    SEC_PKCS12PFXItem *pfx;
    SEC_PKCS12AuthenticatedSafe *asafe;
    SEC_PKCS12SafeContents *safe_contents = NULL;
    SECStatus rv;

    if(!der_pfx || !pwitem || !slot) {
       return SECFailure;
    }

    /* decode and validate each section */
    rv = SECFailure;

    pfx = sec_pkcs12_get_pfx(der_pfx, pwitem);
    if(pfx != NULL) {
       asafe = sec_pkcs12_get_auth_safe(pfx);
       if(asafe != NULL) {

           /* decrypt safe -- only if not empty */
           if(asafe->emptySafe != PR_TRUE) {
              rv = sec_pkcs12_decrypt_auth_safe(asafe, pwitem, wincx);
              if(rv == SECSuccess) {
                  safe_contents = sec_pkcs12_get_safe_contents(asafe);
                  if(safe_contents == NULL) {
                     rv = SECFailure;
                  }
              }
           } else {
              safe_contents = sec_pkcs12_create_safe_contents(asafe->poolp);
              safe_contents->swapUnicode = pfx->swapUnicode;
              if(safe_contents == NULL) {
                  rv = SECFailure;
              } else {
                  rv = SECSuccess;
              }
           }

           /* get safe contents and begin import */
           if(rv == SECSuccess) {
              SEC_PKCS12DecoderContext *p12dcx;

              p12dcx = sec_PKCS12ConvertOldSafeToNew(pfx->poolp, slot,
                                   pfx->swapUnicode,
                                   pwitem, wincx, safe_contents,
                                   &asafe->baggage);
              if(!p12dcx) {
                  rv = SECFailure;
                  goto loser;
              }

              if(SEC_PKCS12DecoderValidateBags(p12dcx, ncCall) 
                            != SECSuccess) {
                  rv = SECFailure;
                  goto loser;
              }

              rv = SEC_PKCS12DecoderImportBags(p12dcx);
           }

       }
    }

loser:

    if(pfx) {
       SEC_PKCS12DestroyPFX(pfx);
    }

    return rv;
}

Here is the call graph for this function:

PRBool SEC_PKCS12ValidData ( char *  buf,
int  bufLen,
long int  totalLength 
)

Definition at line 665 of file p12dec.c.

{
    int lengthLength;

    PRBool valid = PR_FALSE;

    if(buf == NULL) {
       return PR_FALSE;
    }

    /* check for constructed sequence identifier tag */
    if(*buf == (SEC_ASN1_CONSTRUCTED | SEC_ASN1_SEQUENCE)) {
       totalLength--;   /* header byte taken care of */
       buf++;

       lengthLength = (long int)SEC_ASN1LengthLength(totalLength - 1);
       if(totalLength > 0x7f) {
           lengthLength--;
           *buf &= 0x7f;  /* remove bit 8 indicator */
           if((*buf - (char)lengthLength) == 0) {
              valid = PR_TRUE;
           }
       } else {
           lengthLength--;
           if((*buf - (char)lengthLength) == 0) {
              valid = PR_TRUE;
           }
       }
    }

    return valid;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 46 of file pkcs12.h.