SDeanComponents

By Sarah Dean (sdean12@sdean12.org)
http://www.SDean12.org/
Last updated: 18th March 2007

Contents



Summary

Current version: v2.60.00

SDeanComponents currently contains the following Delphi packages:

Package Version Description
SDeanUtils v1.4.0 SDeanUtils: Sarah Dean - General Utility Classes and Components
Includes file and directory iterators for walking through directory structures/filesytems, system tray icon (aka tasktray icon), endian integers, named pipes, wrappers for Windows Vista's TaskDialog API, etc
SDeanSecurity v2.5.0 Includes:
  • HMAC
  • AFSplitter
  • Keyboard Entry Dialog
  • MouseRNG
  • MouseRNG Random Data Capture Dialog
  • MSCryptoAPI
  • Shredder
Hash v2.0.0 Hash: Hash algorithms:
  • GOST R 34.11-94,
  • MD2,
  • MD4,
  • MD5,
  • RIPEMD-128,
  • RIPEMD-160,
  • RIPEMD-256,
  • RIPEMD-320,
  • SHA,
  • SHA-1
  • SHA-256
  • SHA-384
  • SHA-512
  • Tiger
(All of which inherit from THash)
OTFE v1.1.0 OTFE: Base class for On-The-Fly Encryption components
OTFEBestCrypt v2.0.0 OTFE: BestCrypt Delphi Component
OTFECrossCrypt
v1.0.0
OTFE: CrossCrypt Delphi Component
OTFEE4M
v1.0.2 OTFE: E4M Delphi Component
OTFEFreeOTFE
v1.60.0 OTFE: FreeOTFE Delphi Component
OTFEPGPDisk v1.0.0 OTFE: PGPDisk Delphi Component
OTFEScramDisk v2.0.0 OTFE: ScramDisk Delphi Component
OTFETrueCrypt
v1.1.0
OTFE: TrueCrypt Delphi Component
OTFEUnified v2.0.0 OTFE: Unified OTFE Delphi Component
OTFEDriveCrypt
n/a
OTFE: DriveCrypt Delphi Component
Do not use - development shelved (see below)
OTFEStrongDisk
n/a OTFE: StrongDisk Delphi Component
Do not use - under development (see below)

Additionally, the following test applications to demo/test the above components are included:


Licence and Legal Stuff


Download

The latest version of this software can be downloaded from: http://www.SDean12.org/Download.htm

Component Specific Notes and Issues

SDeanUtils

SDUGeneral

SDUCreateLargeFile
Files created with this function consist of the $00 character, repeated.

SDUFileIterator

Note that setting "FileMask" to a string including a path (e.g. "C:\test\*.*"), the path will be stripped off and "Directory" will be set to that value, while "FileMask" is set to just the mask ("*.*", in this example)

SDUSystemTrayIcon

Usage of this component should be fairly obvious; it provides full functionality with respect to creating, animating, etc system tray icons.

Note that balloon messages will not appear with early versions of MS Windows which include an older shell (shell32.dll; e.g. pre-Windows 2000)

This component may be compiled with the either one of the following parameters for debug purposes:

GEXPERTS - Send debug output to the GExpers debug window. Requires GExperts to be installed; see http://www.GExperts.org/
SDUSYSTEMTRAYICON_DEBUG - Send debug output to file using SDULogger object (see source for output filename)

SDUSystemTrayIcon includes support for "minimize to system tray icon" functionality. In order to support "close to system tray icon" functionality, certain minor code changes are required to the form which this must apply for; see comments in the "Min/Close to System Tray" test application source for details; specifically those below the "Functions required for close/minimize to system tray follow" source code comment. These changes are required in order to override the default operations carried out when Close() is called, in order to minimise the form to the system tray instead of closing it.

Note that when MinToIcon is set on an SDUSystemTrayIcon, if WindowState is set to wsMinimized on the form it is placed on, the normal WidowState behavious will occur; i.e. the form is minimized to the desktop; use Application.Minimize to minimize the application completely.

