Review past

SHA algorithm

ARM assembly language program structure

Xposed framework installation, use and plug-in development

The most detailed framework of CydiaSubstrate ever

Symmetric encryption algorithm

(1) the definition

In a symmetric encryption algorithm, the sender sends the plaintext (the original data) and the encryption key through a special encryption algorithm to make it a complex encrypted ciphertext. After receiving the ciphertext, the recipient needs to decrypt the ciphertext using the used encryption key and the inverse algorithm of the same algorithm to restore the ciphertext to readable text if it wants to read the original text. In symmetric encryption algorithm, only one key is used. Both sender and receiver use this key to encrypt and decrypt data, which requires that the decryptor must know the encryption key in advance.

(2) Advantages and disadvantages

Advantages: open algorithm, small amount of calculation, fast encryption speed, high encryption efficiency.

Disadvantages:

(1) Both parties of the transaction use the same key, so the security cannot be guaranteed.

(2) Each pair of users need to use the unique key unknown to others every time they use the symmetric encryption algorithm, which makes the number of keys owned by both sides of the sender and receiver grow exponentially, and key management becomes the burden of users. Symmetric encryption algorithm is difficult to use in distributed network system, mainly because of the difficulty of key management and high cost.

(3) Commonly used symmetric encryption algorithms

Symmetric key encryption algorithms include DES, 3DES (TripleDES), AES, RC2, RC4, RC5, and Blowfish.

2 the des algorithm

(1) INTRODUCTION to DES algorithm

DES algorithm is called Data Encryption Standard, namely Data Encryption algorithm, which was successfully researched and published by IBM in 1975. The DES algorithm has three entry parameters: Key, Data, and Mode. Key contains 8 bytes and a total of 64 bits. It is the working Key of DES algorithm. Data is also 8 bytes 64-bit, which is the Data to be encrypted or decrypted; Mode Indicates the working Mode of DES, including encryption and decryption.

(2) Algorithm principle

DES algorithm changes the 64-bit plaintext input block into the 64-bit ciphertext output block, and the key it uses is also 64-bit. Its algorithm is mainly divided into two steps:

(1) Initial permutation

Its function is to recombine the input 64-bit data blocks by bit, and divide the output into L0 and R0 parts, each part is 32 bits long, the substitution rule is to change the input 58th bit to the first, the 50th bit to the second… And so on, the last digit is the original seventh digit. L0 is the left 32 bits of the output, and R0 is the right 32 bits of the output. For example, set the input value before the output to D1D2D3…… D64, L0=D58D50…… The D8. R0 = D57D49… D7.

(2) inverse permutation

After 16 iterations, L16 and R16 are obtained, which are taken as input and carried out inverse permutation, which is exactly the inverse operation of the initial permutation, thus obtaining the ciphertext output.

Grouping pattern

(1) Why is grouping mode needed?

The plaintext length is not fixed, but the block cipher can only deal with a specific length of a piece of data, so it is necessary to iterate the algorithm of the block cipher, in order to encrypt a very long plaintext, and the iterative method is the grouping mode.

Common grouping modes:

EBC mode: Electronic Code Book, Electronic password Book mode

Features: Simple, high efficiency, regular ciphertext, easy to crack

CBC mode: Cipher Block Chaining mode (recommended)

Features: Ciphertext is irregular and often used for encryption

CFB mode: Cipher FeedBack, ciphertext FeedBack mode

Features: The ciphertext is irregular, and the plaintext is grouped by bit with a data stream, resulting in the OFB mode: output-feedback. The plaintext is grouped by bit with a data stream, resulting in the ciphertext

CTR mode: CounTeR, CounTeR mode (key, recommended)

Features: Ciphertext is not regular. Plaintext is grouped in bitwise xor operations with a data stream, and ciphertext is generated

Common fill mode

When Java performs DES, 3DES and AES symmetric encryption algorithms, NoPadding (NoPadding), Zeros padding (0 padding) and PKCS5Padding are often used.

DES algorithm code is analyzed in Eclipse

Mainactivity in the main class called four custom data encryption algorithms: DESCBC, DESedeCBC, DES, DESede

(2) Analyze the CLASSES DESCBC, DESedeCBC, DES and DESede respectively

GetInstance: Obtain the corresponding algorithm by using this method

GenerateSecret: encrypt key to generateSecret key;

GenerateKey: generates a key

DESedeKeySpec(byte[] key) : Creates a DESedeKeySpec object, using the first 24 bytes of the key as the contents of the DES-EDE key.

IvParameterSpec: gets the deflection vector

DECRYPT_MODE: indicates the encryption mode

summary

1. Introduce DES related algorithms and implementation principles.

2. Analyze DES algorithm code in Eclipse.

If you are also interested in Android reverse, please add contact information, wechat search [Chen Road mobile security team], pay attention to surprise oh!

Qq: 3543756281

Ag: Yjxiaox