Disclaimer THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Hector Ho Fuentes e-mail: hhofuent@ccs.neu.edu Date of SEALLib.prc: April 25, 2001 Version: 0.1 If you have any suggestions please write to the author. Description: SEALLib is a Palm OS Library that implements SEAL 3.0. To use this Palm Library, you need to: 1. Download the SEALLib.prc 2. Download the SEALLib.h 3. Only include the SEALLib.h in your project. How to use the SSC2Lib: 1. First you need to open the Library. The sample code is as follows: err = SysLibFind("SEALLibrary", &SEALLibRefNum); if (err) err = SysLibLoad('libr', 'HHSE', &SEALLibRefNum); ErrFatalDisplayIf(err, "Cannot load SEAL Library"); err = SEALOpen(SEALLibRefNum); Where SEALLibRefNum is a static UInt16, used to store where is the SEALLibrary. We sugest that you put this code in your StartApplication() function, or in the function you use to initialize your application. 2. How to use SEAL? You need to create a variable that will contain some of the SSC2 info. We have created a special type: SEAL_CTX. Example: SEAL_CTX key_ctx; Also, you need to Initialize SEAL and then you can call the Encryption/Decryption functions. If you finished using SEAL, you need to deallocate memory used in the SEAL Initialization. After you finish, you need to close the library. 3. How to Initialize SEAL? This is done via the function: SEALInit(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * key) It has the following parameters: UInt16 refNum: This is the reference number of the library. SEAL_CTX *keyctx: This is where we store information used for SEAL. unsigned char * key: This is string with the key. NOTE: After you finished working with SEAL you need to call: SEALClean() so it can deallocate memory used at the initialization. NOTE 2: We also included the function SEALKey(). It has the same parameters as SEALInit, but no memory allocation is provided. We highly sugest using SEALInit instead. 4. How to Encrypt/Decrypt? To Encrypt or Decrypt, we have declared two functions: To Encrypt we use the function: SEALEncrypt(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * input, unsigned char * output, int size) The parameters are as follows: UInt16 refNum: The reference number of this library. Obtain when you open the library. SEAL_CTX * key: This is the context information about SEAL. You need to initialize it before using it in Encrypt or Decrypt, and you need to call SEALClean when you finished. unsigned char * input: This is a pointer to the input string. unsigned char * output: This is a pointer to where the output should be written. The user has to allocate this memory. unsigned long size: This is the size of the data to be encrypted. This size is denoted in number of Bytes to be encrypted. To decrypt, the function is SEALDecrypt(UInt16 refNum, SEAL_CTX * keyctx, unsigned char * input, unsigned char * output, int size) and the parameters are the same. NOTE: The user is responsible in deallocating any memory created for the input and output strings. Also the user is responsible to call SEALClean afterwards. 5. After you finished working with SEAL. You need to call SEALClean() because of the limitted memory in the PalmOS for applications (3.25KB), it was not a good idea to store statically all the information about the context for SEAL. That is why in SEALInit, we allocate some memory and the first 1024 B of Keystream. SEALClean(UInt16 refNum, SEAL_CTX * keyctx) has the following parameters: UInt16 refNum: The reference number to SEAL Library. SEAL_CTX * keyctx: The context for SEAL. 6. How to Close the Library? You can close the library when you finished. This is accomplished via: error = SEALClose(SEALLibRefNum, &numapps); // check for erros in the Close() routine if (numapps == 0) SysLibRemove(SEALLibRefNum); We suggest you include this code in the StopApplication() function or your function used to handle the case of closing the application.