Named Pipes

This software is currently under development - do not use.

SDeanSecurity

HMAC

This file contains a number of functions that may be called to generate HMAC values using a number of different hashes including SHA-1, MD5, SHA-512, Tiger - any hash that has an implementation based on THash.

TMouseRNG

The height and width of this component should be set to a multiple of (2 to the power of BITS_PER_SAMPLE)

e.g.
If BITS_PER_SAMPLE is 1, then the width and height should be a multiple of 2
If BITS_PER_SAMPLE is 2, then the width and height should be a multiple of 4

If you want the component to have BorderStyle=bsSingle, then the window should be further increased in size by 2 pixels in both width and height.

If the component is not sized as shown above, you risk biasing the RNG.

At both design time and runtime, if the control is dynamically resized, then it will take care of the above rules and will automatically adjust itself appropriately. This however, does have the effect that the window may appear "jerky" when resized; especially for very large values of BITS_PER_SAMPLE (say, 4 or 5).

TMouseRNGDialog

This is a standard dialog that uses TMouseRNG. It is designed to be used in a similar manner as other standard dialogs supplied with Delphi (e.g. TOpenDialogTo, TFontDialog).

To use:
  1. Set "RequiredBits" to the number of random bits of data that are required (Note: This value gives the number of bits, not bytes of random data that will be captured)
  2. Call Execute(...)
  3. If the return value of the call to Execute(...) is TRUE, then call GetRandomData(...) to retrieve the random data captured.

TPasswordRichEdit

This is a standard TRichEdit component, but "PasswordChar" is exposed in the same manner as TEdit.

It should be noted that this control is intended for obscuring passwords from visual inspection only. In the same way as passwords entered into TEdit controls with PasswordChar set, passwords entered into TPasswordRichEdit can be "lifted" using tools such as "Password Spectator Pro".

AFSplitter

This is not a Delphi component, but library code intended to be used by applications.

This implementation reflects the AFSplitter as used by "cryptsetup"; the Linux LUKS encryption version, and as such it should be noted that a single bit change in split data will only change up to <hash algorithm's hash length> bits in the recovered data.

CryptoAPI

This is not a Delphi component, but library code intended to be used by applications.

 This library is fairly limited, and currenly only supports those interfaces required to generate random data.

Hash

No notes.

OTFE

The OTFE package is required in order to use the other OTFE components; it holds the base class on which they all depend.

OTFEBestCrypt

function Mount(volumeFilenames: TStringList; var mountedAs: string; readonly: boolean = FALSE): boolean;
This function will prompt the user for a password for each volume file instead of accepting one password, and applying it to all the volume files specified

Note to self (the following table is really only intended as a development aid to the author):

The following table lists the buffer sizes used by the BestCrypt Control Panel when carrying out various DeviceIOControl calls. The sizes shown are in hex.

In all cases, unless otherwise indicated, the buffer in is exactly the same as the buffer out (both in size, and memory location)

The "Driver Version" lists the version ID of the driver installed for each combination of BestCrypt release version/OS combination. The versions shown are:

