Back to index

lightning-sunbird  0.9+nobinonly
Functions
p12local.h File Reference
#include "plarena.h"
#include "secoidt.h"
#include "secasn1.h"
#include "secder.h"
#include "certt.h"
#include "secpkcs7.h"
#include "pkcs12.h"
#include "p12.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const SEC_ASN1Templatesec_pkcs12_choose_bag_type (void *src_or_dest, PRBool encoding)
const SEC_ASN1Templatesec_pkcs12_choose_cert_crl_type (void *src_or_dest, PRBool encoding)
const SEC_ASN1Templatesec_pkcs12_choose_shroud_type (void *src_or_dest, PRBool encoding)
SECItem * sec_pkcs12_generate_salt (void)
SECItem * sec_pkcs12_generate_key_from_password (SECOidTag algorithm, SECItem *salt, SECItem *password)
SECItem * sec_pkcs12_generate_mac (SECItem *key, SECItem *msg, PRBool old_method)
SGNDigestInfo * sec_pkcs12_compute_thumbprint (SECItem *der_cert)
SECItem * sec_pkcs12_create_virtual_password (SECItem *password, SECItem *salt, PRBool swapUnicodeBytes)
SECStatus sec_pkcs12_append_shrouded_key (SEC_PKCS12BaggageItem *bag, SEC_PKCS12ESPVKItem *espvk)
voidsec_pkcs12_find_object (SEC_PKCS12SafeContents *safe, SEC_PKCS12Baggage *baggage, SECOidTag objType, SECItem *nickname, SGNDigestInfo *thumbprint)
PRBool sec_pkcs12_convert_item_to_unicode (PRArenaPool *arena, SECItem *dest, SECItem *src, PRBool zeroTerm, PRBool asciiConvert, PRBool toUnicode)
CK_MECHANISM_TYPE sec_pkcs12_algtag_to_mech (SECOidTag algtag)
SEC_PKCS12PFXItem * sec_pkcs12_new_pfx (void)
SEC_PKCS12SafeContents * sec_pkcs12_create_safe_contents (PRArenaPool *poolp)
SEC_PKCS12Baggage * sec_pkcs12_create_baggage (PRArenaPool *poolp)
SEC_PKCS12BaggageItem * sec_pkcs12_create_external_bag (SEC_PKCS12Baggage *luggage)
void SEC_PKCS12DestroyPFX (SEC_PKCS12PFXItem *pfx)
SEC_PKCS12AuthenticatedSafe * sec_pkcs12_new_asafe (PRArenaPool *poolp)
SEC_PKCS12DecoderContext * sec_PKCS12ConvertOldSafeToNew (PRArenaPool *arena, PK11SlotInfo *slot, PRBool swapUnicode, SECItem *pwitem, void *wincx, SEC_PKCS12SafeContents *safe, SEC_PKCS12Baggage *baggage)

Function Documentation

Definition at line 56 of file p12local.c.

{
    switch (algtag) {
    case SEC_OID_MD2:
       return CKM_MD2_HMAC;
    case SEC_OID_MD5:
       return CKM_MD5_HMAC;
    case SEC_OID_SHA1:
       return CKM_SHA_1_HMAC;
    case SEC_OID_SHA256:
       return CKM_SHA256_HMAC;
    case SEC_OID_SHA384:
       return CKM_SHA384_HMAC;
    case SEC_OID_SHA512:
       return CKM_SHA512_HMAC;
    default:
       break;
    }
    return CKM_INVALID_MECHANISM;
}

Here is the caller graph for this function:

SECStatus sec_pkcs12_append_shrouded_key ( SEC_PKCS12BaggageItem *  bag,
SEC_PKCS12ESPVKItem *  espvk 
)

Definition at line 610 of file p12local.c.

