michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NSSBridge_h michael@0: #define NSSBridge_h michael@0: michael@0: #include "nss.h" michael@0: #include "pk11func.h" michael@0: #include "pk11sdr.h" michael@0: #include "seccomon.h" michael@0: #include "secitem.h" michael@0: #include "secmodt.h" michael@0: michael@0: #include "prerror.h" michael@0: #include "plstr.h" michael@0: #include "prmem.h" michael@0: michael@0: #include michael@0: michael@0: int setup_nss_functions(void *nss_handle, void *nssutil_handle, void *plc_handle); michael@0: michael@0: #define NSS_WRAPPER(name, return_type, args...) \ michael@0: typedef return_type (*name ## _t)(args); \ michael@0: extern name ## _t f_ ## name; michael@0: michael@0: NSS_WRAPPER(NSS_Initialize, SECStatus, const char*, const char*, const char*, const char*, uint32_t) michael@0: NSS_WRAPPER(NSS_Shutdown, void, void) michael@0: NSS_WRAPPER(PK11SDR_Encrypt, SECStatus, SECItem *, SECItem *, SECItem *, void *) michael@0: NSS_WRAPPER(PK11SDR_Decrypt, SECStatus, SECItem *, SECItem *, void *) michael@0: NSS_WRAPPER(SECITEM_ZfreeItem, void, SECItem*, PRBool) michael@0: NSS_WRAPPER(PR_ErrorToString, char *, PRErrorCode, PRLanguageCode) michael@0: NSS_WRAPPER(PR_GetError, PRErrorCode, void) michael@0: NSS_WRAPPER(PR_Free, PRErrorCode, char *) michael@0: NSS_WRAPPER(PL_Base64Encode, char*, const char*, uint32_t, char*) michael@0: NSS_WRAPPER(PL_Base64Decode, char*, const char*, uint32_t, char*) michael@0: NSS_WRAPPER(PL_strfree, void, char*) michael@0: NSS_WRAPPER(PK11_GetInternalKeySlot, PK11SlotInfo *, void) michael@0: NSS_WRAPPER(PK11_NeedUserInit, PRBool, PK11SlotInfo *) michael@0: NSS_WRAPPER(PK11_InitPin, SECStatus, PK11SlotInfo*, const char*, const char*) michael@0: michael@0: bool setPassword(PK11SlotInfo *slot); michael@0: SECStatus doCrypto(JNIEnv* jenv, const char *path, const char *value, char** result, bool doEncrypt); michael@0: SECStatus encode(const unsigned char *data, int32_t dataLen, char **_retval); michael@0: SECStatus decode(const char *data, unsigned char **result, int32_t * _retval); michael@0: #endif /* NSS_h */