// ***** // * PROJECT: SEALLib (SEAL) // * FILENAME: SEALLib.h // * AUTHOR: Hector Ho Fuentes // * // * SEAL created by Phil Rogaway and Don Coppersmith. // * // * DESCRIPTION: SEAL Shared library functionality interface definition // * // * // * HISTORY: Hector Ho Fuentes 1/25/2001 // * // * // * 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 SEAL_LIB_NAME "SEALLibrary" #define SEAL_LIB_CREATOR 'HHSE' // Register this with Palm #define ALG_OK 0 #define ALG_NOTOK 1 // These are possible error types that SEAL might return: typedef enum tagSEALErrEnum { SEALErrNone = 0, SEALErrParam = -1, SEALErrNoGlobals = -2, ///// // Your custom return codes go here... ///// SEALErrKeySize = -3, SEALErrNotEnoughMemory = -4 } SEALErr; // These are SEAL's trap identifiers. The PalmOS constant 'sysLibTrapCustom' is // the first trap number we can use after open, close, sleep, and wake. typedef enum tagSEALTrapNumEnum { ///// // - 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 SEALTrapNumEnum in MySharedLib.h // 2) Modify the DC.W to SEAL_DispatchTable() in MySharedLibDispatch.c (no gaps!) // 3) Modify the JMP in SEAL_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(SEALTrapMyFunc)" prototype somewhere // ///// SEALTrapKey = sysLibTrapCustom, // libDispatchEntry(4) SEALTrapEncrypt, // libDispatchEntry(5) SEALTrapDecrypt, // libDispatchEntry(6) SEALTrapResynch, // libDispatchEntry(7) SEALTrapSEALInit, // libDispatchEntry(8) SEALTrapSEALClean // libDispatchEntry(9) } SEALTrapNumEnum; typedef struct { unsigned long *t; /* 512 rounded up to a multiple of 5 + 5*/ unsigned long *s; /* 256 rounded up to a multiple of 5 + 5*/ unsigned long *r; /* 16 rounded up to multiple of 5 */ /* According to the paper (version 3.0) page 6, 16 elements are required for generating 4KB of keystream */ unsigned long counter; /* 32-bit synch value. */ unsigned long *ks_buf; /* keystream buffer */ int ks_pos; } SEAL_CTX; #ifdef __cplusplus extern "C" { #endif // These are the four required entry points: extern SEALErr SEALOpen(UInt16 uRefNum) SYS_TRAP (sysLibTrapOpen); extern SEALErr SEALClose(UInt16 uRefNum, UInt32* dwRefCountP) SYS_TRAP (sysLibTrapClose); extern Err SEALSleep(UInt16 uRefNum) SYS_TRAP (sysLibTrapSleep); extern Err SEALWake(UInt16 uRefNum) SYS_TRAP (sysLibTrapWake); // Here are the actual functions we want the library to extend to callers. /* NOTE: SEALKey will just initialize the structures given a key. It is up to the user to allocate / deallocate the memory needed. It is better to user SEALInit and SEALClean before and after using SEALEncrypt/SEALDecrypt, because they allocate and Initialze the data and will then just deallocate the used data. */ extern SEALErr SEALKey(UInt16 refNum, SEAL_CTX * keycxt, unsigned char * key) SYS_TRAP(SEALTrapKey); extern Int16 SEALEncrypt(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * input, unsigned char * output, int size) SYS_TRAP(SEALTrapEncrypt); extern Int16 SEALDecrypt(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * input, unsigned char * output, int size) SYS_TRAP(SEALTrapDecrypt); extern SEALErr SEALResynch(UInt16 refNum, SEAL_CTX * keyctx, unsigned long synch_word) SYS_TRAP(SEALTrapResynch); extern SEALErr SEALInit(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * key) SYS_TRAP(SEALTrapSEALInit); extern SEALErr SEALClean(UInt16 refNum, SEAL_CTX * keyctx) SYS_TRAP(SEALTrapSEALClean); #ifdef __cplusplus } #endif