{
    int size;
    void *mark = NULL, *dummy = NULL;

    if((bag == NULL) || (espvk == NULL))
       return SECFailure;

    mark = PORT_ArenaMark(bag->poolp);

    /* grow the list */
    size = (bag->nEspvks + 1) * sizeof(SEC_PKCS12ESPVKItem *);
    dummy = (SEC_PKCS12ESPVKItem **)PORT_ArenaGrow(bag->poolp,
                                   bag->espvks, size, 
                                   size + sizeof(SEC_PKCS12ESPVKItem *));
    bag->espvks = (SEC_PKCS12ESPVKItem**)dummy;
    if(dummy == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       goto loser;
    }

    bag->espvks[bag->nEspvks] = espvk;
    bag->nEspvks++;
    bag->espvks[bag->nEspvks] = NULL;

    PORT_ArenaUnmark(bag->poolp, mark);
    return SECSuccess;

loser:
    PORT_ArenaRelease(bag->poolp, mark);
    return SECFailure;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const SEC_ASN1Template* sec_pkcs12_choose_bag_type ( void src_or_dest,
PRBool  encoding 
)

Definition at line 116 of file p12local.c.

{
    const SEC_ASN1Template *theTemplate;
    SEC_PKCS12SafeBag *safebag;
    SECOidData *oiddata;

    if (src_or_dest == NULL) {
       return NULL;
    }

    safebag = (SEC_PKCS12SafeBag*)src_or_dest;

    oiddata = safebag->safeBagTypeTag;
    if (oiddata == NULL) {
       oiddata = SECOID_FindOID(&safebag->safeBagType);
       safebag->safeBagTypeTag = oiddata;
    }

    switch (oiddata->offset) {
       default:
           theTemplate = SEC_ASN1_GET(SEC_AnyTemplate);
           break;
       case SEC_OID_PKCS12_KEY_BAG_ID:
           theTemplate = SEC_PKCS12PrivateKeyBagTemplate;
           break;
       case SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID:
           theTemplate = SEC_PKCS12CertAndCRLBagTemplate;
           break;
        case SEC_OID_PKCS12_SECRET_BAG_ID:
           theTemplate = SEC_PKCS12SecretBagTemplate;
           break;
    }
    return theTemplate;
}

Here is the call graph for this function:

Definition at line 185 of file p12local.c.

{
    const SEC_ASN1Template *theTemplate;
    SEC_PKCS12CertAndCRL *certbag;
    SECOidData *oiddata;

    if (src_or_dest == NULL) {
       return NULL;
    }

    certbag = (SEC_PKCS12CertAndCRL*)src_or_dest;
    oiddata = certbag->BagTypeTag;
    if (oiddata == NULL) {
       oiddata = SECOID_FindOID(&certbag->BagID);
       certbag->BagTypeTag = oiddata;
    }

    switch (oiddata->offset) {
       default:
           theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate);
           break;
       case SEC_OID_PKCS12_X509_CERT_CRL_BAG:
           theTemplate = SEC_PointerToPKCS12X509CertCRLTemplate;
           break;
       case SEC_OID_PKCS12_SDSI_CERT_BAG:
           theTemplate = SEC_PointerToPKCS12SDSICertTemplate;
           break;
    }
    return theTemplate;
}

Here is the call graph for this function:

const SEC_ASN1Template* sec_pkcs12_choose_shroud_type ( void src_or_dest,
PRBool  encoding 
)

Definition at line 218 of file p12local.c.

{
    const SEC_ASN1Template *theTemplate;
    SEC_PKCS12ESPVKItem *espvk;
    SECOidData *oiddata;

    if (src_or_dest == NULL) {
       return NULL;
    }

    espvk = (SEC_PKCS12ESPVKItem*)src_or_dest;
    oiddata = espvk->espvkTag;
    if (oiddata == NULL) {
       oiddata = SECOID_FindOID(&espvk->espvkOID);
       espvk->espvkTag = oiddata;
    }

    switch (oiddata->offset) {
       default:
           theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate);
           break;
       case SEC_OID_PKCS12_PKCS8_KEY_SHROUDING:
          theTemplate = 
              SEC_ASN1_GET(SECKEY_PointerToEncryptedPrivateKeyInfoTemplate);
           break;
    }
    return theTemplate;
}

