User Guide: Header Files

From Crypto++ Wiki
Jump to navigation Jump to search

Crypto++ implements a large number of cryptographic schemes that have similar properties and behavior, but are largely independent from each other.

Consequentially, Crypto++ defines a number of common base classes from which most of the algorithm implementations inherit: you will encounter these classes in all programs that use Crypto++. Often, the headers in which these basic abstractions are declared do not have to be included explicitly, as they are automatically included in the more specific header files.

On the other hand, each separate algorithm that you need to implement is usually declared in its own header file that you need to include explicitly. Exactly which header file you need to include is sometimes obvious, and sometimes not. For the cases when it is not, this section describes the most important header files in Crypto++.

As a matter of convenience, we will divide Crypto++ header files into the following groups:

Crypto++ Infrastructure

Crypto++ Infrastructure Header Files:

Header file Description

Provides basic abstractions for the Crypto++ library. These include: Exception, BufferedTransformation, BlockTransformation, StreamCipher, RandomAccessStreamCipher, RandomNumberGenerator, HashTransformation, MessageAuthenticationCode, and public key crypto base classes.

If Crypto++ had a most important header file, then cryptlib.h would be it. Nearly all classes defined by Crypto++ derive from base classes defined in cryptlib.h. When you need to figure out how to use one of the derived classes, your best bet is to find the relevant base class in cryptlib.h.


Provides additional input/output base classes (derived from BufferedTransformation): Filter and derivatives, Sink and derivatives, Source and derivatives.

filters.h may be the second most important header file in Crypto++. A large number of classes in Crypto++ derive from Filter, which is an especially useful type of BufferedTransformation because of its attachment functionality. In order to make elegant and efficient use of Crypto++, you need to be acquainted with the Filter class, as well as derived classes such as StringSource, StringSink, FileSource and FileSink (declared in files.h).

oids.h Defines specific object identifiers (OIDs) that are needed by or can be used on various classes throughout the library.
files.h Defines classes FileStore, FileSource and FileSink (derived from Store, Source and Sink).
network.h Defines base classes NonblockingSource, NonblockingSink; base classes NetworkReceiver, NetworkSender; and finally, NetworkSource and NetworkSink.
socketft.h Encapsulates network sockets and provides Crypto++ source and sink classes for them. The following types are defined: Socket, SocketSource, SocketSink. Support for Berkeley-style as well as Windows-style sockets is provided.
misc.h A bunch of bit and byte manipulating functions like BytePrecision(), bitReverse(), etc. Also defines template class SecBlock, a somewhat secure memory management class used for rudimentary protection of sensitive data in Crypto++.
smartptr.h Definitions for various types of smart pointer types used in Crypto++: member_ptr, value_ptr, clonable_ptr, counted_ptr, vector_member_ptrs.

Data Manipulation

Data Manipulation Header Files:

Header file Description
base64.h Provides classes Base64Encoder and Base64Decoder, both derived from Filter.
hex.h Provides classes HexEncoder and HexDecoder, both derived from Filter.
gzip.h Provides compression and decompression classes Gzip and Gunzip. Both classes inherit indirectly from Filter.
zlib.h Provides compression and decompression classes ZlibCompressor and ZlibDecompressor. Both classes inherit indirectly from Filter.

All classes provided in the above header files are very much alike, hence only base64.h is discussed as an example.

Random Number Generation

Random Number Generation Header Files:

Header file Description
randpool.h Defines RandomPool, a particularly useful type of RandomNumberGenerator. Given a quality random seed, this class uses hashing to provide virtually unlimited amounts of cryptographically strong pseudo random data.
osrng.h Encapsulates platform-specific hooks for obtaining quality random data (classes NonblockingRng and BlockingRng). Provides AutoSeededRandomPool, a derivative of RandomPool that seeds itself automatically using BlockingRng or NonblockingRng, whichever is available.

Hash Functions and MACs

Hash Function and MAC Header Files:

Header file Description
sha.h Defines classes to implement various types of the SHA hash function: class SHA for SHA-1 and classes SHA256, SHA384 and SHA512 for SHA-2.
ripemd.h Provides the RIPEMD160 class, implementing European Union's RIPEMD-160 hash function.
hmac.h Defines HMAC, a one-way hash function MAC.
trunhash.h Defines TruncatedHashTransformation, which, enveloped around a regular hash module, produces a shorter message digest; and class NullHash, a hash module that does nothing - that is, has a zero-length digest.

See also: HashTransformation.

Block Ciphers

Block Cipher Header Files:

