OpenSSL source code introduction

The openssl source code is mainly composed of eay library , ssl library , tool source code , example source code and test source code .
An eay library is a basic library function that provides many functions. The source code is placed in the crypto directory. Includes the following:
1. asn.1 DER encoding and decoding (crypto/asn1 directory), which includes the encoding and decoding of basic asn1 objects and the most basic encoding and decoding functions such as digital certificate requests, digital certificates, CRL revocation lists, and PKCS8. These functions are mainly implemented through macros.
2. Abstract IO (BIO, crypto/bio directory), the functions in this directory abstract various input and output, including files, memory, standard input and output, socket and SSL protocols, etc.
3. Large number operations (crypto/bn directory), the files in this directory implement various large number operations. These large number operations are mainly used for key generation and various encryption and decryption operations in asymmetric algorithms. In addition, a large number of auxiliary functions are provided for users, such as conversion between memory and large numbers.
4. Character cache operation (crypto/buffer directory).
5. Read the configuration file (crypto/conf directory), the main configuration file of openssl is openssl.cnf. The functions in this directory implement the read operation of configuration files in this format.
6. DSO (Dynamic Shared Object, crypto/dso directory), the files in this directory mainly abstract the dynamic library loading functions of various platforms and provide users with a unified interface.
7. Hardware engine (crypto/engine directory), hardware engine interface. If users want to write their own hardware engine, they must implement the interface specified by it.
8. Error handling (crypto/err directory), when an error occurs in the program, openssl can display each error in the form of a stack. There are only basic error handling interfaces in this directory, and specific error information is provided by each module. The files dedicated to error handling in each module are generally *_err..c files.
9. Encapsulation of symmetric algorithm, asymmetric algorithm and digest algorithm (crypto/evp directory).
10. HMAC (crypto/hmac directory), which implements a MAC based on a symmetric algorithm.
11. Hash table (crypto/lhash directory), which implements the hash table data structure. Many data structures in openssl are stored in hash tables. Such as configuration information, ssl session and asn.1 object information.
12. Digital certificate online authentication (crypto/ocsp directory), which realizes the functions of encoding and decoding the ocsp protocol and calculating the validity of the certificate.
13. PEM file format processing (crypto/pem), used to generate and read various PEM format files, including various keys, digital certificate requests, digital certificates, PKCS7 messages and PKCS8 messages.
14. pkcs7 message syntax (crypto/pkcs7 directory), which mainly implements the construction and parsing of PKCS7 messages;
15. pkcs12 personal certificate format (crypto/pckcs12 directory), which mainly implements the construction and analysis of pkcs12 certificates.
16. Queue (crypto/pqueue directory), which implements the queue data structure, mainly used for DTLS.
17. Random number (crypto/rand directory), realizes pseudo-random number generation, and supports user-defined random number generation.
18. Stack (crypto/stack directory), which implements the stack data structure.
19. Thread support (crypto/threads), openssl supports multi-threading, but users must implement related interfaces.
20. Text database (crypto/txt_db directory).
21. x509 digital certificate (crypto/x509 directory and crypto/x509v3), including digital certificate application, digital certificate and CRL construction, parsing and signature verification and other functions.
22、对称算法(crypto/aes、crypto/bf、crypto/cast、ccrypto/omp和crypto/des等目录)。
23、非对称算法(crypto/dh、crypto/dsa、crypto/ec和crypto/ecdh)。
24、摘要算法(crypto/md2、crypto/md4、crypto/md5和crypto/sha)以及密钥交换/认证算法(crypto/dh 和crypto/krb5)。
 
二 ssl库所有源代码在ssl目录下,包括了sslv2、sslv3、tlsv1和DTLS的源代码
各个版本基本上都有客户端源码(*_clnt.c)、服务源码(*_srvr.c)、通用源码(*_both.c)、底层包源码(*_pkt.c)、方法源码(*_meth.c)以及协议相关的各种密钥计算源码(*_enc.c)等,都很有规律。
 
三 工具源码主要在crypto/apps目录下,默认编译时只编译成openssl(windows下为openssl.exe)可执行文件。该命令包含了各种命令工具。此目录下的各个源码可以单独进行编译。
 
四 范例源码在demo目录下,另外engines目录给出了openssl支持的几种硬件的engines源码,也可以作为engine编写参考。
 
五 测试源码主要在test目录下。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326917822&siteId=291194637