Here is the call graph for this function:

SGNDigestInfo* sec_pkcs12_compute_thumbprint ( SECItem *  der_cert)

Definition at line 511 of file p12local.c.

{
    SGNDigestInfo *thumb = NULL;
    SECItem digest;
    PRArenaPool *temparena = NULL;
    SECStatus rv = SECFailure;

    if(der_cert == NULL)
       return NULL;

    temparena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE);
    if(temparena == NULL) {
       return NULL;
    }

    digest.data = (unsigned char *)PORT_ArenaZAlloc(temparena,
                                              sizeof(unsigned char) * 
                                              SHA1_LENGTH);
    /* digest data and create digest info */
    if(digest.data != NULL) {
       digest.len = SHA1_LENGTH;
       rv = PK11_HashBuf(SEC_OID_SHA1, digest.data, der_cert->data, 
                         der_cert->len);
       if(rv == SECSuccess) {
           thumb = SGN_CreateDigestInfo(SEC_OID_SHA1, 
                                    digest.data, 
                                    digest.len);
       } else {
           PORT_SetError(SEC_ERROR_NO_MEMORY);
       }
    } else {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
    }

    PORT_FreeArena(temparena, PR_TRUE);

    return thumb;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool sec_pkcs12_convert_item_to_unicode ( PRArenaPool arena,
SECItem *  dest,
SECItem *  src,
PRBool  zeroTerm,
PRBool  asciiConvert,
PRBool  toUnicode 
)

Definition at line 917 of file p12local.c.

