       0        0
 ?÷     /* 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/. */
#ifndef _SECMODT_H_
#define _SECMODT_H_ 1

#include "nssrwlkt.h"
#include "nssilckt.h"
#include "secoid.h"
#include "secasn1.h"
#include "pkcs11t.h"
#include "utilmodt.h"

SEC_BEGIN_PROTOS

/* find a better home for these... */
extern const SEC_ASN1Template SECKEY_PointerToEncryptedPrivateKeyInfoTemplate[];
SEC_ASN1_CHOOSER_DECLARE(SECKEY_PointerToEncryptedPrivateKeyInfoTemplate)
extern const SEC_ASN1Template SECKEY_EncryptedPrivateKeyInfoTemplate[];
SEC_ASN1_CHOOSER_DECLARE(SECKEY_EncryptedPrivateKeyInfoTemplate)
extern const SEC_ASN1Template SECKEY_PrivateKeyInfoTemplate[];
SEC_ASN1_CHOOSER_DECLARE(SECKEY_PrivateKeyInfoTemplate)
extern const SEC_ASN1Template SECKEY_PointerToPrivateKeyInfoTemplate[];
SEC_ASN1_CHOOSER_DECLARE(SECKEY_PointerToPrivateKeyInfoTemplate)

SEC_END_PROTOS

/* PKCS11 needs to be included */
typedef struct SECMODModuleStr SECMODModule;
typedef struct SECMODModuleListStr SECMODModuleList;
typedef NSSRWLock SECMODListLock;
typedef struct PK11SlotInfoStr PK11SlotInfo;          /* defined in secmodti.h */
typedef struct NSSUTILPreSlotInfoStr PK11PreSlotInfo; /* defined in secmodti.h */
typedef struct PK11SymKeyStr PK11SymKey;              /* defined in secmodti.h */
typedef struct PK11ContextStr PK11Context;            /* defined in secmodti.h */
typedef struct PK11SlotListStr PK11SlotList;
typedef struct PK11SlotListElementStr PK11SlotListElement;
typedef struct PK11RSAGenParamsStr PK11RSAGenParams;
typedef unsigned long SECMODModuleID;
typedef struct PK11DefaultArrayEntryStr PK11DefaultArrayEntry;
typedef struct PK11GenericObjectStr PK11GenericObject;
typedef void (*PK11FreeDataFunc)(void *);

struct SECMODModuleStr {
    PLArenaPool *arena;
    PRBool internal;           /* true of internally linked modules, false
                                * for the loaded modules */
    PRBool loaded;             /* Set to true if module has been loaded */
    PRBool isFIPS;             /* Set to true if module is finst internal */
    char *dllName;             /* name of the shared library which implements
                                * this module */
    char *commonName;          /* name of the module to display to the user */
    void *library;             /* pointer to the library. opaque. used only by
                                * pk11load.c */
    void *functionList;        /* The PKCS #11 function table */
    PZLock *refLock;           /* only used pk11db.c */
    int refCount;              /* Module reference count */
    PK11SlotInfo **slots;      /* array of slot points attached to this mod*/
    int slotCount;             /* count of slot in above array */
    PK11PreSlotInfo *slotInfo; /* special info about slots default settings */
    int slotInfoCount;         /* count */
    SECMODModuleID moduleID;   /* ID so we can find this module again */
    PRBool isThreadSafe;
    unsigned long ssl[2];        /* SSL cipher enable flags */
    char *libraryParams;         /* Module specific parameters */
    void *moduleDBFunc;          /* function to return module configuration data*/
    SECMODModule *parent;        /* module that loaded us */
    PRBool isCritical;           /* This module must load successfully */
    PRBool isModuleDB;           /* this module has lists of PKCS #11 modules */
    PRBool moduleDBOnly;         /* this module only has lists of PKCS #11 modules */
    int trustOrder;              /* order for this module's certificate trust rollup */
    int cipherOrder;             /* order for cipher operations */
    unsigned long evControlMask; /* control the running and shutdown of slot
                                  * events (SECMOD_WaitForAnyTokenEvent) */
    CK_VERSION cryptokiVersion;  /* version of this library */
    CK_FLAGS flags;              /* pkcs11 v3 flags */
    /* Warning this could go way in future versions of NSS
     * w