tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

sdb.h (3147B)


      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/. */
      4 /*
      5 * This file implements PKCS 11 on top of our existing security modules
      6 *
      7 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard.
      8 *   This implementation has two slots:
      9 *      slot 1 is our generic crypto support. It does not require login.
     10 *   It supports Public Key ops, and all they bulk ciphers and hashes.
     11 *   It can also support Private Key ops for imported Private keys. It does
     12 *   not have any token storage.
     13 *      slot 2 is our private key support. It requires a login before use. It
     14 *   can store Private Keys and Certs as token objects. Currently only private
     15 *   keys and their associated Certificates are saved on the token.
     16 *
     17 *   In this implementation, session objects are only visible to the session
     18 *   that created or generated them.
     19 */
     20 
     21 /*
     22 * the following data structures should be moved to a 'rdb.h'.
     23 */
     24 
     25 #ifndef _SDB_H
     26 #define _SDB_H 1
     27 #include "pkcs11t.h"
     28 #include "secitem.h"
     29 #include "sftkdbt.h"
     30 
     31 #define STATIC_CMD_SIZE 2048
     32 
     33 typedef struct SDBFindStr SDBFind;
     34 typedef struct SDBStr SDB;
     35 
     36 struct SDBStr {
     37    void *private;
     38    int version;
     39    int reserved;
     40    int sdb_flags;
     41    void *app_private;
     42    CK_RV(*sdb_FindObjectsInit)
     43    (SDB *sdb, const CK_ATTRIBUTE *template,
     44     CK_ULONG count, SDBFind **find);
     45    CK_RV(*sdb_FindObjects)
     46    (SDB *sdb, SDBFind *find, CK_OBJECT_HANDLE *ids,
     47     CK_ULONG arraySize, CK_ULONG *count);
     48    CK_RV(*sdb_FindObjectsFinal)
     49    (SDB *sdb, SDBFind *find);
     50    CK_RV(*sdb_GetAttributeValue)
     51    (SDB *sdb, CK_OBJECT_HANDLE object,
     52     CK_ATTRIBUTE *template, CK_ULONG count);
     53    CK_RV(*sdb_SetAttributeValue)
     54    (SDB *sdb, CK_OBJECT_HANDLE object,
     55     const CK_ATTRIBUTE *template, CK_ULONG count);
     56    CK_RV(*sdb_CreateObject)
     57    (SDB *sdb, CK_OBJECT_HANDLE *object,
     58     const CK_ATTRIBUTE *template, CK_ULONG count);
     59    CK_RV(*sdb_DestroyObject)
     60    (SDB *sdb, CK_OBJECT_HANDLE object);
     61    CK_RV(*sdb_GetMetaData)
     62    (SDB *sdb, const char *id,
     63     SECItem *item1, SECItem *item2);
     64    CK_RV(*sdb_PutMetaData)
     65    (SDB *sdb, const char *id,
     66     const SECItem *item1, const SECItem *item2);
     67    CK_RV(*sdb_Begin)
     68    (SDB *sdb);
     69    CK_RV(*sdb_Commit)
     70    (SDB *sdb);
     71    CK_RV(*sdb_Abort)
     72    (SDB *sdb);
     73    CK_RV(*sdb_Reset)
     74    (SDB *sdb);
     75    CK_RV(*sdb_Close)
     76    (SDB *sdb);
     77    void (*sdb_SetForkState)(PRBool forked);
     78    CK_RV(*sdb_GetNewObjectID)
     79    (SDB *db, CK_OBJECT_HANDLE *object);
     80    CK_RV(*sdb_DestroyMetaData)
     81    (SDB *db, const char *id);
     82 };
     83 
     84 CK_RV s_open(const char *directory, const char *certPrefix,
     85             const char *keyPrefix,
     86             int cert_version, int key_version,
     87             int flags, SDB **certdb, SDB **keydb, int *newInit);
     88 CK_RV s_shutdown();
     89 CK_RV sdb_Close(SDB *sdb);
     90 
     91 #if defined(_WIN32)
     92 wchar_t *sdb_UTF8ToWide(const char *buf);
     93 #endif
     94 
     95 /* flags */
     96 #define SDB_RDONLY 1
     97 #define SDB_RDWR 2
     98 #define SDB_CREATE 4
     99 #define SDB_HAS_META 8
    100 #define SDB_FIPS 0x10
    101 
    102 #endif