Header file Description
default.h Defines DefaultEncryptor, DefaultDecryptor, DefaultEncryptorWithMAC and DefaultDecryptorWithMAC. These classes currently provide a complete default implentation of Triple-DES encryption, including passphrase mashing, IV generation, block chaining (CBC) and message integrity (...WithMAC variants only).
modes.h Provides interfaces for use of block ciphers in CFB mode (classes CFBEncryption and CFBDecryption), OFB mode (class OFB), Counter mode (class CounterMode), and PGP CFB mode (classes PGP_CFBEncryption and PGP_CFBDecryption).
cbc.h Provides interfaces for use of block ciphers in raw CBC mode (classes CBCRawEncryptor and CBCRawDecryptor), padded CBC mode (classes CBCPaddedEncryptor and CBCPaddedDecryptor) and CBC with ciphertext stealing mode (classes CBC_CTS_Encryptor and CBC_CTS_Decryptor).
aes.h Provides typedefs AESEncryption and AESDecryption mapping to RijndaelEncryption and RijndaelDecryption classes. [#indirectly *]
rijndael.h Defines RijndaelEncryption and RijndaelDecryption classes. [#indirectly *]
twofish.h Defines TwofishEncryption and TwofishDecryption classes. [#indirectly *]
blowfish.h Defines BlowfishEncryption and BlowfishDecryption classes. [#indirectly *]
idea.h Defines IDEAEncryption and IDEADecryption classes. [#indirectly *]
cast.h Defines classes for CAST with a 32..128-bit key (CAST128Encryption, CAST128Decryption) and with a 128...256-bit key (CAST256Encryption, CAST256Decryption). [#indirectly *]

Provides classes for:

  • regular DES (DESEncryption and DESDecryption); [#indirectly *]
  • two-key triple DES (DES_EDE2_Encryption and DES_EDE2_Decryption); [#indirectly *]
  • three-key triple DES (DES_EDE3_Encryption and DES_EDE3_Decryption); [#indirectly *]
  • DESX (DES_XEX3_Encryption and DES_XEX3_Decryption). [#indirectly *]
  • These classes should not be used directly, but rather indirectly via one of the block-cipher mode classes.

Stream Ciphers

Stream Cipher Header Files:

Header file Description
arc4.h Defines class ARC4 - implementation of a stream cipher compatible with RSA Data Security's RC4 algorithm. The name ARC4 is used because the name RC4 is trademarked. The class inherits from StreamCipher and RandomNumberGenerator.
seal.h Defines class SEAL; inherits from RandomAccessStreamCipher and RandomNumberGenerator.

Public Key Cryptosystems

Public Key Cryptosystem Header Files:

Header file Description


  • classes RSAFunction and InvertibleRSAFunction, representing the RSA public key and the RSA private key, respectively;
  • typedefs for RSA encryption with OAEP padding scheme (RSAES_OAEP_SHA_Encryptor, RSAES_OAEP_SHA_Decryptor);
  • typedefs for RSA encryption with PKCS v1.5 padding scheme; (RSAES_PKCS1v15_Encryptor, RSAES_PKCS1v15_Decryptor);
  • typedefs for RSA signature as per PKCS 1.5 (RSASSA_PKCS1v15_xxx_Signer and RSASSA_PKCS1v15_xxx_Verifier, where xxx is either SHA, MD5 or MD2).

Defines class DH, providing an interface for Diffie-Hellman key agreement.



  • classes GDSASigner and GDSAVerifier, representing a generalized-DSA private and public key, respectively;
  • classes DSAPrivateKey and DSAPublicKey, representing a classic-DSA private and public key, respectively.


  • class ECParameters, representing parameters for an elliptic curve with built-in support for recommended parameters;
  • class ECDHC, providing an interface for Elliptic Curve Diffie-Hellman with Cofactor Multiplication key agreement;
  • class ECMQVC, providing an interface for Elliptic Curve Menezes-Qu-Vanstone with Cofactor Multiplication key agreement;
  • classes ECPublicKey and ECPrivateKey, representing a raw elliptic curve public and private key, respectively;
  • classes ECSigner and ECVerifier, representing an EC private/public key, respectively, with message signing/verification capabilities;
  • classes ECEncryptor and ECDecryptor, representing an EC public/private key, respectively, with support for the ECIES encryption scheme.

Defines classes ElGamalEncryptor and ElGamalDecryptor, representing an El-Gamal public and private key, respectively.


Defines class MQV, providing an interface for Menezes-Qu-Vanstone key agreement.


Defines classes RWSigner and RWVerifier, representing a Rabin-Williams private and public key, respectively.


Defines class XTR_DH, providing an interface for XTR Diffie-Hellman key agreement.

To find other topics in the User Guide, visit Category:User Guide.