// ***** // * PROJECT: SSC2Lib (SSC2) // * FILENAME: SSC2Lib.h // * AUTHOR: Hector Ho Fuentes // * // * SSC2 created by Muxiang Zhang // * // * DESCRIPTION: SSC2 Shared library functionality interface definition // * // * HISTORY: // * 7/18/02 Duncan Wong - Version 0.5 // * - fixed the key initialization problem when key length != 16 // * 7/16/2002 Hector Ho Fuentes - Version 0.4 // * - In MasterKeyGenerationSSC2: // * - Changed the return type to verify for errors. // * - Change to show error codes for wrong Key size // * - Changed x-or for or if keysize >=16. // * - Rechecked code, looks O.K. // * 6/23/02 Duncan Wong - Version 0.3 // * - bug fix // * 4/28/01 Duncan Wong - Version 0.2 // * - more efficient // * 1/23/01 Hector Ho Fuentes - Initial Version // * // * COPYRIGHT: // * // ***** // ***** // * 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. // ***** #pragma once // Use this for SysLibFind calls. This is what we 'name' our dispatch table, too: #define SSC2_LIB_NAME "SSC2 Library" #define SSC2_LIB_CREATOR 'HHSL' // Register this with Palm // [swong] Dragonball microprocessor is big endian // [swong] This library is still architecture independent but more efficient if the platform is big endian #ifndef BIG_ENDIAN #define BIG_ENDIAN #endif // These are possible error types that SSC2 might return: typedef enum tagSSC2ErrEnum { SSC2ErrNone = 0, SSC2ErrParam = -1, SSC2ErrNoGlobals = -2, ///// // Your custom return codes go here... ///// SSC2ErrKeySize = -3 } SSC2Err; // These are SSC2's trap identifiers. The PalmOS constant 'sysLibTrapCustom' is // the first trap number we can use after open, close, sleep, and wake. typedef enum tagSSC2TrapNumEnum { ///// // - 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 SSC2TrapNumEnum in MySharedLib.h // 2) Modify the DC.W to SSC2_DispatchTable() in MySharedLibDispatch.c (no gaps!) // 3) Modify the JMP in SSC2_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(SSC2TrapMyFunc)" prototype somewhere // ///// SSC2TrapMasterKeyGeneration = sysLibTrapCustom, // libDispatchEntry(4) SSC2TrapFrameKeyGeneration, // libDispatchEntry(5) SSC2TrapEncrypt, // libDispatchEntry(6) SSC2TrapDecrypt // libDispatchEntry(7) } SSC2TrapNumEnum; typedef struct { //unsigned char key[16];//[Hector 0.4] Removed, Users should store the key they will use in their own array or D.S. unsigned long R[4]; unsigned long B[18]; } SSC2_CTX; #ifdef __cplusplus extern "C" { #endif // These are the four required entry points: extern SSC2Err SSC2Open ( UInt16 uRefNum ) SYS_TRAP ( sysLibTrapOpen); extern SSC2Err SSC2Close( UInt16 uRefNum, UInt32* dwRefCountP ) SYS_TRAP ( sysLibTrapClose); extern Err SSC2Sleep( UInt16 uRefNum ) SYS_TRAP ( sysLibTrapSleep); extern Err SSC2Wake ( UInt16 uRefNum ) SYS_TRAP ( sysLibTrapWake ); // Here are the actual functions we want the library to extend to callers. extern SSC2Err SSC2MasterKeyGeneration(UInt16 refNum, unsigned char * keystring, int keysize, SSC2_CTX * key) SYS_TRAP(SSC2TrapMasterKeyGeneration); extern SSC2Err SSC2FrameKeyGeneration(UInt16 refNum, SSC2_CTX * key, unsigned long n) SYS_TRAP(SSC2TrapFrameKeyGeneration); extern Int16 SSC2Encrypt(UInt16 refNum, SSC2_CTX * key, unsigned char * in, unsigned char * out, unsigned long size) SYS_TRAP(SSC2TrapEncrypt); extern Int16 SSC2Decrypt(UInt16 refNum, SSC2_CTX * key, unsigned char * in, unsigned char * out, unsigned long size) SYS_TRAP(SSC2TrapDecrypt); #ifdef __cplusplus } #endif