/* * MDLib.h - Ron Rivest's Message-Digest Algorithms Shared Library * * This code is in the public domain. I would appreciate bug reports and * enhancements. * * Duncan S Wong * * Jan 3, 2001 - Initial Version */ // MDLib Version 0.1 (Jan 3, 2001) - Initial Version #ifndef __MDLIB_H__ #define __MDLIB_H__ #ifndef __palmos__ #define __palmos__ #endif #include // for OS 3.5, previously Pilot.h #include "md5.h" #include "md4.h" #include "md2.h" // Use this for SysLibFind calls. // This is what we 'name' our dispatch table, too. #define MDLIB_NAME "MDLib" #define MDLIB_CREATOR 'DWMD' // Register this with Palm // These are possible error types that the library might return: typedef enum tagMDErrEnum { MDErrNone = 0, MDErrParam = -1, MDErrNoGlobals = -2 // Your custom return codes go here... } MDErr; // These are trap identifiers. // The PalmOS constant 'sysLibTrapCustom' is the first trap number // we can use after open, close, sleep, and wake. typedef enum tagMDTrapNumEnum { // - Trap modification checklist - // // If you add, remove or otherwise modify something here, // be sure you've also done all of the following steps! // // 0) All trap identifiers must always run sequentially; no gaps! // 1) Modify the MDTrapNumEnum in MDLib.h // 2) Modify the DC.W to DispatchTable() in MDLibDispatch.c (no gaps!) // 3) Modify the JMP in DispatchTable() in MDLibDispatch.c (no gaps!) // 4) Update NUMBER_OF_FUNCTIONS in MDLibDispatch.c (0-based) // 5) Add or remove an "extern MyFunc(...) SYS_TRAP(MDTrapMyFunc)" prototype somewhere MDLibTrapMD5Init = sysLibTrapCustom, // libDispatchEntry(4) MDLibTrapMD5Update, MDLibTrapMD5Final, MDLibTrapMD4Init, MDLibTrapMD4Update, MDLibTrapMD4Final, MDLibTrapMD2Init, MDLibTrapMD2Update, MDLibTrapMD2Final } MDTrapNumEnum; /************************* * MDLib Interface *************************/ // These are the four required entry points: extern MDErr MDLibOpen(UInt16 uRefNum) SYS_TRAP(sysLibTrapOpen); extern MDErr MDLibClose(UInt16 uRefNum, UInt32* dwRefCountP) SYS_TRAP(sysLibTrapClose); extern Err MDLibSleep(UInt16 uRefNum) SYS_TRAP(sysLibTrapSleep); extern Err MDLibWake(UInt16 uRefNum) SYS_TRAP(sysLibTrapWake); // Here are the actual functions we want the library to extend to callers. extern void MDLibMD5Init(UInt16 uRefNum, MD5_CTX *context) SYS_TRAP(MDLibTrapMD5Init); extern void MDLibMD5Update(UInt16 uRefNum, MD5_CTX *context, unsigned char *input, unsigned int inputLen) SYS_TRAP(MDLibTrapMD5Update); extern void MDLibMD5Final(UInt16 uRefNum, unsigned char digest[16], MD5_CTX *context) SYS_TRAP(MDLibTrapMD5Final); extern void MDLibMD4Init(UInt16 uRefNum, MD4_CTX *context) SYS_TRAP(MDLibTrapMD4Init); extern void MDLibMD4Update(UInt16 uRefNum, MD4_CTX *context, unsigned char *input, unsigned int inputLen) SYS_TRAP(MDLibTrapMD4Update); extern void MDLibMD4Final(UInt16 uRefNum, unsigned char digest[16], MD4_CTX *context) SYS_TRAP(MDLibTrapMD4Final); extern void MDLibMD2Init(UInt16 uRefNum, MD2_CTX *context) SYS_TRAP(MDLibTrapMD2Init); extern void MDLibMD2Update(UInt16 uRefNum, MD2_CTX *context, unsigned char *input, unsigned int inputLen) SYS_TRAP(MDLibTrapMD2Update); extern void MDLibMD2Final(UInt16 uRefNum, unsigned char digest[16], MD2_CTX *context) SYS_TRAP(MDLibTrapMD2Final); #endif