Loading…

Kryptel/Java

ISilverKeyExtractor interface

Declaration

package com.kryptel.silver_key;

public interface ISilverKeyExtractor {
  interface IMessage {
    boolean Show(String parcelTitle, String message);
  }

  class ParcelStatistics {
    // Parcel statistics
    public int nDirs, nFiles;
    public long totalBytes;
    // Data extracted
    public int nDirsCreated, nFilesCreated;
    public long bytesWritten;
  }

  void ExtractData(String targetDir, String parcelPath, Object arg,
                   IKeyCallback keyFunc,
                   IProgressCallback progressFunc,
                   IReplaceCallback replaceCallback,
                   IMessage msgCallback,
                   INotification notificationCallback) throws Exception;

  ParcelStatistics GetExtractionStatistics() throws Exception;
}

IMessage interface

interface IMessage {
  boolean Show(String parcelTitle, String message);
}

Parcel may contain various text messages – an unencrypted parcel description and/or private encrypted messages. In order to show them, the client should implement this interface.

The typical impplementation of Show function opens a dialog window with a message box and two buttons: Next and Abort. The string parcelTitle is displayed in the dialog window's title bar.

The function should return true to proceed with decryption, or false to abort it. If it returns false, the decryptor throws UserAbortException.

ParcelStatistics structure

class ParcelStatistics {
  // Data present
  public int nDirs, nFiles;
  public long totalBytes;

  // Data extracted
  public int nDirsCreated, nFilesCreated;
  public long bytesWritten;
}

This structure contains decryption statistics. Values nDirs, nFiles, and totalBytes are from COMMAND_PROGRESS script element; these data are provided by the parcel creator. Values nDirsCreated, nFilesCreated, and bytesWritten are the actual extraction statistics provided by the decryptor. Creation and decryption statistics are not always match because some files may be skipped during decryption (for example, because they are already exist).

Old parcel creators did not support COMMAND_PROGRESS script command. In this case the data present variables will contain -1.

Description

ISilverKeyExtractor interface, or rather its ExtractData function is the primary tool for decryption Silver Key parcels.

Use Parcel Analyzer program included in the Silver Key product for partial parcel decryption.

ExtractData

void ExtractData(String targetDir, String parcelPath, Object arg,
                 IKeyCallback keyFunc,
                 IProgressCallback progressFunc,
                 IReplaceCallback replaceCallback,
                 IMessage msgCallback,
                 INotification notificationCallback) throws Exception;

This finction fully extracts the specified parcel. Five callback interfaces make it look a bit complicated, but only IKeyCallback is mandatory.

targetDir
This directory should be used as TARGET_ASK_USER target (see Targets class for a discussion of targets). This target is the most used one, and almost always it is the only target in the parcel. The client may 1) ask the user where to decrypt (recommended), or 2) pass the current directory (not recommended), or 3) use a dedicated decryption folder. This argument must not be null; if the parcel does not contain TARGET_ASK_USER items, pass any (or empty) string.
parcelPath
The path to the parcel to be decrypted. Must not be null.
arg
This argument is passed to the callback interfaces as is. The extractor neither uses nor checks it. It usually refers to client-defined execution context and may be null if the callbacks are context-independent.
keyFunc
Refers to client's class implementing IKeyCallback interface. This is a mandatory argument as the extractor must have the key to decrypt the parcel.
progressFunc
Pointer to a class implementing IProgressCallback (or, more likely, extending ProgressCallback class). Specify null if no progress bar is needed.
replaceCallback
Pointer to a class implementing IReplaceCallback. If null is specified, the extractor quietly replaces existing files.
msgCallback
Points to a class implementing the local ISilverKeyExtractor.IMessage interface (see above). If null is specified, all parcel messages will be quietly skipped.
notificationCallback
Refers to a class implementing INotification interface. May be null; in this case short notifications will not be shown.

See also Decrypting a Parcel example.

GetExtractionStatistics

ParcelStatistics GetExtractionStatistics() throws Exception;

Returns ParcelStatistics structure (see above) with decryption statistics. The function should naturally be called after calling ExtractData (no decryption statistics if there was no decryption).