Current location - Quotes Website - Signature design - Fundamentals of cryptography
Fundamentals of cryptography
Cryptography is a science that studies how to protect information security, involving mathematics, physics, computer, information theory, coding, communication technology and other disciplines, and has been widely used in life. ? Cryptography is divided into coding and cryptanalysis. Cryptography mainly studies the encoding of information to realize the concealment of information. Cryptanalysis mainly studies the decoding of encrypted messages or the forgery of messages. They are independent and interdependent, developing in contradiction and struggle, and unity of opposites.

? The development history of cryptography can be roughly divided into three stages:

confidentiality

Only the sender and the designated receiver can understand the contents of the transmitted message. The eavesdropper can intercept the encrypted message, but can't restore the original information, that is, can't get the message content.

authentication

Both the sender and the receiver should be able to prove that the other party involved in the communication process really has their claimed identity. That is, a third party can't pretend to be the other party who communicates with you, but can identify the identity of the other party.

message integrity

even though the sender and the receiver can authenticate each other, they still need to ensure that the content of their communication has not been changed during transmission.

non-repudiation

if people receive the message from the other party, they should confirm that the message really comes from the claimed sender, and the sender cannot deny that he sent the message after sending it.

? Cryptosystem is a protocol that enables both parties to communicate in secret. The cryptosystem consists of five elements, P(Plaintext set), C(Ciphertext set), K(Key key set), E(Encryption algorithm) and D(Decryption algorithm), and it meets the following characteristics:?

< script type="math/tex; mode=display" id="MathJax-Element-1"> p ∈ P < /script>

< script type="math/tex; mode=display" id="MathJax-Element-2"> c ∈ C < /script>

< script type="math/tex; mode=display" id="MathJax-Element-3"> k1 ∈ K, k2 ∈ K < /script>

< script type="math/tex; mode=display" id="MathJax-Element-6"> E_{k1}(p) = c,D_{k2}(c) = p < /script>

? The basic principles of encryption and decryption are the same whether it is a classical cryptographic system completed by hand or machinery or a modern cryptographic system completed by computer software or electronic circuit hardware. Are based on the replacement or replacement of plaintext information, or through the combination of the two.

? Substitution cipher: systematically replacing a group of letters with other letters or symbols;

? For example,' help me' becomes' ifmqnf' (each letter is replaced by the next letter).

? Transposition cipher: rearranging the alphabetical order without changing the letters;

? For example,' help me' becomes' ehplem'.

? Cryptographers usually use the following methods to attack cryptosystems:

? Known plaintext analysis method:?

Know a part of plaintext and its corresponding ciphertext, analyze and find the secret key.

? Selected plaintext analysis method:?

Try to get the opponent to encrypt a piece of plaintext he selected, and get the corresponding ciphertext. On this basis, analyze and discover the key.

? Differential comparative analysis method:?

Try to get the other party to encrypt a group of plaintext with slight differences, and analyze the secret key by comparing their encrypted results.

? Unconditional security:?

no matter how strong the calculation ability of the decipherer is, no matter how many ciphertexts are intercepted, the plaintext cannot be deciphered.

? Computationally safe:

? The cost of deciphering exceeds the value of the information itself, and the time required for deciphering exceeds the validity period of the information.

? The application of any cryptographic system needs to strike a balance between security and operating efficiency. As long as the cryptographic algorithm meets the requirements of computational security, it has practical conditions and does not need to achieve absolute security in theory. In 1945, Claude e Shannon, an American mathematician, published the Mathematical Principles of Cryptography, which rigorously proved that one-time codebook or Vernam cipher is unconditionally secure. However, this absolutely safe encryption method needs to consume a lot of resources in actual operation and does not have the feasibility of large-scale use. In fact, the cryptographic systems that are widely used at present only have computational security.

? A good cryptosystem should meet the following two conditions:

It is easy to calculate the ciphertext according to the encryption algorithm when the plaintext and key are known; Given the ciphertext and decryption key, it is easy to calculate plaintext.

