|
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)(SDB *sdb, const CK_ATTRIBUTE *template, |
|
43 CK_ULONG count, SDBFind **find); |
|
44 CK_RV (*sdb_FindObjects)(SDB *sdb, SDBFind *find, CK_OBJECT_HANDLE *ids, |
|
45 CK_ULONG arraySize, CK_ULONG *count); |
|
46 CK_RV (*sdb_FindObjectsFinal)(SDB *sdb, SDBFind *find); |
|
47 CK_RV (*sdb_GetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, |
|
48 CK_ATTRIBUTE *template, CK_ULONG count); |
|
49 CK_RV (*sdb_SetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, |
|
50 const CK_ATTRIBUTE *template, CK_ULONG count); |
|
51 CK_RV (*sdb_CreateObject)(SDB *sdb, CK_OBJECT_HANDLE *object, |
|
52 const CK_ATTRIBUTE *template, CK_ULONG count); |
|
53 CK_RV (*sdb_DestroyObject)(SDB *sdb, CK_OBJECT_HANDLE object); |
|
54 CK_RV (*sdb_GetMetaData)(SDB *sdb, const char *id, |
|
55 SECItem *item1, SECItem *item2); |
|
56 CK_RV (*sdb_PutMetaData)(SDB *sdb, const char *id, |
|
57 const SECItem *item1, const SECItem *item2); |
|
58 CK_RV (*sdb_Begin)(SDB *sdb); |
|
59 CK_RV (*sdb_Commit)(SDB *sdb); |
|
60 CK_RV (*sdb_Abort)(SDB *sdb); |
|
61 CK_RV (*sdb_Reset)(SDB *sdb); |
|
62 CK_RV (*sdb_Close)(SDB *sdb); |
|
63 void (*sdb_SetForkState)(PRBool forked); |
|
64 }; |
|
65 |
|
66 CK_RV s_open(const char *directory, const char *certPrefix, |
|
67 const char *keyPrefix, |
|
68 int cert_version, int key_version, |
|
69 int flags, SDB **certdb, SDB **keydb, int *newInit); |
|
70 CK_RV s_shutdown(); |
|
71 |
|
72 /* flags */ |
|
73 #define SDB_RDONLY 1 |
|
74 #define SDB_RDWR 2 |
|
75 #define SDB_CREATE 4 |
|
76 #define SDB_HAS_META 8 |
|
77 |
|
78 #endif |