{
    PRBool success = PR_FALSE;
    if(!src || !dest) {
       return PR_FALSE;
    }

    dest->len = src->len * 3 + 2;
    if(arena) {
       dest->data = (unsigned char*)PORT_ArenaZAlloc(arena, dest->len);
    } else {
       dest->data = (unsigned char*)PORT_ZAlloc(dest->len);
    }

    if(!dest->data) {
       dest->len = 0;
       return PR_FALSE;
    }

    if(!asciiConvert) {
       success = PORT_UCS2_UTF8Conversion(toUnicode, src->data, src->len, dest->data,
                                      dest->len, &dest->len);
    } else {
#ifndef IS_LITTLE_ENDIAN
       PRBool swapUnicode = PR_FALSE;
#else
       PRBool swapUnicode = PR_TRUE;
#endif
       success = PORT_UCS2_ASCIIConversion(toUnicode, src->data, src->len, dest->data,
                                       dest->len, &dest->len, swapUnicode);
    }

    if(!success) {
       if(!arena) {
           PORT_Free(dest->data);
           dest->data = NULL;
           dest->len = 0;
       }
       return PR_FALSE;
    }

    if((dest->data[dest->len-1] || dest->data[dest->len-2]) && zeroTerm) {
       if(dest->len + 2 > 3 * src->len) {
           if(arena) {
              dest->data = (unsigned char*)PORT_ArenaGrow(arena, 
                                               dest->data, dest->len,
                                               dest->len + 2);
           } else {
              dest->data = (unsigned char*)PORT_Realloc(dest->data, 
                                                   dest->len + 2);
           }

           if(!dest->data) {
              return PR_FALSE;
           }
       }
       dest->len += 2;
       dest->data[dest->len-1] = dest->data[dest->len-2] = 0;
    }

    return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12Baggage* sec_pkcs12_create_baggage ( PRArenaPool poolp)

Definition at line 209 of file p12creat.c.

{
    SEC_PKCS12Baggage *luggage;
    void *mark;

    if(poolp == NULL)
       return NULL;

    mark = PORT_ArenaMark(poolp);

    /* allocate bag */
    luggage = (SEC_PKCS12Baggage *)PORT_ArenaZAlloc(poolp, 
       sizeof(SEC_PKCS12Baggage));
    if(luggage == NULL)
    {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_ArenaRelease(poolp, mark);
       return NULL;
    }

    /* init list */
    luggage->bags = (SEC_PKCS12BaggageItem **)PORT_ArenaZAlloc(poolp,
                                   sizeof(SEC_PKCS12BaggageItem *));
    if(luggage->bags == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_ArenaRelease(poolp, mark);
       return NULL;
    }

    luggage->bags[0] = NULL;
    luggage->luggage_size = 0;
    luggage->poolp = poolp;

    PORT_ArenaUnmark(poolp, mark);
    return luggage;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12BaggageItem* sec_pkcs12_create_external_bag ( SEC_PKCS12Baggage *  luggage)

Definition at line 142 of file p12creat.c.

{
    void *dummy, *mark;
    SEC_PKCS12BaggageItem *bag;

    if(luggage == NULL) {
       return NULL;
    }

    mark = PORT_ArenaMark(luggage->poolp);

    /* allocate space for null terminated bag list */
    if(luggage->bags == NULL) {
       luggage->bags=(SEC_PKCS12BaggageItem**)PORT_ArenaZAlloc(luggage->poolp, 
                                   sizeof(SEC_PKCS12BaggageItem *));
       if(luggage->bags == NULL) {
           goto loser;
       }
       luggage->luggage_size = 0;
    }

    /* grow the list */    
    dummy = PORT_ArenaGrow(luggage->poolp, luggage->bags,
                     sizeof(SEC_PKCS12BaggageItem *) * (luggage->luggage_size + 1),
                     sizeof(SEC_PKCS12BaggageItem *) * (luggage->luggage_size + 2));
    if(dummy == NULL) {
       goto loser;
    }
    luggage->bags = (SEC_PKCS12BaggageItem**)dummy;

    luggage->bags[luggage->luggage_size] = 
              (SEC_PKCS12BaggageItem *)PORT_ArenaZAlloc(luggage->poolp,
                                                 sizeof(SEC_PKCS12BaggageItem));
    if(luggage->bags[luggage->luggage_size] == NULL) {
       goto loser;
    }

    /* create new bag and append it to the end */
    bag = luggage->bags[luggage->luggage_size];
    bag->espvks = (SEC_PKCS12ESPVKItem **)PORT_ArenaZAlloc(
                                          luggage->poolp,
                                          sizeof(SEC_PKCS12ESPVKItem *));
    bag->unencSecrets = (SEC_PKCS12SafeBag **)PORT_ArenaZAlloc(
                                          luggage->poolp,
                                          sizeof(SEC_PKCS12SafeBag *));
    if((bag->espvks == NULL) || (bag->unencSecrets == NULL)) {
       goto loser;
    }

    bag->poolp = luggage->poolp;
    luggage->luggage_size++;
    luggage->bags[luggage->luggage_size] = NULL;
    bag->espvks[0] = NULL;
    bag->unencSecrets[0] = NULL;
    bag->nEspvks = bag->nSecrets = 0;

    PORT_ArenaUnmark(luggage->poolp, mark);
    return bag;

loser:
    PORT_ArenaRelease(luggage->poolp, mark);
    PORT_SetError(SEC_ERROR_NO_MEMORY);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12SafeContents* sec_pkcs12_create_safe_contents ( PRArenaPool poolp)

Definition at line 103 of file p12creat.c.

{
    SEC_PKCS12SafeContents *safe;
    void *mark;

    if(poolp == NULL)
       return NULL;

    /* allocate structure */
    mark = PORT_ArenaMark(poolp);
    safe = (SEC_PKCS12SafeContents *)PORT_ArenaZAlloc(poolp, 
       sizeof(SEC_PKCS12SafeContents));
    if(safe == NULL)
    {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_ArenaRelease(poolp, mark);
       return NULL;
    }

    /* init list */
    safe->contents = (SEC_PKCS12SafeBag**)PORT_ArenaZAlloc(poolp, 
                                            sizeof(SEC_PKCS12SafeBag *));
    if(safe->contents == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_ArenaRelease(poolp, mark);
       return NULL;
    }
    safe->contents[0] = NULL;
    safe->poolp       = poolp;
    safe->safe_size   = 0;
    PORT_ArenaUnmark(poolp, mark);
    return safe;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECItem* sec_pkcs12_create_virtual_password ( SECItem *  password,
SECItem *  salt,
PRBool  swapUnicodeBytes 
)

Definition at line 554 of file p12local.c.

{
    SECItem uniPwd = {siBuffer, NULL,0}, *retPwd = NULL;

    if((password == NULL) || (salt == NULL)) {
       return NULL;
    }

    if(password->len == 0) {
       uniPwd.data = (unsigned char*)PORT_ZAlloc(2);
       uniPwd.len = 2;
       if(!uniPwd.data) {
           return NULL;
       }
    } else {
       uniPwd.data = (unsigned char*)PORT_ZAlloc(password->len * 3);
       uniPwd.len = password->len * 3;
       if(!PORT_UCS2_ASCIIConversion(PR_TRUE, password->data, password->len,
                            uniPwd.data, uniPwd.len, &uniPwd.len, swap)) {
           SECITEM_ZfreeItem(&uniPwd, PR_FALSE);
           return NULL;
       }
    }

    retPwd = (SECItem *)PORT_ZAlloc(sizeof(SECItem));
    if(retPwd == NULL) {
       goto loser;
    }

    /* allocate space and copy proper data */
    retPwd->len = uniPwd.len + salt->len;
    retPwd->data = (unsigned char *)PORT_Alloc(retPwd->len);
    if(retPwd->data == NULL) {
       PORT_Free(retPwd);
       goto loser;
    }

    PORT_Memcpy(retPwd->data, salt->data, salt->len);
    PORT_Memcpy((retPwd->data + salt->len), uniPwd.data, uniPwd.len);

    SECITEM_ZfreeItem(&uniPwd, PR_FALSE);

    return retPwd;

loser:
    PORT_SetError(SEC_ERROR_NO_MEMORY);
    SECITEM_ZfreeItem(&uniPwd, PR_FALSE);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* sec_pkcs12_find_object ( SEC_PKCS12SafeContents *  safe,
SEC_PKCS12Baggage *  baggage,
SECOidTag  objType,
SECItem *  nickname,
SGNDigestInfo *  thumbprint 
)

Definition at line 861 of file p12local.c.

{
    int i, j;
    void *retItem;
   
    if(((safe == NULL) && (thumbprint == NULL)) ||
       ((nickname == NULL) && (thumbprint == NULL))) {
       return NULL;
    }    

    i = 0;
    if((safe != NULL) && (safe->contents != NULL)) {
       while(safe->contents[i] != NULL) {
           SECOidTag bagType = SECOID_FindOIDTag(&safe->contents[i]->safeBagType);
           retItem = sec_pkcs12_try_find(safe, NULL, objType, bagType, i,
                                     nickname, thumbprint);
           if(retItem != NULL) {
              return retItem;
           }
           i++;
       }
    }

    if((baggage != NULL) && (baggage->bags != NULL)) {
       i = 0;
       while(baggage->bags[i] != NULL) {
           SEC_PKCS12BaggageItem *xbag = baggage->bags[i];
           j = 0;
           if(xbag->unencSecrets != NULL) {
              while(xbag->unencSecrets[j] != NULL) {
                  SECOidTag bagType;
                  bagType = SECOID_FindOIDTag(&xbag->unencSecrets[j]->safeBagType);
                  retItem = sec_pkcs12_try_find(NULL, xbag, objType, bagType,
                                            j, nickname, thumbprint);
                  if(retItem != NULL) {
                     return retItem;
                  }
                  j++;
              }
           }
           i++;
       }
    }

    PORT_SetError(SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECItem* sec_pkcs12_generate_key_from_password ( SECOidTag  algorithm,
SECItem *  salt,
SECItem *  password 
)

Definition at line 279 of file p12local.c.

{
    unsigned char *pre_hash=NULL;
    unsigned char *hash_dest=NULL;
    SECStatus res;
    PRArenaPool *poolp;
    SECItem *key = NULL;
    int key_len = 0;

    if((salt == NULL) || (password == NULL)) {
       return NULL;
    }

    poolp = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
    if(poolp == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       return NULL;
    }

    pre_hash = (unsigned char *)PORT_ArenaZAlloc(poolp, sizeof(char) * 
                                           (salt->len+password->len));
    if(pre_hash == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       goto loser;
    }

    hash_dest = (unsigned char *)PORT_ArenaZAlloc(poolp, 
                                   sizeof(unsigned char) * SHA1_LENGTH);
    if(hash_dest == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       goto loser;
    }

    PORT_Memcpy(pre_hash, salt->data, salt->len);
    /* handle password of 0 length case */
    if(password->len > 0) {
       PORT_Memcpy(&(pre_hash[salt->len]), password->data, password->len);
    }

    res = PK11_HashBuf(SEC_OID_SHA1, hash_dest, pre_hash, 
                       (salt->len+password->len));
    if(res == SECFailure) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       goto loser;
    }

    switch(algorithm) {
       case SEC_OID_SHA1:
           if(key_len == 0)
              key_len = 16;
           key = (SECItem *)PORT_ZAlloc(sizeof(SECItem));
           if(key == NULL) {
              PORT_SetError(SEC_ERROR_NO_MEMORY);
              goto loser;
           }
           key->data = (unsigned char *)PORT_ZAlloc(sizeof(unsigned char) 
                                               * key_len);
           if(key->data == NULL) {
              PORT_SetError(SEC_ERROR_NO_MEMORY);
              goto loser;
           }
           key->len = key_len;
           PORT_Memcpy(key->data, &hash_dest[SHA1_LENGTH-key->len], key->len);
           break;
       default:
           goto loser;
           break;
    }

    PORT_FreeArena(poolp, PR_TRUE);
    return key;

loser:
    PORT_FreeArena(poolp, PR_TRUE);
    if(key != NULL) {
       SECITEM_ZfreeItem(key, PR_TRUE);
    }
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECItem* sec_pkcs12_generate_mac ( SECItem *  key,
SECItem *  msg,
PRBool  old_method 
)

Definition at line 446 of file p12local.c.

{
    SECStatus res = SECFailure;
    SECItem *mac = NULL;
    PK11Context *pk11cx = NULL;    
    SECItem ignore = {0};

    if((key == NULL) || (msg == NULL)) {
       return NULL;
    }

    if(old_method == PR_TRUE) {
       return sec_pkcs12_generate_old_mac(key, msg);
    }

    /* allocate return item */
    mac = SECITEM_AllocItem(NULL, NULL, SHA1_LENGTH);
    if (mac == NULL) {
       return NULL;
    }

    pk11cx = PK11_CreateContextByRawKey(NULL, CKM_SHA_1_HMAC, PK11_OriginDerive,
                                        CKA_SIGN, key, &ignore, NULL);
    if (pk11cx == NULL) {
       goto loser;
    }

    res = PK11_DigestBegin(pk11cx);
    if (res == SECFailure) {
       goto loser;
    }

    res = PK11_DigestOp(pk11cx, msg->data, msg->len);
    if (res == SECFailure) {
       goto loser;
    }

    res = PK11_DigestFinal(pk11cx, mac->data, &mac->len, SHA1_LENGTH);
    if (res == SECFailure) {
       goto loser;
    }

    PK11_DestroyContext(pk11cx, PR_TRUE);
    pk11cx = NULL;

loser:

    if(res != SECSuccess) {
       SECITEM_ZfreeItem(mac, PR_TRUE);
       mac = NULL;
       if (pk11cx) {
           PK11_DestroyContext(pk11cx, PR_TRUE);
       }
    }

    return mac;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 252 of file p12local.c.

{
    SECItem *salt;

    salt = (SECItem *)PORT_ZAlloc(sizeof(SECItem));
    if(salt == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       return NULL;
    }
    salt->data = (unsigned char *)PORT_ZAlloc(sizeof(unsigned char) * 
                                         SALT_LENGTH);
    salt->len = SALT_LENGTH;
    if(salt->data == NULL) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       SECITEM_ZfreeItem(salt, PR_TRUE);
       return NULL;
    }

    PK11_GenerateRandom(salt->data, salt->len);

    return salt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12AuthenticatedSafe* sec_pkcs12_new_asafe ( PRArenaPool poolp)

Definition at line 78 of file p12creat.c.

{
    SEC_PKCS12AuthenticatedSafe  *asafe = NULL;
    void *mark;

    mark = PORT_ArenaMark(poolp);
    asafe = (SEC_PKCS12AuthenticatedSafe *)PORT_ArenaZAlloc(poolp, 
       sizeof(SEC_PKCS12AuthenticatedSafe));
    if(asafe == NULL)
       goto loser;
    asafe->poolp = poolp;
    PORT_Memset(&asafe->old_baggage, 0, sizeof(SEC_PKCS7ContentInfo));

    PORT_ArenaUnmark(poolp, mark);
    return asafe;

loser:
    PORT_ArenaRelease(poolp, mark);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12PFXItem* sec_pkcs12_new_pfx ( void  )

Definition at line 51 of file p12creat.c.

{
    SEC_PKCS12PFXItem   *pfx = NULL;
    PRArenaPool     *poolp = NULL;

    poolp = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); /* XXX Different size? */
    if(poolp == NULL)
       goto loser;

    pfx = (SEC_PKCS12PFXItem *)PORT_ArenaZAlloc(poolp, 
       sizeof(SEC_PKCS12PFXItem));
    if(pfx == NULL)
       goto loser;
    pfx->poolp = poolp;

    return pfx;

loser:
    PORT_FreeArena(poolp, PR_TRUE);
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SEC_PKCS12DecoderContext* sec_PKCS12ConvertOldSafeToNew ( PRArenaPool arena,
PK11SlotInfo *  slot,
PRBool  swapUnicode,
SECItem *  pwitem,
void wincx,
SEC_PKCS12SafeContents *  safe,
SEC_PKCS12Baggage *  baggage 
)

Definition at line 3437 of file p12d.c.

{
    SEC_PKCS12DecoderContext *p12dcx;

    if(!arena || !slot || !pwitem) {
       return NULL;
    }

    if(!safe && !baggage) {
       return NULL;
    }

    p12dcx = (SEC_PKCS12DecoderContext *)PORT_ArenaZAlloc(arena, 
                                       sizeof(SEC_PKCS12DecoderContext));
    if(!p12dcx) {
       return NULL;
    }

    p12dcx->arena = arena;
    p12dcx->slot = PK11_ReferenceSlot(slot);
    p12dcx->wincx = wincx;
    p12dcx->error = PR_FALSE;
    p12dcx->swapUnicodeBytes = swapUnicode; 
    p12dcx->pwitem = pwitem;
    p12dcx->tokenCAs = SECPKCS12TargetTokenNoCAs;
    
    if(sec_pkcs12_decoder_convert_old_safe_to_bags(p12dcx, safe, baggage) 
                            != SECSuccess) {
       p12dcx->error = PR_TRUE;
       return NULL;
    }

    return p12dcx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SEC_PKCS12DestroyPFX ( SEC_PKCS12PFXItem *  pfx)

Definition at line 248 of file p12creat.c.

{
    if (pfx != NULL && pfx->poolp != NULL)
    {
       PORT_FreeArena(pfx->poolp, PR_TRUE);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: