Ejemplo n.º 1
0
 /*
 * FUNCTION: pkix_pl_OID_Comparator
 * (see comments for PKIX_PL_ComparatorCallback in pkix_pl_system.h)
 */
static PKIX_Error *
pkix_pl_OID_Comparator(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pRes,
        void *plContext)
{
        PKIX_PL_OID *firstOID = NULL;
        PKIX_PL_OID *secondOID = NULL;

        PKIX_ENTER(OID, "pkix_pl_OID_Comparator");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pRes);

        PKIX_CHECK(pkix_CheckTypes
                    (firstObject, secondObject, PKIX_OID_TYPE, plContext),
                    PKIX_ARGUMENTSNOTOIDS);

        firstOID = (PKIX_PL_OID*)firstObject;
        secondOID = (PKIX_PL_OID*)secondObject;

        *pRes = (PKIX_Int32)SECITEM_CompareItem(&firstOID->derOid,
                                                &secondOID->derOid);
cleanup:
        PKIX_RETURN(OID);
}
Ejemplo n.º 2
0
/*
 * FUNCTION: pkix_pl_Date_Comparator
 * (see comments for PKIX_PL_ComparatorCallback in pkix_pl_system.h)
 */
static PKIX_Error *
pkix_pl_Date_Comparator(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pResult,
        void *plContext)
{
        PRTime firstTime;
        PRTime secondTime;
        SECComparison cmpResult;

        PKIX_ENTER(DATE, "pkix_pl_Date_Comparator");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult);

        PKIX_CHECK(pkix_CheckTypes
                    (firstObject, secondObject, PKIX_DATE_TYPE, plContext),
                    PKIX_ARGUMENTSNOTDATES);

        firstTime = ((PKIX_PL_Date *)firstObject)->nssTime;
        secondTime = ((PKIX_PL_Date *)secondObject)->nssTime;

        if (firstTime == secondTime)
            cmpResult = SECEqual;
        else if (firstTime < secondTime)
            cmpResult = SECLessThan;
        else
            cmpResult = SECGreaterThan;

        *pResult = cmpResult;

cleanup:

        PKIX_RETURN(DATE);
}
Ejemplo n.º 3
0
/*
 * FUNCTION: pkix_pl_Date_Comparator
 * (see comments for PKIX_PL_ComparatorCallback in pkix_pl_system.h)
 */
static PKIX_Error *
pkix_pl_Date_Comparator(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pResult,
        void *plContext)
{
        SECItem *firstTime = NULL;
        SECItem *secondTime = NULL;
        SECComparison cmpResult;

        PKIX_ENTER(DATE, "pkix_pl_Date_Comparator");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult);

        PKIX_CHECK(pkix_CheckTypes
                    (firstObject, secondObject, PKIX_DATE_TYPE, plContext),
                    PKIX_ARGUMENTSNOTDATES);

        firstTime = &((PKIX_PL_Date *)firstObject)->nssTime;
        secondTime = &((PKIX_PL_Date *)secondObject)->nssTime;

        PKIX_DATE_DEBUG("\t\tCalling SECITEM_CompareItem).\n");
        cmpResult = SECITEM_CompareItem(firstTime, secondTime);

        *pResult = cmpResult;

cleanup:

        PKIX_RETURN(DATE);
}
Ejemplo n.º 4
0
/*
 * FUNCTION: pkix_pl_ByteArray_Comparator
 * (see comments for PKIX_PL_ComparatorCallback in pkix_pl_system.h)
 *
 *  NOTE:
 *  It is not clear that this definition of comparing byte arrays makes
 *  sense. It does allow you to tell whether two blocks of memory are
 *  identical, so we only use it for the Equals function (i.e. we don't
 *  register it as a Compare function for ByteArray).
 */
static PKIX_Error *
pkix_pl_ByteArray_Comparator(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pResult,
        void *plContext)
{
        PKIX_PL_ByteArray *firstByteArray = NULL;
        PKIX_PL_ByteArray *secondByteArray = NULL;
        unsigned char *firstData = NULL;
        unsigned char *secondData = NULL;
        PKIX_UInt32 i;

        PKIX_ENTER(BYTEARRAY, "pkix_pl_ByteArray_Comparator");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult);

        PKIX_CHECK(pkix_CheckTypes
                (firstObject, secondObject, PKIX_BYTEARRAY_TYPE, plContext),
                PKIX_ARGUMENTSNOTBYTEARRAYS);

        /* It's safe to cast */
        firstByteArray = (PKIX_PL_ByteArray *)firstObject;
        secondByteArray = (PKIX_PL_ByteArray *)secondObject;

        *pResult = 0;
        firstData = (unsigned char *)firstByteArray->array;
        secondData = (unsigned char *)secondByteArray->array;

        if (firstByteArray->length < secondByteArray->length) {
                *pResult = -1;
        } else if (firstByteArray->length > secondByteArray->length) {
                *pResult = 1;
        } else if (firstByteArray->length == secondByteArray->length) {
                /* Check if both array contents are identical */
                for (i = 0;
                    (i < firstByteArray->length) && (*pResult == 0);
                    i++) {
                        if (firstData[i] < secondData[i]) {
                                *pResult = -1;
                        } else if (firstData[i] > secondData[i]) {
                                *pResult = 1;
                        }
                }
        }

