CsCrypto  1.0.1
API and Library Design

The CsCrypto API is divided into three layers: driver layer, context layer, and one which provides high-level cryptographic operations.

Driver Layer

At the lowest layer are drivers and these consist of source code which will be linked into your application when the driver is enabled at build time. A driver can wrap one or more external libraries or implement the cryptographic operations directly. Although you can develop your own external library we strongly advise only using a well tested and industry standard library. CsCrypto comes with drivers to support OpenSSL and Botan.

If you are writing a new driver it must conform to a specific interface which is defined by CsCrypto. There are different interfaces for different categories of operation (e.g. hash functions and symmetric encryption). Each interface defines a context type which is used by the other layers in CsCrypto. The context is responsible for maintaining the state of a cryptographic operation which is currently in progress.

Context Layer

The next layer provides operations for updating the context byte-for-byte. This layer can contain custom overloads for updating a context. As an example, you can add support to update a context with an object that contains a user defined type. This part of the CsCrypto API is loosely based on "Types Don't Know #" which is a C++ standardization proposal, document number D3980.

High-level Cryptographic Layer

This layer provides the API most developers will use in their C++ applications. This includes convenience functions for all currently supported hash functions as well as other user friendly functions that utilize the other two layers.

Hash Functions

For all drivers (OpenSSL and Botan) CsCrypto currently supports the following hash functions:

  • md4
  • md5
  • sha1
  • sha2-224, sha2-256, sha2-384 and sha2-512
  • sha3-224, sha3-256, sha3-384 and sha3-512

Symmetric Encryption

For all drivers CsCrypto supports encryption through AES with Cipher Block Chaining mode with PKCS#7 padding. The following ciphers are supported:

  • AES-128 (16 byte key)
  • AES-192 (24 byte key)
  • AES-256 (32 byte key)