//**************************************************************************** // fotplib.hpp // Contains functions for handling one-time pad (OTP) files. // // Notice // Copyright ©1995-97, David R. Tribble. // // This source code is copyrighted. Distribution of this source code is // granted, provided that this copyright notice remains attached to the // source code, and that adequate acknowledgement is given to the // original author. // // History // 1.00 1995-05-03 dtribble. // First cut. // 1.01 1995-06-27 dtribble. // Renamed "fotplib.h" to "fotplib.hpp". #ifndef fotplib_hpp #define fotplib_hpp 101 // Identification #define FOTPLIB_ID_VERS "1.01" #define FOTPLIB_ID_DATE "1995-05-27" #ifndef NO_H_IDENT static const char id_fotp_h[] = "@(#)" FOTPLIB_ID_DATE " " FOTPLIB_ID_VERS " " __FILE__; #endif // System includes #include // Local includes #include "osdefs.h" // Manifest constants #define OTP_BLKSZ (4 * 1024) // OTP file block size // Feedback mode types #define OTP_FEEDBK_ECB 0 // ECB, none #define OTP_FEEDBK_CBC 1 // CBC, cipher block chaining #define OTP_FEEDBK_PBC 2 // PBC, plaintext block chaining #define OTP_FEEDBK_CFB 3 // CFB, cipher feedback #define OTP_FEEDBK_OFB 4 // OFB, output feedback #define OTP_FEEDBK_PFB 5 // PFB, plaintext feedback //---------------------------------------------------------------------------- // OTP file info #define OTP_VERS 100 // Struct version #define OTP_MAGIC 0x6FCB // Struct magic number class otp_file { private: unsigned short o_magic; // Magic number short o_vers; // Struct version public: const char * o_fname; // File name FILE * o_fp; // File pointer long o_off; // Current offset unsigned char o__r[64-12]; // Reserved, zero unsigned char o_data[OTP_BLKSZ]; // Current data block public: otp_file(); otp_file(const char *fname); ~otp_file(); private: void init(); public: int open(const char *fname); int close(); int seek(long off); int readblk(); }; #endif // fotplib_hpp // End fotplib.hpp