SECCryptoFile Class

class SECCryptoFile: public CFile

SECCryptoFile is derived from CFile, and provides encryption and decryption services for data written to and from the file.

Defined in: CRYPTFIL.H

Comments

Two modes are provided, Electronic Codebook (ECB) and Output Feedback (OFB).

ECB is moderately secure, and allows random access reads and writes. However, application of sophisticated cryptographic methods allows much easier recovery of the contents of each of two or more files encrypted with the same password. Encourage your users to change their passwords frequently, or implement another layer of key management.

OFB is much more secure, but file access is unidirectional and sequential only. Therefore, an SECCryptoFile opened in OFB may be CFile::modeRead or CFile::modeWrite, but not both. The seek functions are also not available.

See the TEST32 sample in the \SAMPLES\TOOLKIT\STANDARD\UTILITY\CRYPT directory for a demonstration of this class.

enum  eDir

Encryption directions

enum  eMode

Encryption methods

Class Members

Creation/Initialization

SECCryptoFile( const TCHAR *pszFileName, const TCHAR *pszPassword, UINT nOpenFlags, eMode CipherMode )

Constructs a SECCryptoFile object.

SECCryptoFile( int hFile, const TCHAR *pszPassword, eMode CipherMode )

Constructs a SECCryptoFile object.

SECCryptoFile()

Constructs a SECCryptoFile object.

Operations

BOOL  Open( const TCHAR *pszFileName, const TCHAR *pszPassword, UINT nOpenFlags, eMode CipherMode, CFileException *p = NULL )

Opens an SECCryptoFile with a path, password, direction and

UINT  Read( void FAR *pBuf, UINT nCount )

Reads a number of bytes from the file and decrypts them.

UINT  ReadHuge( void FAR *pBuf, DWORD nCount )

Reads a number of bytes from the file and decrypts them.

void  Write( const void FAR *pBuf, UINT nCount )

Encrypts and then writes a number of characters to the file.

void  WriteHuge( void FAR *pBuf, DWORD nCount )

Encrypts and then writes a number of characters to the file.

long  Seek( long lOff, UINT nFrom )

Moves to a specified location in the file.

void  SeekToBegin( void )

Moves to the beginning of the file.

void  SeekToEnd( void )

Moves to the end of the file. Only usable in ECB mode.

Protected data members

SECCryptoBlackBox  m_bb

En/decryption engine object.