Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
p12plcy.c File Reference
#include "p12plcy.h"
#include "secoid.h"
#include "secport.h"
#include "secpkcs5.h"

Go to the source code of this file.

Classes

struct  pkcs12SuiteMapStr

Defines

#define PKCS12_NULL   0x0000

Typedefs

typedef struct pkcs12SuiteMapStr pkcs12SuiteMap

Functions

PRBool SEC_PKCS12DecryptionAllowed (SECAlgorithmID *algid)
PRBool SEC_PKCS12IsEncryptionAllowed (void)
SECOidTag SEC_PKCS12GetPreferredEncryptionAlgorithm (void)
SECOidTag SEC_PKCS12GetStrongestAllowedAlgorithm (void)
SECStatus SEC_PKCS12EnableCipher (long which, int on)
SECStatus SEC_PKCS12SetPreferredCipher (long which, int on)

Variables

static pkcs12SuiteMap pkcs12SuiteMaps []

Class Documentation

struct pkcs12SuiteMapStr

Definition at line 45 of file p12plcy.c.

Class Members
SECOidTag algTag
PRBool allowed
unsigned int keyLengthBits
PRBool preferred
unsigned long suite

Define Documentation

#define PKCS12_NULL   0x0000

Definition at line 43 of file p12plcy.c.


Typedef Documentation


Function Documentation

PRBool SEC_PKCS12DecryptionAllowed ( SECAlgorithmID *  algid)

Definition at line 66 of file p12plcy.c.

{
    unsigned int keyLengthBits;
    SECOidTag algId;
    int i;
   
    algId = SEC_PKCS5GetCryptoAlgorithm(algid);
    if(algId == SEC_OID_UNKNOWN) {
       return PR_FALSE;
    }
    
    keyLengthBits = (unsigned int)(SEC_PKCS5GetKeyLength(algid) * 8);

    i = 0;
    while(pkcs12SuiteMaps[i].algTag != SEC_OID_UNKNOWN) {
       if((pkcs12SuiteMaps[i].algTag == algId) && 
          (pkcs12SuiteMaps[i].keyLengthBits == keyLengthBits)) {

           return pkcs12SuiteMaps[i].allowed;
       }
       i++;
    }

    return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 155 of file p12plcy.c.

{
    int i;

    i = 0;
    while(pkcs12SuiteMaps[i].suite != 0L) {
       if(pkcs12SuiteMaps[i].suite == (unsigned long)which) {
           if(on) {
              pkcs12SuiteMaps[i].allowed = PR_TRUE;
           } else {
              pkcs12SuiteMaps[i].allowed = PR_FALSE;
           }
           return SECSuccess;
       }
       i++;
    }

    return SECFailure;
}

Here is the caller graph for this function:

Definition at line 112 of file p12plcy.c.

{
    int i;

    i = 0;
    while(pkcs12SuiteMaps[i].algTag != SEC_OID_UNKNOWN) {
       if((pkcs12SuiteMaps[i].preferred == PR_TRUE) && 
          (pkcs12SuiteMaps[i].allowed == PR_TRUE)) {
           return SEC_PKCS5GetPBEAlgorithm(pkcs12SuiteMaps[i].algTag,
                                       pkcs12SuiteMaps[i].keyLengthBits);
       }
       i++;
    }

    return SEC_OID_UNKNOWN;
}

Here is the caller graph for this function:

Definition at line 131 of file p12plcy.c.

{
    int i, keyLengthBits = 0;
    SECOidTag algorithm = SEC_OID_UNKNOWN;

    i = 0;
    while(pkcs12SuiteMaps[i].algTag != SEC_OID_UNKNOWN) {
       if((pkcs12SuiteMaps[i].allowed == PR_TRUE) && 
          (pkcs12SuiteMaps[i].keyLengthBits > (unsigned int)keyLengthBits) &&
          (pkcs12SuiteMaps[i].algTag != SEC_OID_RC4)) {
           algorithm = pkcs12SuiteMaps[i].algTag;
           keyLengthBits = pkcs12SuiteMaps[i].keyLengthBits;
       }
       i++;
    }

    if(algorithm == SEC_OID_UNKNOWN) {
       return SEC_OID_UNKNOWN;
    }

    return SEC_PKCS5GetPBEAlgorithm(algorithm, keyLengthBits);
}

Here is the caller graph for this function:

Definition at line 94 of file p12plcy.c.

{
    int i;

    i = 0;
    while(pkcs12SuiteMaps[i].algTag != SEC_OID_UNKNOWN) {
       if(pkcs12SuiteMaps[i].allowed == PR_TRUE) {
           return PR_TRUE;
       } 
       i++;
    }

    return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 176 of file p12plcy.c.

{
    int i;
    PRBool turnedOff = PR_FALSE;
    PRBool turnedOn = PR_FALSE;

    i = 0;
    while(pkcs12SuiteMaps[i].suite != 0L) {
       if(pkcs12SuiteMaps[i].preferred == PR_TRUE) {
           pkcs12SuiteMaps[i].preferred = PR_FALSE;
           turnedOff = PR_TRUE;
       }
       if(pkcs12SuiteMaps[i].suite == (unsigned long)which) {
           pkcs12SuiteMaps[i].preferred = PR_TRUE;
           turnedOn = PR_TRUE;
       }
       i++;
    }

    if((turnedOn) && (turnedOff)) {
       return SECSuccess;
    }

    return SECFailure;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:

Definition at line 53 of file p12plcy.c.