166 lines
4.5 KiB
C
166 lines
4.5 KiB
C
|
|
|
|
#ifndef __FPM_Firefox_Password_MANAGER_H__
|
|
#define __FPM_Firefox_Password_MANAGER_H__
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
#include <time.h>
|
|
|
|
#ifdef WIN32
|
|
#include <windows.h>
|
|
#include <userenv.h>
|
|
#pragma comment(lib,"userenv.lib")
|
|
|
|
#define STRCMPI strcmpi
|
|
#define APIEXPORT __declspec(dllexport)
|
|
|
|
#define NSS_LIBRARY_NAME "nss3.dll"
|
|
#define PLC_LIBRARY_NAME "plc4.dll"
|
|
#define NSPR_LIBRARY_NAME "nspr4.dll"
|
|
#define PLDS_LIBRARY_NAME "plds4.dll"
|
|
#define SOFTN_LIBRARY_NAME "softokn3.dll"
|
|
|
|
#define LOADLIBRARY(x) LoadLibrary(x)
|
|
#define GETPROCADDRESS GetProcAddress
|
|
#define FREELIBRARY FreeLibrary
|
|
|
|
#else
|
|
#include <dlfcn.h>
|
|
#define STRCMPI strcasecmp
|
|
#define APIEXPORT
|
|
|
|
#define NSS_LIBRARY_NAME "libnss3.so"
|
|
#define PLC_LIBRARY_NAME "libplc4.so"
|
|
#define NSPR_LIBRARY_NAME "libnspr4.so"
|
|
#define PLDS_LIBRARY_NAME "libplds4.so"
|
|
#define SOFTN_LIBRARY_NAME "libsoftokn3.so"
|
|
|
|
#define LOADLIBRARY(x) dlopen(x, RTLD_LAZY) // alternative : RTLD_NOW
|
|
#define GETPROCADDRESS dlsym
|
|
#define FREELIBRARY dlclose
|
|
|
|
#define HMODULE void *
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FPM_TRUE 1
|
|
#define FPM_FALSE 0
|
|
|
|
#define MESG_DEBUG 0
|
|
#define MESG_PRINT 1
|
|
#define MESG_ERROR 2
|
|
|
|
#define MAX_PROFILE_COUNT 5
|
|
|
|
//#define DEBUG 11
|
|
|
|
#define Unichar unsigned int
|
|
|
|
#define HEADER_VERSION "#2c"
|
|
#define CRYPT_PREFIX "~"
|
|
|
|
#define SIGNON_FILE_NAME "signons.txt"
|
|
|
|
// Internal structure declaration taken from firefox.....
|
|
typedef enum SECItemType
|
|
{
|
|
siBuffer = 0,
|
|
siClearDataBuffer = 1,
|
|
siCipherDataBuffer = 2,
|
|
siDERCertBuffer = 3,
|
|
siEncodedCertBuffer = 4,
|
|
siDERNameBuffer = 5,
|
|
siEncodedNameBuffer = 6,
|
|
siAsciiNameString = 7,
|
|
siAsciiString = 8,
|
|
siDEROID = 9,
|
|
siUnsignedInteger = 10,
|
|
siUTCTime = 11,
|
|
siGeneralizedTime = 12
|
|
};
|
|
|
|
//typedef struct SECItemStr SECItem;
|
|
|
|
struct SECItem
|
|
{
|
|
SECItemType type;
|
|
unsigned char *data;
|
|
unsigned int len;
|
|
};
|
|
|
|
|
|
typedef enum SECStatus
|
|
{
|
|
SECWouldBlock = -2,
|
|
SECFailure = -1,
|
|
SECSuccess = 0
|
|
};
|
|
|
|
// For some PR type varialbes...just to remove gecko-sdk dependency
|
|
// following is added here.
|
|
#define PRBool int
|
|
#define PRUint32 unsigned int
|
|
#define PR_TRUE 1
|
|
#define PR_FALSE 0
|
|
|
|
|
|
|
|
// End
|
|
|
|
|
|
|
|
typedef struct PK11SlotInfoStr PK11SlotInfo;
|
|
|
|
// NSS Library functions
|
|
//typedef char *(PR_CALLBACK *PK11PasswordFunc)(PK11SlotInfo *slot, PRBool retry, void *arg);
|
|
typedef SECStatus (*NSS_Init) (const char *configdir);
|
|
typedef SECStatus (*NSS_Shutdown) (void);
|
|
//typedef void (*PK11_SetPasswordFunc) (PK11PasswordFunc func);
|
|
typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void);
|
|
typedef void (*PK11_FreeSlot) (PK11SlotInfo *slot);
|
|
typedef SECStatus (*PK11_Authenticate) (PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
|
|
typedef SECStatus (*PK11_CheckUserPassword) (PK11SlotInfo *slot,char *pw);
|
|
typedef SECStatus (*PK11SDR_Decrypt) (SECItem *data, SECItem *result, void *cx);
|
|
typedef SECStatus (*PK11SDR_Encrypt) (SECItem *keyid, SECItem *data, SECItem *result, void *cx);
|
|
|
|
// PLC Library functions
|
|
typedef char * (*PL_Base64Encode)( const char *src, PRUint32 srclen, char *dest);
|
|
typedef char * (*PL_Base64Decode)( const char *src, PRUint32 srclen, char *dest);
|
|
|
|
void PrintMessage( int level, char *mesg , ...);
|
|
int IsDirectoryExists( char *path );
|
|
void StrLwr(char *str);
|
|
|
|
|
|
|
|
// Profile initiliazation functions
|
|
extern "C" APIEXPORT int FPM_IsStoreAvailable();
|
|
extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int **profileFlag);
|
|
extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName);
|
|
extern "C" APIEXPORT int FPM_FirefoxProfileExit(char *profileName);
|
|
|
|
// Master password functions
|
|
extern "C" APIEXPORT int FPM_IsMasterPasswordSet(char *profileName);
|
|
extern "C" APIEXPORT int FPM_CheckMasterPassword(char *profileName, char *masterPassword);
|
|
|
|
// Signon data update functions
|
|
extern "C" APIEXPORT int FPM_GetSignonData(char *profileName,struct Host **host, int doRefresh);
|
|
extern "C" APIEXPORT int FPM_WriteSignonData(char *profileName);
|
|
extern "C" APIEXPORT int FPM_AddHost(char *profileName, struct Host *host, int doUpdate);
|
|
extern "C" APIEXPORT int FPM_ModifyHost(char *profileName, struct Host *host, int doUpdate);
|
|
extern "C" APIEXPORT int FPM_RemoveHost(char *profileName, char *hostname, int doUpdate);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|