Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | /* |
michael@0 | 5 | * This file implements PKCS 11 on top of our existing security modules |
michael@0 | 6 | * |
michael@0 | 7 | * For more information about PKCS 11 See PKCS 11 Token Inteface Standard. |
michael@0 | 8 | * This implementation has two slots: |
michael@0 | 9 | * slot 1 is our generic crypto support. It does not require login. |
michael@0 | 10 | * It supports Public Key ops, and all they bulk ciphers and hashes. |
michael@0 | 11 | * It can also support Private Key ops for imported Private keys. It does |
michael@0 | 12 | * not have any token storage. |
michael@0 | 13 | * slot 2 is our private key support. It requires a login before use. It |
michael@0 | 14 | * can store Private Keys and Certs as token objects. Currently only private |
michael@0 | 15 | * keys and their associated Certificates are saved on the token. |
michael@0 | 16 | * |
michael@0 | 17 | * In this implementation, session objects are only visible to the session |
michael@0 | 18 | * that created or generated them. |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | /* |
michael@0 | 22 | * the following data structures should be moved to a 'rdb.h'. |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | #ifndef _SDB_H |
michael@0 | 26 | #define _SDB_H 1 |
michael@0 | 27 | #include "pkcs11t.h" |
michael@0 | 28 | #include "secitem.h" |
michael@0 | 29 | #include "sftkdbt.h" |
michael@0 | 30 | |
michael@0 | 31 | #define STATIC_CMD_SIZE 2048 |
michael@0 | 32 | |
michael@0 | 33 | typedef struct SDBFindStr SDBFind; |
michael@0 | 34 | typedef struct SDBStr SDB; |
michael@0 | 35 | |
michael@0 | 36 | struct SDBStr { |
michael@0 | 37 | void *private; |
michael@0 | 38 | int version; |
michael@0 | 39 | int reserved; |
michael@0 | 40 | int sdb_flags; |
michael@0 | 41 | void *app_private; |
michael@0 | 42 | CK_RV (*sdb_FindObjectsInit)(SDB *sdb, const CK_ATTRIBUTE *template, |
michael@0 | 43 | CK_ULONG count, SDBFind **find); |
michael@0 | 44 | CK_RV (*sdb_FindObjects)(SDB *sdb, SDBFind *find, CK_OBJECT_HANDLE *ids, |
michael@0 | 45 | CK_ULONG arraySize, CK_ULONG *count); |
michael@0 | 46 | CK_RV (*sdb_FindObjectsFinal)(SDB *sdb, SDBFind *find); |
michael@0 | 47 | CK_RV (*sdb_GetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, |
michael@0 | 48 | CK_ATTRIBUTE *template, CK_ULONG count); |
michael@0 | 49 | CK_RV (*sdb_SetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, |
michael@0 | 50 | const CK_ATTRIBUTE *template, CK_ULONG count); |
michael@0 | 51 | CK_RV (*sdb_CreateObject)(SDB *sdb, CK_OBJECT_HANDLE *object, |
michael@0 | 52 | const CK_ATTRIBUTE *template, CK_ULONG count); |
michael@0 | 53 | CK_RV (*sdb_DestroyObject)(SDB *sdb, CK_OBJECT_HANDLE object); |
michael@0 | 54 | CK_RV (*sdb_GetMetaData)(SDB *sdb, const char *id, |
michael@0 | 55 | SECItem *item1, SECItem *item2); |
michael@0 | 56 | CK_RV (*sdb_PutMetaData)(SDB *sdb, const char *id, |
michael@0 | 57 | const SECItem *item1, const SECItem *item2); |
michael@0 | 58 | CK_RV (*sdb_Begin)(SDB *sdb); |
michael@0 | 59 | CK_RV (*sdb_Commit)(SDB *sdb); |
michael@0 | 60 | CK_RV (*sdb_Abort)(SDB *sdb); |
michael@0 | 61 | CK_RV (*sdb_Reset)(SDB *sdb); |
michael@0 | 62 | CK_RV (*sdb_Close)(SDB *sdb); |
michael@0 | 63 | void (*sdb_SetForkState)(PRBool forked); |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | CK_RV s_open(const char *directory, const char *certPrefix, |
michael@0 | 67 | const char *keyPrefix, |
michael@0 | 68 | int cert_version, int key_version, |
michael@0 | 69 | int flags, SDB **certdb, SDB **keydb, int *newInit); |
michael@0 | 70 | CK_RV s_shutdown(); |
michael@0 | 71 | |
michael@0 | 72 | /* flags */ |
michael@0 | 73 | #define SDB_RDONLY 1 |
michael@0 | 74 | #define SDB_RDWR 2 |
michael@0 | 75 | #define SDB_CREATE 4 |
michael@0 | 76 | #define SDB_HAS_META 8 |
michael@0 | 77 | |
michael@0 | 78 | #endif |