OpenSSL BIO Series 1 --- Abstract IO Interface

zhaozj2021-02-16  57

Bio- Abstract IO interface

(Author: DragonKing Mail: wzhah@263.net Posted: http: //gdwzh.126.com openssl professional forum)

In fact, there are many interfaces, with a universal function interface, mainly controlled in the Bio_Method's unloading function control,

I prelimated, there are about 14 kinds, including 6 Filter types and 8 Source / Sink types.

BIO is an application interface that covers many type I / O interface details at the bottom layer. If you use BIO in the program, you can transparently connect with SSL connections, non-encrypted network connections, and file IO.

There are two uncommon BIO interfaces, one is a source / sink type, one is a Fileter type.

As the name, Source / Sink type BIO is the data source or data target (I don't know how to translate SINK, according to Shuimu Liaojz, usually the synonym of Destination (goal), everyone understands, huh, huh, huh), for example, Sokect BIO and file BIO.

The Filter Bio is converted from one BIO to another BIO or application interface. During the conversion process, these data may not modify (such as information summary BIO) or conversion. For example, in the encrypted BIO, if the write operation, the data is encrypted. If it is a read operation, the data will be decrypted.

BIO can be connected to become a BIO chain (single BIO is a special case of a Bio chain), as follows is the structure definition of the BIO, you can see it has up and down:

Struct Bio_ST

{

BIO_METHOD * METHOD;

/ * Bio, Mode, Argp, Argi, Argl, Ret * /

Long (* Callback) (Struct Bio_st *, Int, Const Char *, INT, long, long);

Char * cb_arg; / * first argument for the callback * /

Int init;

Int shutdown;

INT flag; / * Extra Storage * /

Int retry_reason;

Int Num;

Void * PTR;

Struct Bio_st * next_bio; / * use by filter bios * / bio

Struct Bio_st * prev_bio; / * buy by filter bios * / bio

INT References;

Unsigned long num_read;

UNSIGNED Long Num_Write;

Crypto_ex_data ex_data;

}

A Bio chain typically includes a Source Bio and one or more Filter BIOs, and the data is read or written from the first BIO, and then via a series of BIOs to the output (usually a source / sink bi).

Note: This is based on OpenSSL's Bio.Pod translation and according to my own understanding, I will slowly tell the details of BIO, I hope everyone will work together.

转载请注明原文地址:https://www.9cbs.com/read-24031.html

New Post(0)