Saving, retrieving, and clearing encryption keys on Palm OS

On Palm OS, applications are automatically shut down by the system whenever a user switches to a different application. Therefore, if you encrypt an UltraLite database on Palm OS, the user is prompted to re-enter the key each time they switch back to the application.

To avoid re-entering the encryption key
  1. Save the encryption key in dynamic memory as a Palm feature.

    Features are indexed by creator and a feature number. Applications can then pass in their creator ID or NULL, along with the feature number or NULL, to save and retrieve the encryption key.

  2. Program the application to retrieve the key upon re-launch.

    Note

    Because the encryption key is cleared on any reset of the device, the retrieval of the key will fail at this time. The user is prompted to re-enter the key in this case.

    The following sample code (embedded SQL) illustrates how to save and retrieve the encryption key:

    startupRoutine() {
       ul_char buffer[MAX_PWD];
    
       if( !ULRetrieveEncryptionKey(
              buffer, MAX_PWD, NULL, NULL  ) ){
          // prompt user for key
          userPrompt( buffer, MAX_PWD );
    
          if( !ULSaveEncryptionKey( buffer, NULL, NULL ) ) {
             // inform user save failed
          }
       }
    }
  3. Use a menu item to clear the encryption key and thereby secure the device.

    The following code sample shows the method to accommodate this goal:

    case MenuItemClear
        ULClearEncryptionKey( NULL, NULL );
        break;
See also