without knowing the decryption key, it is impossible to calculate plaintext from ciphertext, or the cost of calculating plaintext from ciphertext exceeds the value of the information itself.

Common password algorithms include:

? Symmetric cryptosystem is also called single-key or private-key cryptosystem, and its encryption key and decryption key are the same, or substantially equivalent, that is, it is easy to deduce the other from one.

? Advantages: high confidentiality, fast encryption speed, suitable for encrypting a large number of data, and easy to realize by hardware; ?

Disadvantages: the secret key must be transmitted through a safe and reliable way, and the distribution of the secret key is the key factor to ensure security; Common symmetric cryptographic algorithms: DES (key length =56 bits), 3DES (three different keys with 56 bits each), AES (key length 128/192/256 optional), IDEA (key length 128 bits), RC5 (variable key length).

? According to different encryption methods, symmetric passwords can be divided into block passwords and sequence passwords.

? The plaintext is divided into fixed-length groups, and each block is encrypted with the same key and algorithm, and the output is also fixed-length ciphertext, and the decryption process is the same.

? Also known as stream cipher, plaintext is encrypted one bit or one byte at a time, and a pseudo-random sequence (key stream) with excellent performance is generated by a pseudo-random number generator, and the plaintext message sequence is encrypted by this sequence to obtain a ciphertext sequence, and the decryption process is the same.

? Asymmetric cryptosystem is also called double-key or public-key cryptosystem, and its encryption key and decryption key are different, so it is difficult to deduce the other from one. The encryption key can be made public, which is called public key or public key for short. The decryption key must be kept secret, which is called private key.

? Advantages: key exchange can be conducted through an open channel without confidentiality. It can be used for both encryption and signature. ?

Disadvantages: The encryption speed is not as fast as that of symmetric cipher, so it is not suitable for encrypting a large number of data, and the encryption operation is difficult to realize by hardware.

? Asymmetric cryptosystem not only endows communication with confidentiality, but also provides authentication of messages. Information can be transmitted safely through insecure channels without exchanging secret keys, which simplifies the workload of key management, adapts to the needs of communication networks, and opens up broad prospects for the application of cryptography technology in commercial fields.

? Common asymmetric cryptographic algorithms: RSA (based on large integer prime factor decomposition problem) and ECC (based on elliptic curve discrete logarithm problem).

misunderstanding of asymmetric passwords?

asymmetric passwords are more secure than symmetric passwords? ?

The security of any algorithm depends on the length of the secret key and the workload of deciphering the password. From the perspective of anti-analysis, no one is superior.

? Asymmetric cryptography makes symmetric cryptography an outdated technology? ?

The public key algorithm is very slow, and it is generally used for key management and digital signature. Symmetric cryptography will exist for a long time, and the combination of symmetric cryptography and asymmetric cryptography is adopted in practical engineering. Hash function maps an arbitrarily long message to a fixed-length hash value, also called message digest. Message digest can be used as an authenticator to complete message authentication. ?

Hash is a one-way function, so it is extremely difficult to infer the original message from the message digest. The security of hash function is determined by the probability of collision. If an attacker can easily construct two different messages with the same message digest, then such a hash function is unreliable.

? Common hash functions are: MD5, SHA1, HMAC.

? Digital signature is a typical application of public key cryptography, which can provide similar effects as handwritten signature in reality, and it is guaranteed both technically and legally. It is an important technology to provide message integrity, confirm identity and ensure message source (non-repudiation) in network environment.

? Digital signature and verification process:

? The sender uses a hash function to generate a 128-bit hash value (or message digest) from the message text, and the sender encrypts this hash value with his own private key to form his own digital signature. Then, this digital signature will be sent to the receiver together with the message as an attachment. After receiving the message, the receiver uses the same hash function to calculate the hash value (or message digest) from the original message, and then uses the sender's public key to decrypt the digital signature attached to the message to obtain another hash value. If the two hash values are the same, the receiver can confirm that the digital signature belongs to the sender. The integrity and non-repudiation of messages can be achieved through digital signature. ?

? In network security, the key plays an important role

