The OpenSSL API for symmetric cryptography is vast. Each cipher has its own set of routines for encryption and decryption. Fortunately, OpenSSL also provides a single API that serves as an interface to all symmetric encryption algorithms: the EVP interface, which can be accessed by including openssl/evp.h. The EVP API provides an interface to every cipher OpenSSL exports. Before using the EVP interface, we must know how to get a reference to the different ciphers we may wish to use. OpenSSL represents ciphers as data objects that generally get loaded behind the programmer's back. When you wish to use a particular cipher, you simply request a reference to the object associated with that cipher. There are two common methods for doing this. First, OpenSSL provides a method for each cipher in each mode of interest for that cipher, which loads the cipher data object into memory if necessary. For example, we can use the following code to get a reference to the Blowfish-CBC cipher object:
EVP_CIPHER *c = EVP_bf_cbc( );
Second, OpenSSL provides the function
, which returns the appropriate cipher object
given a string representation of the cipher configuration, or
NULL if no matching cipher is found. This function
can be used only on cipher configurations that have previously been
loaded. You can load all symmetric ciphers with the call
, which takes no parameters.
will also do the trick, ...