BestCrypt version
OS
Driver Version
DeviceIOControl:
0x72001
(Driver version)
DeviceIOControl:
0x72005
(Get mounted disks mask)
DeviceIOControl:
0x72009
(Get disk info)
DeviceIOControl:
0x7200d
(Mount disk)
DeviceIOControl:
0x72011
(Disconnect disk)
DeviceIOControl:
0x72051
(??? - called on create/mount)
DeviceIOControl:
0x72061
(???)
v6.06
Windows Me
v2.31
(0x21F)
0x00b 0x010
(old struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014 0x01c in/0x200 out (this one not checked for)
v6.06
Windows XP
v2.14 (0x20E)
0x00b 0x010
(old struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014
0x01c in/0x200 out
(this one not checked for)
v6.07.2
Windows Me v2.41 (0x229)
0x00b 0x014
(new struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014 (this one not checked for) (this one not checked for)
v6.07.2 Windows XP v2.18
(0x212)
0x00b 0x014
(new struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014 0x01c in/0x200 out (this one not checked for)
v7.05
Windows Me v2.41
(0x229)
0x00b 0x014
(new struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014 (this one not checked for) (this one not checked for)
v7.05 Windows XP v3.18 (0x312)
0x00b 0x014
(new struct)
0x1b8
(old struct)
0x1b8
(old struct)
0x014 0x01c in/0x200 out (this one not checked for)
v7.10.4
Windows Me v2.42 (0x22A)
0x00b
0x014
(new struct)
0x1c0
(new struct)
0x1c0
(new struct)
0x014 (this one not checked for) 0x010
v7.10.4
Windows XP v3.30 (0x31E)
0x00b 0x014
(new struct)
0x1c0
(new struct)
0x1c0
(new struct)
0x014 0x01c in/0x200 out 0x010


The v6.07.2 release used for these tests was downloaded from Jetico's WWW site on the 24th September 2004
The v7.10.4 release used for these tests was downloaded from Jetico's WWW site on the 19th September 2004

OTFECrossCrypt

function Version(): cardinal; override;
function VersionStr(): string; override;
Note that the version ID returned by these functions will only be valid if a CrossCrypt volume is mounted. This is due to weirdness in CrossCrypt.

OTFEE4M

CAUTION!
If you have an application that uses this component that may still be running when the user shuts down/restarts their computer, it is important that you intercept the shutdown, and ensure that this components "Active" property to FALSE. Failure to do so could result in the user's computer freezing on shutdown as the component is still connected to the E4M driver (under Windows Me, at least).

function GetVolFileForDrive(driveLetter: char): string;
When getting filenames of mounted volumes under NT, the E4M driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "..." (or if the "filename" is not the name of a device, only the first 56 chars)

This is because under NT, the E4M driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

function GetDriveForVolFile(volumeFilename: string): char;
Calls to this function may return the wrong drive letter if there is more than one volume file mounted, and the first 56 chars (or 60 in the case of partitions) of two or more of the mounted volume filenames match the first 56 chars of "volumeFilename". In such a case, the drive letter to either one of these volumes may be returned.

This is because under NT, the E4M driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

function Dismount(volumeFilename: string; emergency: boolean = FALSE): boolean;
Calls to this function may dismount the wrong drive if there is more than one volume file mounted, and the first 56 chars (or 60 in the case of partitions) of two or more of the mounted volume filenames match the first 56 chars of "volumeFilename". In such a case, one of the matching volume filenames will have it's drive dismounted

This is because under NT, the E4M driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

The "Dismount" function that takes a drive letter as it's parameter works correctly, and it is recommended that this function should be used instead.

function Mount(volumeFilename: string; readonly: boolean = FALSE): char;
The "readonly" parameter is ignored (E4M does not support mounting volume files as readonly)

function Mount(volumeFilenames: TStringList; var mountedAs: string; readonly: boolean = FALSE): boolean;
The "readonly" parameter is ignored (E4M does not support mounting volume files as readonly)

function GetVolumeInfo(volumeFilename: string; info: pTOTFEE4MVolumeInfo): boolean;
Due to another limitation with the E4M driver, it is not possible to identify the cipher or hash details of a mounted volume that has not been mounted with the same instance of TOTFEE4M on which GetVolumeInfo(...) is being called, nor is it possible to determine the type of the volume if it is a ScramDisk/E4M/SFS volume file, although partitions can be identified as such.

OTFEFreeOTFE

Projects built with the conditional "FREEOTFE_DEBUG" defined will generate additional debug information.

An additional test application "OTFEFreeOTFEDetectLinuxSettings" is included for this component. This particular test app is not intended for general use; it was a quick 'n' dirty tool to detect the settings used in encrypting a Linux cryptoloop/dm-crypt volume, given the volumes password. Requires conditional "DETECT_LINUX" defined during compilation to use.

OTFEPGPDisk

The PGPDisk component was originally written for the version of PGPDisk supplied with PGP v6.0.2i. Because NAI appear to have changed all the APIs to PGPDisk, and don't appear to wanna talk to me about what's changed, the version of PGPDisk supplied with the commercial release of PGP v7.0.x does not work correctly with this component (mounted PGPDisks are misreported, etc)
function Version(): cardinal;
function VersionStr(): string;
The version number returned is (as with the other OTFE components) the version ID the driver identifies as. In the case of PGPDisk, this constant should be interpreted as an internal version number only, and has no meaning outside of PGPdisk.

function Mount(volumeFilename: string; readonly: boolean = FALSE): char;
The "readonly" parameter is ignored (the user can specify mounting as readonly when entering the password)

function Mount(volumeFilenames: TStringList; var mountedAs: string; readonly: boolean = FALSE): boolean;
This function will prompt the user for a password for each volume file instead of accepting one password, and applying it to all the volume files specified
Also, the "readonly" parameter is ignored (the user can specify mounting as readonly when entering the password)

OTFEScramDisk

Because the ScramDisk component is designed to clear all cached passwords immediatly after they are used, you cannot mount a volume using this component and then create an SKF file; in order to create a SKF file, you are required not to clear the cached passwords. Instead, you can use ScramDisk to mount the volumes, and then create any SKF files needed.

OTFETrueCrypt

property VersionHint: TTrueCryptVersionHint;
The TrueCrypt driver supplied with TrueCrypt v2.1 and v2.1a both identify as version 0x0210. Normally, this would not be too much of a problem, however the cypher IDs used by the driver changed between these two versions (Arrrrgh! It's a chore, but why can't people just update their version IDs when they update their software?!!).
As a direct result of this, when attempting to identify the driver version, the component will determine the version ID returned by the driver. In the case of v2.1 and v2.1a, the component will then proceed to further check the filesize of the TrueCrypt executable, comparing it against the filesize known to be in the different releases in order to find out which of the two versions it's working with. Setting this property to anything other than "tcvAuto" will skip this check, and the version you supply will be assumed.
If the version is incorrectly set, then the names of cyphers returned when getting volume information from the component may be incorrect, although it should be noted that this is largely a cosmetic issue, and has no impact on the rest of the component's functionality.

function Version(): cardinal;
This function will operate as per normal, however both TrueCrypt v2.1 and v2.1a will both be reported as 0x210.

function VersionStr(): cardinal;
This function will operate as per normal, however for TrueCrypt v2.1 and v2.1a, because the component cannot differentiate between these two versions: If the TrueCrypt executable as one of two known filesizes, this function will return either "v2.1" or "v2.1a". If the filesize cannot be determined, or does not match a known executable filesize, then "v2.1(???)" will be returned. If you set the "VersionHint" property to something other than "tcvAuto", then this filesize check will be skipped, and the version will be assumed to be that which you specified.

function GetVolFileForDrive(driveLetter: char): string;
When getting filenames of mounted volumes under NT, the TrueCrypt driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "..." (or if the "filename" is not the name of a device, only the first 56 chars)

This is because under NT, the TrueCrypt driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

function GetDriveForVolFile(volumeFilename: string): char;
Calls to this function may return the wrong drive letter if there is more than one volume file mounted, and the first 56 chars (or 60 in the case of partitions) of two or more of the mounted volume filenames match the first 56 chars of "volumeFilename". In such a case, the drive letter to either one of these volumes may be returned.

This is because under NT, the TrueCrypt driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

function Dismount(volumeFilename: string; emergency: boolean = FALSE): boolean;
Calls to this function may dismount the wrong drive if there is more than one volume file mounted, and the first 56 chars (or 60 in the case of partitions) of two or more of the mounted volume filenames match the first 56 chars of "volumeFilename". In such a case, one of the matching volume filenames will have it's drive dismounted

This is because under NT, the TrueCrypt driver does not return the full filename it is more than 63 chars long; instead it will return the first 60 chars, followed by "...". In the case of volume files (not partitions), the filename returned by the driver is prefixed with "/??/" which is stripped out by the component

Note: "Filename" in the above two paragraphs refers to the full filename, including the full path to the file.

The "Dismount" function that takes a drive letter as it's parameter works correctly, and it is recommended that this function should be used instead.

function Mount(volumeFilename: string; readonly: boolean = FALSE): char;
The "readonly" parameter is ignored (TrueCrypt does not support mounting volume files as readonly)

function Mount(volumeFilenames: TStringList; var mountedAs: string; readonly: boolean = FALSE): boolean;
The "readonly" parameter is ignored (TrueCrypt does not support mounting volume files as readonly)

OTFEUnified

CAUTION!
If you enable support for E4M, then: If you have an application that uses this component that may still be running when the user shuts down/restarts their computer, it is important that you intercept the shutdown, and ensure that this components "Active" property to FALSE. Failure to do so could result in the user's computer freezing on shutdown as the component is still connected to the E4M driver (under Windows Me, at least).

OTFEDriveCrypt

A modified TOTFEScramDisk. Development shelved indefinatly due to lack of DriveCrypt API documentation

OTFEStrongDisk

This component is currently under development. Current development is based on API documentation for StrongDisk v2, pending API information relating to later versions.

Development comment to self: strdsk.dll for StrongDisk v3 appears to require Language.dll be loaded - not was not the case in the earlier versions (v2.x?), it seems
 - IS IT THE CASE WITH STRONGDISK SERVER????


Credits

Full credit is given to Andy Jeffries at Kwik-Rite Development for writing the original TkrScramdisk, the basis of TOTFEScramDisk and the (now redundant) TEnhKrScramDisk.

Appendix A: OTFE Compatibility

The OTFE components have been tested for compatibility with the OTFE system/versions described in the table below.
Note that this table is not exhaustive, and only lists those versions which I have tested - other versions of the packages listed may very well work, provided there have been no driver API changes within the particular OTFE system.

OTFE System
Version
Comments
FreeOTFE
v2.00.00
Fully supported.
v1.60.00
Fully supported.
v1.50.00
Fully supported.
v1.00.00
Fully supported.
v00.58.00
Fully supported.
v00.59.00
Fully supported.
BestCrypt
v6.06 Fully supported.
v6.07.2 Fully supported.
v7.05 Fully supported.
v7.10.4
Fully supported.
v7.12.01
Fully supported.
CrossCrypt
v0.4.3
Fully supported, with minor cosmetic issue (CrossCrypt is slightly weird in that it will not report it's version number correctly unless it has one or more CrossCrypt volumes mounted.)
E4M
v2.00
Fully supported.
v2.02a
Fully supported.
PGPDisk
v6.0.2i
Fully supported (Note: This is the version of PGPDisk supplied with freeware version of PGP v6.0.2i)
ScramDisk
v2.02g
Fully supported.
v3.xx
Fully supported.
TrueCrypt


v1.0
Fully supported.
v2.0
Fully supported.
v2.1
Fully supported, with minor issue if the version ID cannot be determined (TrueCrypt v2.1 and v2.1a both identify themselves as version 0x0210 - but the cipher IDs changed between these versions! This issue has no effect on security, and can be easily eliminated if you use the component correctly)
v2.1a
Fully supported, with minor issue if the version ID cannot be determined (TrueCrypt v2.1 and v2.1a both identify themselves as version 0x0210 - but the cipher IDs changed between these versions! This issue has no effect on security, and can be easily eliminated if you use the component correctly)
v3.0a
Fully supported.
v3.1
Fully supported.
v3.1a
Fully supported.


Appendix B: Version History


Email me at: sdean12@sdean12.org

Return to the main page