cleanup:

        PKIX_RETURN(BYTEARRAY);
}
Ejemplo n.º 5
0
/*
 * FUNCTION: pkix_pl_CollectionCertStoreContext_Equals
 * (see comments for PKIX_PL_EqualsCallback in pkix_pl_system.h)
 */
static PKIX_Error *
pkix_pl_CollectionCertStoreContext_Equals(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pResult,
        void *plContext)
{
        PKIX_PL_CollectionCertStoreContext *firstCCSContext = NULL;
        PKIX_PL_CollectionCertStoreContext *secondCCSContext = NULL;
        PKIX_Boolean cmpResult = 0;

        PKIX_ENTER(COLLECTIONCERTSTORECONTEXT,
                    "pkix_pl_CollectionCertStoreContext_Equals");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult);

        PKIX_CHECK(pkix_CheckTypes
                    (firstObject,
                    secondObject,
                    PKIX_COLLECTIONCERTSTORECONTEXT_TYPE,
                    plContext),
                    PKIX_OBJECTNOTCOLLECTIONCERTSTORECONTEXT);

        firstCCSContext = (PKIX_PL_CollectionCertStoreContext *)firstObject;
        secondCCSContext = (PKIX_PL_CollectionCertStoreContext *)secondObject;

        if (firstCCSContext->storeDir == secondCCSContext->storeDir) {

                cmpResult = PKIX_TRUE;

        } else {

                PKIX_CHECK(PKIX_PL_Object_Equals
                    ((PKIX_PL_Object *) firstCCSContext->storeDir,
                    (PKIX_PL_Object *) secondCCSContext->storeDir,
                    &cmpResult,
                    plContext),
                    PKIX_STRINGEQUALSFAILED);
        }

        *pResult = cmpResult;

        /* should not check equal on crlList and certList, data are dynamic */

cleanup:
        PKIX_RETURN(COLLECTIONCERTSTORECONTEXT);
}
Ejemplo n.º 6
0
/*
 * FUNCTION: pkix_CertStore_Equals
 * (see comments for PKIX_PL_EqualsCallback in pkix_pl_system.h)
 */
static PKIX_Error *
pkix_CertStore_Equals(
        PKIX_PL_Object *firstObject,
        PKIX_PL_Object *secondObject,
        PKIX_Int32 *pResult,
        void *plContext)
{
        PKIX_CertStore *firstCS = NULL;
        PKIX_CertStore *secondCS = NULL;
        PKIX_Boolean cmpResult = PKIX_FALSE;

        PKIX_ENTER(CERTSTORE, "pkix_CertStore_Equals");
        PKIX_NULLCHECK_THREE(firstObject, secondObject, pResult);

        PKIX_CHECK(pkix_CheckTypes
                    (firstObject, secondObject, PKIX_CERTSTORE_TYPE, plContext),
                    PKIX_ARGUMENTSNOTDATES);

        firstCS = (PKIX_CertStore *)firstObject;
        secondCS = (PKIX_CertStore *)secondObject;

        cmpResult = (firstCS->certCallback == secondCS->certCallback) &&
            (firstCS->crlCallback == secondCS->crlCallback) &&
            (firstCS->certContinue == secondCS->certContinue) &&
            (firstCS->crlContinue == secondCS->crlContinue) &&
            (firstCS->trustCallback == secondCS->trustCallback);

        if (cmpResult &&
            (firstCS->certStoreContext != secondCS->certStoreContext)) {

                PKIX_CHECK(PKIX_PL_Object_Equals
                    ((PKIX_PL_Object *) firstCS->certStoreContext,
                    (PKIX_PL_Object *) secondCS->certStoreContext,
                    &cmpResult,
                    plContext),
                    PKIX_CERTSTOREEQUALSFAILED);
        }

        *pResult = cmpResult;

cleanup:

        PKIX_RETURN(CERTSTORE);
}