/* RijndaelGladmanLib.h - Rijndael shared library header file * * This code is in the public domain. I would appreciate bug reports and * enhancements. * * Duncan S Wong * * July 31, 2001 - Initial Port * Aug 4, 2001 - version 1.0 * Reasons: By using database resource to store up to 20KB * transformation tables and round constants (rcon_tab). * Here below lists some possible cases: * 1) ONE_TABLE, ONE_LR_TABLE - 4KB * 2) ONE_TABLE, ONE_LR_TABLE, ONE_IM_TABLE - 5KB * 3) FOUR_TABLES - 8KB * 4) FOUR_TABLES, FOUR_LR_TABLES - 16KB * 5) FOUR_TABLES, FOUR_LR_TABLES, FOUR_IM_TABLES - 20KB * The structure of the database can be found in the struct TablesType * defined in RijndaelGladmanLibPrv.h * Details about the transformation tables are in Rijndael AES Proposal * version 2 (page 17-22). * Apr 2, 2002 - version 1.1 * Reasons: fix the write-to-NULL problem of (void *) tablesP in * RijndaelGladmanCTX structure defined in rijndael_gladman.h * The solution is to change (void *) tablesP to (TablesType) tablesP * and move the TablesType structure definition from * RijndaelGladmanLibPrv.h to rijndael_gladman.h * (The problem was pointed out by Dave Webb) */ // ***** // * PROJECT: MySharedLib (MSL) // * FILENAME: MySharedLib.h // * AUTHOR: Jeff Ishaq 05/21/99 // * // * DESCRIPTION: Shared library functionality interface definition // * // * COPYRIGHT: As long as this 'copyright' is intact, this code is freely modifiable // * and distributable. // ***** #ifndef __RIJNDAELGLADMANLIB_H__ #define __RIJNDAELGLADMANLIB_H__ #include "rijndael_gladman.h" // Use this for SysLibFind calls. This is what we 'name' our dispatch table, too: #define RIJNDAELGLADMANLIB_NAME "RijndaelGladmanLib" #define RIJNDAELGLADMANLIB_CREATOR 'DWRG' // Register this with Palm // These are possible error types that MSL might return: typedef enum tagRijndaelGladmanErrEnum { RijndaelGladmanErrNone = 0, RijndaelGladmanErrParam = -1, RijndaelGladmanErrNoGlobals = -2, RijndaelGladmanErrCipherErr = -3 ///// // Your custom return codes go here... ///// } RijndaelGladmanErr; // These are MSL's trap identifiers. The PalmOS constant 'sysLibTrapCustom' is // the first trap number we can use after open, close, sleep, and wake. typedef enum tagRijndaelGladmanTrapNumEnum { ///// // - Trap modification checklist - // // If you add or 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 RijndaelGladmanTrapNumEnum in MySharedLib.h // 2) Modify the DC.W to MSL_DispatchTable() in MySharedLibDispatch.c (no gaps!) // 3) Modify the JMP in MSL_DispatchTable() in MySharedLibDispatch.c (no gaps!) // 4) ** Update NUMBER_OF_FUNCTIONS in MySharedLibDispatch.c ** (0-based) // 5) Add or remove an "extern MyFunc(...) SYS_TRAP(RijndaelGladmanTrapMyFunc)" prototype somewhere // ///// RijndaelGladmanLibTrapMakeKey = sysLibTrapCustom, // libDispatchEntry(4) RijndaelGladmanLibTrapEncrypt, RijndaelGladmanLibTrapDecrypt } RijndaelGladmanTrapNumEnum; // These are the four required entry points: extern Int16 RijndaelGladmanLibOpen(UInt16 uRefNum) SYS_TRAP (sysLibTrapOpen); extern RijndaelGladmanErr RijndaelGladmanLibClose(UInt16 uRefNum, UInt32* dwRefCountP) SYS_TRAP(sysLibTrapClose); extern Err RijndaelGladmanLibSleep(UInt16 uRefNum) SYS_TRAP(sysLibTrapSleep); extern Err RijndaelGladmanLibWake(UInt16 uRefNum) SYS_TRAP(sysLibTrapWake); // Here are the actual functions we want the library to extend to callers. extern Int16 RijndaelGladmanLibMakeKey(UInt16 uRefNum, RijndaelGladmanCTX *ctx, UInt8 mode, UInt8 direction, Int16 key_n_bits, Char *keyMaterial, Char *IV) SYS_TRAP(RijndaelGladmanLibTrapMakeKey); extern Int16 RijndaelGladmanLibEncrypt(UInt16 uRefNum, RijndaelGladmanCTX *ctx, UInt8 *input, Int32 input_n_bytes, UInt8 *outBuffer) SYS_TRAP(RijndaelGladmanLibTrapEncrypt); extern Int16 RijndaelGladmanLibDecrypt(UInt16 uRefNum, RijndaelGladmanCTX *ctx, UInt8 *input, Int32 input_n_bytes, UInt8 *outBuffer) SYS_TRAP(RijndaelGladmanLibTrapDecrypt); #endif