Linux system OpenSSL is a set of password library system, so Linux system will use OpenSSL to add encryption algorithm to OpenSSL. This article will introduce Linux's skills for adding custom encryption algorithm to OpenSSL.
I. Introduction
This article introduces the custom algorithm EVP_ssf33 as an example to introduce the method of adding a custom encryption algorithm in OpenSSL
II. Steps
1, modify crypto /object /objects.txt, registration algorithm OID, as follows:
rsadsi 3 255: SSF33: ssf33
2, enter the directory: crypto /object /, execute the following command , the declaration of the generated algorithm
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;
}< Br>
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;
}
#endif Previous12Next Total 2 Pages
buffer and cache are the cache of the Linux server, and the swap partition occupanc
Ubuntu sudo command is mainly used to improve account permissions, which can save time and improve t
The less command in Linux is mainly used to browse the contents of the file, similar to the usage of
We all know that the ls command is mainly used to display the contents of the curre
Ubuntu tips for installing Visual Studio Code
What should I do if there are garbled characters in Linux Chinese characters?
Linux system Dalvik heap memory management and recycling introduction
What is the difference between the Linux command rmdir and rm?
CentOS 6.0 manual upgrade to CentOS 6.2 method
How can I use email to send emails under Linux lnmp?
How to remove the plus sign after the Linux Kernel version number?
How to install and use Sphinx in Linux system
How to open a file in a terminal using Linux commands
How to configure the IP and host name of the CentOS7 system
Linux system how to configure rdate time server
How to use Linux to clear Bash environment variables with commands
Operate Windows 7 Recycle Bin in the taskbar notification area
Vista built-in game for no reason to lose the solution
Format flash in NTFS format in Windows
WinXP taskbar clock disappears a variety of solutions coup
Teach you how to set a password that is safe enough.
Upgrade win10 0xc0000017 error how to do
How to achieve automatic page up and down effect of the mouse
Windows7 system to modify the taskbar icon size method (graphic tutorial)