Add a custom encryption algorithm and OpenSSL encryption algorithm to openssl.
 
I. Introduction
 
This document introduces how to add a custom encryption algorithm to OpenSSL by taking the custom algorithm EVP_ssf33 as an example.
 
 
 
Step 2
 
1. Modify crypto/object/objects.txt and register the algorithm OID as follows:
 
rsadsi 3 255    : SSF33     : ssf33
 
2. Go to the directory: crypto/object/and run the following command to generate the algorithm declaration.
 
perl objects.pl objects.txt obj_mac.num obj_mac.h
 
3. Add e_ssf33.c under crypto/evp/. The content is as follows:
 
#include <stdio.h>#include "cryptlib.h"#ifndef OPENSSL_NO_RC4    #include <openssl/evp.h>    #include <openssl/objects.h>    #include <openssl/rc4.h>        /* FIXME: surely this is available elsewhere? */    #define EVP_SSF33_KEY_SIZE      16        typedef struct    {        RC4_KEY ks; /* working key */    } EVP_SSF33_KEY;        #define data(ctx) ((EVP_SSF33_KEY *)(ctx)->cipher_data)        static int ssf33_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv,int enc);        static int ssf33_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl);        static const EVP_CIPHER ssf33_evp_cipher=    {        NID_ssf33,        1,        EVP_SSF33_KEY_SIZE,        0,        EVP_CIPH_VARIABLE_LENGTH,        ssf33_init_key,        ssf33_cipher,        NULL,        sizeof(EVP_SSF33_KEY),        NULL,        NULL,        NULL,        NULL    };        const EVP_CIPHER *EVP_ssf33(void)    {        return(&ssf33_evp_cipher);    }        static int ssf33_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc)    {        RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), key);            return 1;    }        static int ssf33_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)    {        RC4(&data(ctx)->ks,inl,in,out);            return 1;    }#endif4. Modify crypto/evp. h and add the algorithm declaration as follows: 
const EVP_CIPHER *EVP_ssf33(void);
5. Modify crypto/evp/c_allc.c and use EVP_add_cipher to register the encryption function in the OpenSSL_add_all_ciphers function, as shown below: 
EVP_add_cipher(EVP_ssf33());
 
6. Modify crypto/evp/Makefile as follows:
 
 
7. Complete
 
 
 
Reference: http://blog.csdn.net/force_eagle/article/details/794856