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 code defines the glue layer between softoken and the legacy DB library
6  */
7 #include "sdb.h"
8 
9 /*
10  * function prototypes for the callbacks into softoken from the legacyDB
11  */
12 
13 typedef SECStatus (*LGEncryptFunc)(PLArenaPool *arena, SDB *sdb,
14                                    SECItem *plainText, SECItem **cipherText);
15 typedef SECStatus (*LGDecryptFunc)(SDB *sdb, SECItem *cipherText,
16                                    SECItem **plainText);
17 
18 /*
19  * function prototypes for the exported functions.
20  */
21 typedef CK_RV (*LGOpenFunc)(const char *dir, const char *certPrefix,
22                             const char *keyPrefix,
23                             int certVersion, int keyVersion, int flags,
24                             SDB **certDB, SDB **keyDB);
25 typedef char **(*LGReadSecmodFunc)(const char *appName,
26                                    const char *filename,
27                                    const char *dbname, char *params, PRBool rw);
28 typedef SECStatus (*LGReleaseSecmodFunc)(const char *appName,
29                                          const char *filename,
30                                          const char *dbname, char **params, PRBool rw);
31 typedef SECStatus (*LGDeleteSecmodFunc)(const char *appName,
32                                         const char *filename,
33                                         const char *dbname, char *params, PRBool rw);
34 typedef SECStatus (*LGAddSecmodFunc)(const char *appName,
35                                      const char *filename,
36                                      const char *dbname, char *params, PRBool rw);
37 typedef SECStatus (*LGShutdownFunc)(PRBool forked);
38 typedef void (*LGSetForkStateFunc)(PRBool);
39 typedef void (*LGSetCryptFunc)(LGEncryptFunc, LGDecryptFunc);
40 
41 /*
42  * Softoken Glue Functions
43  */
44 CK_RV sftkdbCall_open(const char *dir, const char *certPrefix,
45                       const char *keyPrefix,
46                       int certVersion, int keyVersion, int flags,
47                       SDB **certDB, SDB **keyDB);
48 char **sftkdbCall_ReadSecmodDB(const char *appName, const char *filename,
49                                const char *dbname, char *params, PRBool rw);
50 SECStatus sftkdbCall_ReleaseSecmodDBData(const char *appName,
51                                          const char *filename, const char *dbname,
52                                          char **moduleSpecList, PRBool rw);
53 SECStatus sftkdbCall_DeleteSecmodDB(const char *appName,
54                                     const char *filename, const char *dbname,
55                                     char *args, PRBool rw);
56 SECStatus sftkdbCall_AddSecmodDB(const char *appName,
57                                  const char *filename, const char *dbname,
58                                  char *module, PRBool rw);
59 CK_RV sftkdbCall_Shutdown(void);
60