. How to distribute and manage keys safely, reliably, quickly and efficiently has always been an important issue in the field of cryptography.

? Key generation can be achieved through online or offline interactive negotiation, such as cryptographic protocols. The key length should be long enough. Generally speaking, the longer the key length, the larger the corresponding key space, and the more difficult it is for attackers to guess passwords by exhaustive method. When choosing a key, we should avoid choosing a weak key. Most key generation algorithms use random process or pseudo-random process to generate keys.

? Using symmetric encryption algorithm for secure communication requires * * * to share the same key. Usually, one member of the system first selects a secret key and then transmits it to another member or other members. X9.17 standard describes two kinds of keys: key encryption key and data key. Key encryption key encrypts other keys that need to be distributed; The data key only encrypts the information flow. Key encryption keys are generally distributed manually. In order to enhance confidentiality, the key can also be divided into many different parts and then sent out by different channels.

? Some error detection and correction bits are attached to the key for transmission. When an error occurs in the transmission of the key, it can be easily detected and the key can be retransmitted if necessary. The receiver can also verify whether the received key is correct. The sender encrypts a constant with a key, and then sends the first 2-4 bytes of the ciphertext together with the key. At the receiving end, do the same work. If the decrypted constant at the receiving end can match the original constant, the transmission is error-free.

? When the key needs to be changed frequently, it is really difficult to distribute new keys frequently. An easier solution is to generate new keys from old keys, sometimes called key update. You can use the one-way function to update the key. If both parties share the same key and operate with the same one-way function, they will get the same result.

? The key can be stored in the brain, magnetic stripe card and smart card. You can also divide the key into two parts, half of which is stored in the terminal and the other half is stored in the ROM key. You can also use a method similar to the key encryption key to encrypt and save the key that is difficult to remember.

? The backup of the key can adopt the methods of key custody, secret division and secret sharing.

? Key escrow:

? Key escrow requires all users to hand over their keys to the key escrow center, which will back up their keys (such as locking them in a safe somewhere or encrypting them with the master key). Once the user's keys are lost (such as the user forgetting the keys or the user accidentally dying), according to certain rules and regulations, the user's keys can be obtained from the key escrow center. Another backup scheme is to use smart card as temporary key hosting. For example, Alice stores the key in the smart card, and gives it to Bob when Alice is away. Bob can use the card to do Alice's work. When Alice comes back, Bob returns the card. Because the key is stored in the card, Bob doesn't know what the key is.

? Secret division:

? Secret segmentation divides the secret into many pieces, each piece does not mean anything in itself, but put these pieces together and the secret will reappear.

? Secret * * * enjoy:

? The key K is divided into n blocks, and each part is called its "shadow". If you know any m or more blocks, you can calculate the key K, but if you know any m-1 or less blocks, you cannot calculate the key K.. Secret sharing solves two problems: first, if the key is accidentally or intentionally exposed, the whole system will be vulnerable; Second, if the key is lost or damaged, all information in the system can't be used.

? Encryption keys cannot be used indefinitely for several reasons: the longer the key is used, the greater the chance it will be leaked; If the key has been leaked, the longer the key is used, the greater the loss; The longer the key is used, the more tempting it is for people to spend energy to decipher it-even using exhaustive attacks.

? Different keys should have different validity periods. The validity period of data key mainly depends on the value of data and the number of encrypted data in a given time. The greater the value and data transmission rate, the more frequently the key is changed. For example, key encryption keys do not need to be changed frequently, because they are only used occasionally for key exchange. Key encryption keys are either memorized or kept in a safe place. Losing this key means losing all file encryption keys.

? The validity period of the private key in the application of public key cryptography varies according to different applications. The private key used for digital signature and identification must last for several years (even for life), and the private key used for coin toss protocol should be destroyed immediately after the protocol is completed. Even if the security of the key is expected to last for life, it is necessary to change the key every two years. The old key still needs to be kept secret in case the user needs to verify the previous signature. However, the new key will be used as the signature of new files to reduce the number of signature files that can be attacked by cryptanalysts.