First understanding of encryption technology

Recently, internal training was organized in the group. Each group member had to choose a topic to share. I chose the topic of encryption technology. Because of the needs of work, it is the first time to get in touch with and learn this knowledge; it is also because the learning is relatively shallow and rough, so I only shared some basic concepts and some applications, and did not involve specific algorithms.
I studied William Stallings. "Network Security Fundamental Applications and Standards (5th Edition)" [1]; I also checked a lot of information on the Internet, citing the information of some technology sharers, see the references for details, thank you here. There are unavoidable errors in the article, so please correct me.

1 Symmetric encryption
Symmetric encryption is also called conventional encryption, single-key encryption, and traditional encryption. A symmetric encryption scheme consists of five parts: the
Insert picture description heresender and receiver must obtain the key in a secure way and ensure the security of the key. The security of symmetric encryption depends on the confidentiality of the key rather than the confidentiality of the algorithm, and the message cannot be deciphered on the basis of known ciphertext and encryption/decryption algorithms.
1.1 Block cipher The
most commonly used symmetric encryption algorithm is a block cipher.
The plaintext is grouped and then encrypted; the block cipher processes a fixed-size plaintext input group, and generates a ciphertext group of the same size for each plaintext group. There are mainly the following types of
Insert picture description here
block ciphers : Many symmetric block encryption algorithms (including DES), whose structure was first described in detail by Horst Feistel of IBM in 1973. The basic principle is that the plaintext is divided into 2 groups, multiple iterations, each iteration uses a different subkey, and each subkey is generated from the original key. AES does not use the Feistel structure, but processes the entire data packet in parallel during each round of replacement and shift.

1.2 Stream ciphers
There is also a stream cipher for symmetric encryption algorithms. From the plaintext input stream bit by bit or byte by byte, use random number encryption to generate ciphertext output; compared with block cipher, stream cipher is faster and has less code.
RC4 (Rivest Cipher 4) is a widely used stream cipher. It is a stream cipher designed by Ron Rivest for RSA in 1987.
Stream ciphers with variable key sizes, using byte-oriented operations.
Stream cipher and block cipher, both of which can be used in almost all applications.
For applications that require encryption/decryption of data streams, such as data communication channels or browser network links, stream ciphers may be a better choice. For applications that deal with data packets, such as file transfers, emails, and databases, block ciphers may be more appropriate.

1.3 Block cipher working mode
Block cipher working mode For
example, such a cipher mode aes256-ctr, which means AES encryption algorithm, key length 256, working mode CTR;
why is there a working mode?
Block ciphers process one data packet at a time. For example, the AES algorithm has a fixed packet length of 128 bits.
For relatively long plaintext, it is necessary to divide the plaintext into multiple groups according to the packet length of the algorithm (sometimes the last group needs to be filled). That is, the block cipher algorithm describes how to encrypt a data block, and the block cipher working mode realizes how to encrypt multiple long data blocks through the block encryption algorithm. There are five common working modes of block ciphers: ECB, CBC, CFB, OFB and CTR. The following table summarizes these five working modes [4].
Insert picture description here
2 Asymmetric encryption
Asymmetric encryption belongs to the category of
public key cryptosystems. The idea of ​​public key cryptography was first publicly proposed by Diffie and Hellman in 1976 [DIFF76].
Two separate keys are used, called the public key and the private key.
The user generates a key pair, the public key is made public through distribution, and the private key is not distributed and kept by itself. At any time, users can change the private key and release the corresponding public key.
The requirements of public key cryptography
1) It is easy to generate a key pair
2) It is easy to generate a ciphertext with a known public key and a message
3) It is easy to decrypt the ciphertext with a private key
4) The private key cannot be derived from the public key
5) The original message cannot be recovered with the public key and ciphertext.
The application of public key cryptosystems.
Broadly speaking, public key cryptosystems can be divided into three categories:
encryption/decryption,
digital signature,
key exchange
2.1 encryption/decryption
6 components
Insert picture description here2.2 Main algorithm
DH
Diffie and Hellman first publicly proposed the idea of ​​public key cryptography in 1976. The Diffie-Hellman algorithm is limited to key exchange. The purpose of this algorithm is to enable two users to safely exchange keys for later use when encrypting messages.
RSA
was proposed by Ron Rivest, Adi Shamir and Leonard Adleman at the Massachusetts Institute of Technology in 1977. Is currently the most widely used asymmetric encryption algorithm. The current 1024bits key strength is no longer secure enough. The larger the key, the more secure, but the slower the system runs.
The RSA algorithm is based on a very simple fact of number theory: it is easy to multiply two large prime numbers, but it is extremely difficult to factor the product at that time.
The DSS
digital signature standard is an algorithm designed specifically for digital signature functions and cannot be used for encryption or key exchange. The obsolete
DSA (Digital Signature Algorithm)
Schnorr and ElGamal signature algorithms are variants and are adopted as DSS ( Digital Signature Standard) by NIST. DSA is based on the integer finite field discrete logarithm problem. The longest key length is 1024, which is no longer secure enough for the
ECC
elliptic curve encryption algorithm. It only needs a very small number of bits to provide the same strength of security, thereby reducing processing overhead.
Elgamal
another commonly used asymmetric encryption algorithm, based on DH, was proposed by Tahir Gamol in 1985.
The purpose of each algorithm is as follows Insert picture description here
3 Message authentication
Unlike encryption to prevent passive attacks (eavesdropping), message authentication can prevent active attacks (forged data, etc.). Message authentication takes a small piece of data of the message for processing (forms a message authentication code) and attaches it to the message; the message itself is not encrypted.
The algorithm that forms the message authentication code, or message digest algorithm, is mainly divided into three categories: MD, SHA, MAC
1) MD (Message Digest): Message Digest
MD series algorithms generally include: MD2, MD4, MD5, the digest length after the algorithm The fixed 128bit is 16 bytes;
2) SHA (Secure Hash Algorithm): Secure Hash Algorithm is
generally divided into two categories: SHA-1 and SHA-2
SHA-1 is our common SHA1 (not enough security), after the algorithm The output digest length is 20 bytes;
SHA-2 mainly includes SHA-224, SHA-256, SHA-384, SHA-512, etc. The length of the digest output after the algorithm is 28 bytes, 32 bytes, 48 ​​bytes and 64 bytes respectively;
3) MAC (Message Authentication Code): The message authentication code
merges the key into the existing hash algorithm. The widely accepted scheme is HMAC. It is a MAC scheme that must be implemented in IP security and is also used in other Internet protocols.

