security/nss/lib/dev/devt.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef DEVT_H
     6 #define DEVT_H
     8 /*
     9  * devt.h
    10  *
    11  * This file contains definitions for the low-level cryptoki devices.
    12  */
    14 #ifndef NSSBASET_H
    15 #include "nssbaset.h"
    16 #endif /* NSSBASET_H */
    18 #ifndef NSSPKIT_H
    19 #include "nsspkit.h"
    20 #endif /* NSSPKIT_H */
    22 #ifndef NSSDEVT_H
    23 #include "nssdevt.h"
    24 #endif /* NSSDEVT_H */
    26 #ifndef BASET_H
    27 #include "baset.h"
    28 #endif /* BASET_H */
    30 #include "secmodt.h"
    32 PR_BEGIN_EXTERN_C
    34 typedef struct nssSessionStr nssSession;
    36 /* XXX until NSSTokenStr is moved */
    37 struct nssDeviceBaseStr
    38 {
    39   NSSArena *arena;
    40   PZLock *lock;
    41   PRInt32 refCount;
    42   NSSUTF8 *name;
    43   PRUint32 flags;
    44 };
    46 typedef struct nssTokenObjectCacheStr nssTokenObjectCache;
    48 /* XXX until devobject.c goes away */
    49 struct NSSTokenStr
    50 {
    51     struct nssDeviceBaseStr base;
    52     NSSSlot *slot;  /* Parent (or peer, if you will) */
    53     CK_FLAGS ckFlags; /* from CK_TOKEN_INFO.flags */
    54     PRUint32 flags;
    55     void *epv;
    56     nssSession *defaultSession;
    57     NSSTrustDomain *trustDomain;
    58     PRIntervalTime lastTime;
    59     nssTokenObjectCache *cache;
    60     PK11SlotInfo *pk11slot;
    61 };
    63 typedef enum {
    64   nssSlotAskPasswordTimes_FirstTime = 0,
    65   nssSlotAskPasswordTimes_EveryTime = 1,
    66   nssSlotAskPasswordTimes_Timeout = 2
    67 } 
    68 nssSlotAskPasswordTimes;
    70 struct nssSlotAuthInfoStr
    71 {
    72   PRTime lastLogin;
    73   nssSlotAskPasswordTimes askTimes;
    74   PRIntervalTime askPasswordTimeout;
    75 };
    77 struct NSSSlotStr
    78 {
    79   struct nssDeviceBaseStr base;
    80   NSSModule *module; /* Parent */
    81   NSSToken *token;  /* Peer */
    82   CK_SLOT_ID slotID;
    83   CK_FLAGS ckFlags; /* from CK_SLOT_INFO.flags */
    84   struct nssSlotAuthInfoStr authInfo;
    85   PRIntervalTime lastTokenPing;
    86   PZLock *lock;
    87   void *epv;
    88   PK11SlotInfo *pk11slot;
    89 };
    91 struct nssSessionStr
    92 {
    93   PZLock *lock;
    94   CK_SESSION_HANDLE handle;
    95   NSSSlot *slot;
    96   PRBool isRW;
    97   PRBool ownLock;
    98 };
   100 typedef enum {
   101     NSSCertificateType_Unknown = 0,
   102     NSSCertificateType_PKIX = 1
   103 } NSSCertificateType;
   105 typedef enum {
   106     nssTrustLevel_Unknown = 0,
   107     nssTrustLevel_NotTrusted = 1,
   108     nssTrustLevel_Trusted = 2,
   109     nssTrustLevel_TrustedDelegator = 3,
   110     nssTrustLevel_MustVerify = 4,
   111     nssTrustLevel_ValidDelegator = 5
   112 } nssTrustLevel;
   114 typedef struct nssCryptokiInstanceStr nssCryptokiInstance;
   116 struct nssCryptokiInstanceStr
   117 {
   118     CK_OBJECT_HANDLE handle;
   119     NSSToken *token;
   120     PRBool isTokenObject;
   121     NSSUTF8 *label;
   122 };
   124 typedef struct nssCryptokiInstanceStr nssCryptokiObject;
   126 typedef struct nssTokenCertSearchStr nssTokenCertSearch;
   128 typedef enum {
   129     nssTokenSearchType_AllObjects = 0,
   130     nssTokenSearchType_SessionOnly = 1,
   131     nssTokenSearchType_TokenOnly = 2,
   132     nssTokenSearchType_TokenForced = 3
   133 } nssTokenSearchType;
   135 struct nssTokenCertSearchStr
   136 {
   137     nssTokenSearchType searchType;
   138     PRStatus (* callback)(NSSCertificate *c, void *arg);
   139     void *cbarg;
   140     nssList *cached;
   141     /* TODO: add a cache query callback if the list would be large 
   142      *       (traversal) 
   143      */
   144 };
   146 struct nssSlotListStr;
   147 typedef struct nssSlotListStr nssSlotList;
   149 struct NSSAlgorithmAndParametersStr
   150 {
   151     CK_MECHANISM mechanism;
   152 };
   154 PR_END_EXTERN_C
   156 #endif /* DEVT_H */

mercurial