summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/libpkix/pkix/store
diff options
context:
space:
mode:
Diffstat (limited to 'security/nss/lib/libpkix/pkix/store')
-rwxr-xr-xsecurity/nss/lib/libpkix/pkix/store/Makefile48
-rwxr-xr-xsecurity/nss/lib/libpkix/pkix/store/config.mk15
-rw-r--r--security/nss/lib/libpkix/pkix/store/exports.gyp25
-rwxr-xr-xsecurity/nss/lib/libpkix/pkix/store/manifest.mn21
-rwxr-xr-xsecurity/nss/lib/libpkix/pkix/store/pkix_store.c415
-rwxr-xr-xsecurity/nss/lib/libpkix/pkix/store/pkix_store.h41
-rw-r--r--security/nss/lib/libpkix/pkix/store/store.gyp23
7 files changed, 588 insertions, 0 deletions
diff --git a/security/nss/lib/libpkix/pkix/store/Makefile b/security/nss/lib/libpkix/pkix/store/Makefile
new file mode 100755
index 000000000..36524f56a
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/Makefile
@@ -0,0 +1,48 @@
+#! gmake
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#######################################################################
+# (1) Include initial platform-independent assignments (MANDATORY). #
+#######################################################################
+
+include manifest.mn
+
+#######################################################################
+# (2) Include "global" configuration information. (OPTIONAL) #
+#######################################################################
+
+include $(CORE_DEPTH)/coreconf/config.mk
+
+#######################################################################
+# (3) Include "component" configuration information. (OPTIONAL) #
+#######################################################################
+
+
+
+#######################################################################
+# (4) Include "local" platform-dependent assignments (OPTIONAL). #
+#######################################################################
+
+include config.mk
+
+#######################################################################
+# (5) Execute "global" rules. (OPTIONAL) #
+#######################################################################
+
+include $(CORE_DEPTH)/coreconf/rules.mk
+
+#######################################################################
+# (6) Execute "component" rules. (OPTIONAL) #
+#######################################################################
+
+
+
+#######################################################################
+# (7) Execute "local" rules. (OPTIONAL). #
+#######################################################################
+
+export:: private_export
+
diff --git a/security/nss/lib/libpkix/pkix/store/config.mk b/security/nss/lib/libpkix/pkix/store/config.mk
new file mode 100755
index 000000000..b8c03de79
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/config.mk
@@ -0,0 +1,15 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#
+# Override TARGETS variable so that only static libraries
+# are specifed as dependencies within rules.mk.
+#
+
+TARGETS = $(LIBRARY)
+SHARED_LIBRARY =
+IMPORT_LIBRARY =
+PROGRAM =
+
diff --git a/security/nss/lib/libpkix/pkix/store/exports.gyp b/security/nss/lib/libpkix/pkix/store/exports.gyp
new file mode 100644
index 000000000..52f13f5ae
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/exports.gyp
@@ -0,0 +1,25 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+{
+ 'includes': [
+ '../../../../coreconf/config.gypi'
+ ],
+ 'targets': [
+ {
+ 'target_name': 'lib_libpkix_pkix_store_exports',
+ 'type': 'none',
+ 'copies': [
+ {
+ 'files': [
+ 'pkix_store.h'
+ ],
+ 'destination': '<(nss_private_dist_dir)/<(module)'
+ }
+ ]
+ }
+ ],
+ 'variables': {
+ 'module': 'nss'
+ }
+}
diff --git a/security/nss/lib/libpkix/pkix/store/manifest.mn b/security/nss/lib/libpkix/pkix/store/manifest.mn
new file mode 100755
index 000000000..4df8eb64b
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/manifest.mn
@@ -0,0 +1,21 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+CORE_DEPTH = ../../../..
+
+EXPORTS = \
+ $(NULL)
+
+PRIVATE_EXPORTS = \
+ pkix_store.h \
+ $(NULL)
+
+MODULE = nss
+
+CSRCS = \
+ pkix_store.c \
+ $(NULL)
+
+LIBRARY_NAME = pkixstore
+
diff --git a/security/nss/lib/libpkix/pkix/store/pkix_store.c b/security/nss/lib/libpkix/pkix/store/pkix_store.c
new file mode 100755
index 000000000..af8be2bb2
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/pkix_store.c
@@ -0,0 +1,415 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/*
+ * pkix_store.c
+ *
+ * CertStore Function Definitions
+ *
+ */
+
+#include "pkix_store.h"
+
+/* --CertStore-Private-Functions----------------------------------------- */
+
+/*
+ * FUNCTION: pkix_CertStore_Destroy
+ * (see comments for PKIX_PL_DestructorCallback in pkix_pl_system.h)
+ */
+static PKIX_Error *
+pkix_CertStore_Destroy(
+ PKIX_PL_Object *object,
+ void *plContext)
+{
+ PKIX_CertStore *certStore = NULL;
+
+ PKIX_ENTER(CERTSTORE, "pkix_CertStore_Destroy");
+ PKIX_NULLCHECK_ONE(object);
+
+ /* Check that this object is a CertStore object */
+ PKIX_CHECK(pkix_CheckType(object, PKIX_CERTSTORE_TYPE, plContext),
+ PKIX_OBJECTNOTCERTSTORE);
+
+ certStore = (PKIX_CertStore *)object;
+
+ certStore->certCallback = NULL;
+ certStore->crlCallback = NULL;
+ certStore->certContinue = NULL;
+ certStore->crlContinue = NULL;
+ certStore->trustCallback = NULL;
+
+ PKIX_DECREF(certStore->certStoreContext);
+
+cleanup:
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: pkix_CertStore_Hashcode
+ * (see comments for PKIX_PL_HashcodeCallback in pkix_pl_system.h)
+ */
+static PKIX_Error *
+pkix_CertStore_Hashcode(
+ PKIX_PL_Object *object,
+ PKIX_UInt32 *pHashcode,
+ void *plContext)
+{
+ PKIX_CertStore *certStore = NULL;
+ PKIX_UInt32 tempHash = 0;
+
+ PKIX_ENTER(CERTSTORE, "pkix_CertStore_Hashcode");
+ PKIX_NULLCHECK_TWO(object, pHashcode);
+
+ PKIX_CHECK(pkix_CheckType(object, PKIX_CERTSTORE_TYPE, plContext),
+ PKIX_OBJECTNOTCERTSTORE);
+
+ certStore = (PKIX_CertStore *)object;
+
+ if (certStore->certStoreContext) {
+ PKIX_CHECK(PKIX_PL_Object_Hashcode
+ ((PKIX_PL_Object *) certStore->certStoreContext,
+ &tempHash,
+ plContext),
+ PKIX_CERTSTOREHASHCODEFAILED);
+ }
+
+ *pHashcode = (PKIX_UInt32)((char *)certStore->certCallback - (char *)NULL) +
+ (PKIX_UInt32)((char *)certStore->crlCallback - (char *)NULL) +
+ (PKIX_UInt32)((char *)certStore->certContinue - (char *)NULL) +
+ (PKIX_UInt32)((char *)certStore->crlContinue - (char *)NULL) +
+ (PKIX_UInt32)((char *)certStore->trustCallback - (char *)NULL) +
+ (tempHash << 7);
+
+cleanup:
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * 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);
+}
+
+/*
+ * FUNCTION: pkix_CertStore_RegisterSelf
+ * DESCRIPTION:
+ * Registers PKIX_CERTSTORE_TYPE and its related functions with
+ * systemClasses[]
+ * THREAD SAFETY:
+ * Not Thread Safe - for performance and complexity reasons
+ *
+ * Since this function is only called by PKIX_PL_Initialize, which should
+ * only be called once, it is acceptable that this function is not
+ * thread-safe.
+ */
+PKIX_Error *
+pkix_CertStore_RegisterSelf(void *plContext)
+{
+ extern pkix_ClassTable_Entry systemClasses[PKIX_NUMTYPES];
+ pkix_ClassTable_Entry entry;
+
+ PKIX_ENTER(CERTSTORE, "pkix_CertStore_RegisterSelf");
+
+ entry.description = "CertStore";
+ entry.objCounter = 0;
+ entry.typeObjectSize = sizeof(PKIX_CertStore);
+ entry.destructor = pkix_CertStore_Destroy;
+ entry.equalsFunction = pkix_CertStore_Equals;
+ entry.hashcodeFunction = pkix_CertStore_Hashcode;
+ entry.toStringFunction = NULL;
+ entry.comparator = NULL;
+ entry.duplicateFunction = pkix_duplicateImmutable;
+
+ systemClasses[PKIX_CERTSTORE_TYPE] = entry;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/* --CertStore-Public-Functions------------------------------------------ */
+
+/*
+ * FUNCTION: PKIX_CertStore_Create (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_Create(
+ PKIX_CertStore_CertCallback certCallback,
+ PKIX_CertStore_CRLCallback crlCallback,
+ PKIX_CertStore_CertContinueFunction certContinue,
+ PKIX_CertStore_CrlContinueFunction crlContinue,
+ PKIX_CertStore_CheckTrustCallback trustCallback,
+ PKIX_CertStore_ImportCrlCallback importCrlCallback,
+ PKIX_CertStore_CheckRevokationByCrlCallback checkRevByCrlCallback,
+ PKIX_PL_Object *certStoreContext,
+ PKIX_Boolean cacheFlag,
+ PKIX_Boolean localFlag,
+ PKIX_CertStore **pStore,
+ void *plContext)
+{
+ PKIX_CertStore *certStore = NULL;
+
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_Create");
+ PKIX_NULLCHECK_THREE(certCallback, crlCallback, pStore);
+
+ PKIX_CHECK(PKIX_PL_Object_Alloc
+ (PKIX_CERTSTORE_TYPE,
+ sizeof (PKIX_CertStore),
+ (PKIX_PL_Object **)&certStore,
+ plContext),
+ PKIX_COULDNOTCREATECERTSTOREOBJECT);
+
+ certStore->certCallback = certCallback;
+ certStore->crlCallback = crlCallback;
+ certStore->certContinue = certContinue;
+ certStore->crlContinue = crlContinue;
+ certStore->trustCallback = trustCallback;
+ certStore->importCrlCallback = importCrlCallback;
+ certStore->checkRevByCrlCallback = checkRevByCrlCallback;
+ certStore->cacheFlag = cacheFlag;
+ certStore->localFlag = localFlag;
+
+ PKIX_INCREF(certStoreContext);
+ certStore->certStoreContext = certStoreContext;
+
+ *pStore = certStore;
+ certStore = NULL;
+
+cleanup:
+
+ PKIX_DECREF(certStore);
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetCertCallback (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetCertCallback(
+ PKIX_CertStore *store,
+ PKIX_CertStore_CertCallback *pCallback,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetCertCallback");
+ PKIX_NULLCHECK_TWO(store, pCallback);
+
+ *pCallback = store->certCallback;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetCRLCallback (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetCRLCallback(
+ PKIX_CertStore *store,
+ PKIX_CertStore_CRLCallback *pCallback,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetCRLCallback");
+ PKIX_NULLCHECK_TWO(store, pCallback);
+
+ *pCallback = store->crlCallback;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_CertContinue (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_CertContinue(
+ PKIX_CertStore *store,
+ PKIX_CertSelector *selector,
+ PKIX_VerifyNode *verifyNode,
+ void **pNBIOContext,
+ PKIX_List **pCertList,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_CertContinue");
+ PKIX_NULLCHECK_FOUR(store, selector, pNBIOContext, pCertList);
+
+ PKIX_CHECK(store->certContinue
+ (store, selector, verifyNode,
+ pNBIOContext, pCertList, plContext),
+ PKIX_CERTSTORECERTCONTINUEFUNCTIONFAILED);
+
+cleanup:
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_CrlContinue (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_CrlContinue(
+ PKIX_CertStore *store,
+ PKIX_CRLSelector *selector,
+ void **pNBIOContext,
+ PKIX_List **pCrlList,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_CrlContinue");
+ PKIX_NULLCHECK_FOUR(store, selector, pNBIOContext, pCrlList);
+
+ PKIX_CHECK(store->crlContinue
+ (store, selector, pNBIOContext, pCrlList, plContext),
+ PKIX_CERTSTORECRLCONTINUEFAILED);
+
+cleanup:
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetTrustCallback (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetTrustCallback(
+ PKIX_CertStore *store,
+ PKIX_CertStore_CheckTrustCallback *pCallback,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetTrustCallback");
+ PKIX_NULLCHECK_TWO(store, pCallback);
+
+ *pCallback = store->trustCallback;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetImportCrlCallback (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetImportCrlCallback(
+ PKIX_CertStore *store,
+ PKIX_CertStore_ImportCrlCallback *pCallback,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetTrustCallback");
+ PKIX_NULLCHECK_TWO(store, pCallback);
+
+ *pCallback = store->importCrlCallback;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetCheckRevByCrl (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetCrlCheckerFn(
+ PKIX_CertStore *store,
+ PKIX_CertStore_CheckRevokationByCrlCallback *pCallback,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetTrustCallback");
+ PKIX_NULLCHECK_TWO(store, pCallback);
+
+ *pCallback = store->checkRevByCrlCallback;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetCertStoreContext
+ * (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetCertStoreContext(
+ PKIX_CertStore *store,
+ PKIX_PL_Object **pCertStoreContext,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetCertStoreContext");
+ PKIX_NULLCHECK_TWO(store, pCertStoreContext);
+
+ PKIX_INCREF(store->certStoreContext);
+ *pCertStoreContext = store->certStoreContext;
+
+cleanup:
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetCertStoreCacheFlag
+ * (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetCertStoreCacheFlag(
+ PKIX_CertStore *store,
+ PKIX_Boolean *pCacheFlag,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetCertStoreCacheFlag");
+ PKIX_NULLCHECK_TWO(store, pCacheFlag);
+
+ *pCacheFlag = store->cacheFlag;
+
+ PKIX_RETURN(CERTSTORE);
+}
+
+/*
+ * FUNCTION: PKIX_CertStore_GetLocalFlag
+ * (see comments in pkix_certstore.h)
+ */
+PKIX_Error *
+PKIX_CertStore_GetLocalFlag(
+ PKIX_CertStore *store,
+ PKIX_Boolean *pLocalFlag,
+ void *plContext)
+{
+ PKIX_ENTER(CERTSTORE, "PKIX_CertStore_GetLocalFlag");
+ PKIX_NULLCHECK_TWO(store, pLocalFlag);
+
+ *pLocalFlag = store->localFlag;
+
+ PKIX_RETURN(CERTSTORE);
+}
diff --git a/security/nss/lib/libpkix/pkix/store/pkix_store.h b/security/nss/lib/libpkix/pkix/store/pkix_store.h
new file mode 100755
index 000000000..9d116ffbd
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/pkix_store.h
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/*
+ * pkix_store.h
+ *
+ * CertStore Object Type Definition
+ *
+ */
+
+#ifndef _PKIX_STORE_H
+#define _PKIX_STORE_H
+
+#include "pkix_tools.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct PKIX_CertStoreStruct {
+ PKIX_CertStore_CertCallback certCallback;
+ PKIX_CertStore_CRLCallback crlCallback;
+ PKIX_CertStore_CertContinueFunction certContinue;
+ PKIX_CertStore_CrlContinueFunction crlContinue;
+ PKIX_CertStore_CheckTrustCallback trustCallback;
+ PKIX_CertStore_ImportCrlCallback importCrlCallback;
+ PKIX_CertStore_CheckRevokationByCrlCallback checkRevByCrlCallback;
+ PKIX_PL_Object *certStoreContext;
+ PKIX_Boolean cacheFlag;
+ PKIX_Boolean localFlag; /* TRUE if CertStore is local */
+};
+
+/* see source file for function documentation */
+
+PKIX_Error *pkix_CertStore_RegisterSelf(void *plContext);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PKIX_STORE_H */
diff --git a/security/nss/lib/libpkix/pkix/store/store.gyp b/security/nss/lib/libpkix/pkix/store/store.gyp
new file mode 100644
index 000000000..43aa17768
--- /dev/null
+++ b/security/nss/lib/libpkix/pkix/store/store.gyp
@@ -0,0 +1,23 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+{
+ 'includes': [
+ '../../../../coreconf/config.gypi'
+ ],
+ 'targets': [
+ {
+ 'target_name': 'pkixstore',
+ 'type': 'static_library',
+ 'sources': [
+ 'pkix_store.c'
+ ],
+ 'dependencies': [
+ '<(DEPTH)/exports.gyp:nss_exports'
+ ]
+ }
+ ],
+ 'variables': {
+ 'module': 'nss'
+ }
+} \ No newline at end of file