mozglue/android/NSSBridge.h
author Steven Lee <slee@mozilla.com>
Tue, 07 Aug 2012 19:11:00 -0400
changeset 104895 5439489dc320dbe10c3826682983480b712039ae
parent 96742 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 106112 a16372ce30b5f6b747246b01fcd215a4bf3b6342
permissions -rw-r--r--
Bug 714358: Time manager implementation. r=jlebar

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef NSSBridge_h
#define NSSBridge_h

#include "nss.h"
#include "seccomon.h"
#include "secmodt.h"
#include "secutil.h"
#include "pk11func.h"
#include <jni.h>

int setup_nss_functions(void *nss_handle, void *nssutil_handle, void *plc_handle);

#define NSS_WRAPPER(name, return_type, args...) \
typedef return_type (*name ## _t)(args);  \
extern name ## _t f_ ## name;

NSS_WRAPPER(NSS_Initialize, SECStatus, const char*, const char*, const char*, const char*, PRUint32)
NSS_WRAPPER(NSS_Shutdown, void, void)
NSS_WRAPPER(PK11SDR_Encrypt, SECStatus, SECItem *, SECItem *, SECItem *, void *)
NSS_WRAPPER(PK11SDR_Decrypt, SECStatus, SECItem *, SECItem *, void *)
NSS_WRAPPER(SECITEM_ZfreeItem, void, SECItem*, PRBool)
NSS_WRAPPER(PR_ErrorToString, char *, PRErrorCode, PRLanguageCode)
NSS_WRAPPER(PR_GetError, PRErrorCode, void)
NSS_WRAPPER(PR_Free, PRErrorCode, char *)
NSS_WRAPPER(PL_Base64Encode, char*, const char*, PRUint32, char*)
NSS_WRAPPER(PL_Base64Decode, char*, const char*, PRUint32, char*)
NSS_WRAPPER(PL_strfree, void, char*)
NSS_WRAPPER(PK11_GetInternalKeySlot, PK11SlotInfo *, void)
NSS_WRAPPER(PK11_NeedUserInit, PRBool, PK11SlotInfo *)
NSS_WRAPPER(PK11_InitPin, SECStatus, PK11SlotInfo*, const char*, const char*)

bool setPassword(PK11SlotInfo *slot);
SECStatus doCrypto(JNIEnv* jenv, const char *path, const char *value, char** result, bool doEncrypt);
SECStatus encode(const unsigned char *data, PRInt32 dataLen, char **_retval);
SECStatus decode(const char *data, unsigned char **result, PRInt32 * _retval);
#endif /* NSS_h */