4 Digital signature
Digital signature is another application of public key cryptography.
What is a digital signature? The
sender signs a message with his private key. The signature can be done by encrypting the entire message or encrypting a small data block of the message, where the small data block is a function of the entire message. This encrypted whole message or encrypted small data block is a digital signature.
The function of digital signature is to ensure that the message has not been tampered with during transmission, authenticate the source of the message, and ensure the integrity of the message. The basic idea is to sign with a private key and verify with a public key.
Because the public key is public, many people have it. If the public key is used for signature and private key verification, then the source and integrity of the message cannot be guaranteed. For example, A holds a private key, B and C both hold A’s public key. Now B sends a message to A and uses the public key to sign. Can A not use this signature to prove that it is the message sent by B, because it may also hold From C who has the same public key. Then, after B's information is modified by C, it is sent by C, but there is no way for A to know that B's information has actually been tampered with.
However, the private key is used for encryption, because the private key is owned by only one party. If other people modify the information, because there is no corresponding private key signature, the receiver can determine whether the information has been tampered with.
The website in Reference [2] gives a more detailed explanation of digital signatures

The entire message can be encrypted, but it requires a lot of storage. Therefore, the more commonly used signature method is to encrypt smaller data blocks. A digest is generated through an algorithm (digest algorithm) for a file, and the digest is encrypted with a private key (public key system) to form a signature. Send the signature and the file to the other party.
Signature process
Insert picture description here
Verification process
Insert picture description here
5 Key distribution
5.1 Key distribution based on symmetric encryption
For symmetric encryption, both parties must share the same key, and must ensure that the key cannot be read by others. It is often necessary to frequently change the key to reduce data leakage that an attacker may know about the key. The strength of the cryptographic system depends on the key distribution technology.
Distribution method
1) One of the communication parties selects the key and transmits it to the other party through a secure physical method;
2) The third party selects the key and transmits it to the communication parties through physical methods;
3) One party uses the old key to encrypt the new The key is passed to the other party.
4) Both communication parties have an encrypted link to the third party (KDC key distribution center). The third party transmits the key on the encrypted link to the two communication parties. The
Insert picture description hereautomatic key distribution method provides permission The flexibility and dynamic characteristics required for a large number of end users to access a large number of hosts and exchange data between them. One of the most widely implemented applications of this method is Kerberos. It is actually a certification service, developed by MIT. Use a symmetric encryption mechanism.

5.2 Key distribution based on asymmetric encryption
An important role of public key encryption is to deal with the distribution of keys. It includes two different aspects:
1) the distribution of public keys and
2) the use of public key encryption to distribute keys
. The distribution of
public keys The biggest disadvantage of the process of public key distribution is that anyone can forge the public key. For example, an attacker can pretend that user A sends a public key to other participants such as B, and then the attacker uses his private key to decrypt the encrypted information sent by B to user A. The most typical man-in-the-middle attack. The solution to this problem is to use public key certificates. The main components of a public key certificate: the public key, the user ID of the owner of the public key, and the signature of a trusted third party (such as the certification authority CA).
The most widely accepted public key certificate format is X.509 standard.
Use public key certificate to distribute session key
1) Obtain public key through public key certificate (and verify the validity of public key)
2) Use public key to encrypt session key
3) Use the private key to decrypt the message to get the session key
4) After that, both parties can use the session key to encrypt the message

6 References
[1]. William Stallings. "Network Security Basic Applications and Standards (5th Edition)"
[2].http://www.youdzone.com/signature.html
[3].https://blog. csdn.net/qq_28205153/article/details/55798628
[4].https: //blog.csdn.net/weixin_42940826/article/details/83687007

Guess you like

Origin blog.csdn.net/weixin_47745230/article/details/108693351