Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Symmetric Cryptography, asymmetric Cryptography, Hash algorithm and PKI

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Symmetric Cryptography, asymmetric Cryptography, Hash algorithm and PKI

Problems to be solved in cryptography: confidentiality, integrity, authentication (non-repudiation):

1. Symmetrical password:

Symmetric cryptography: senders and recipients use a single key that they share, which is used for both encryption and decryption, called a secret key (also known as a symmetric key or session key).

A service that provides information confidentiality (information cannot be decrypted without a key) and integrity (changed information cannot be decrypted).

Symmetric cryptography: single key cryptography, secret key cryptography, session key cryptography, private key cryptography, shared key cryptography.

Common symmetric encryption techniques:

DES (data encryption Standard): block encryption, algorithm derived from Lucifer, as a NIST symmetric encryption standard; 64-bit (significant bit 56 bit, parity 8 bit), grouping algorithm

3DES:128 bit, grouping algorithm

IDEA (International data encryption algorithm): 128bit, faster than DES, grouping algorithm

Blowfish:32-448bit, algorithm public, grouping algorithm

RC4: stream cipher with variable key length

RC5: block cipher with variable key length, up to 2048 bits

Rijndael:128 bit / 196bit / 256bit

AES (Advanced encryption Standard): DES upgrade, algorithm from Rinjindael

Advantages of symmetric passwords:

Users only need to remember a key to be used for encryption and decryption.

Compared with the asymmetric encryption method, the amount of computation of encryption and decryption is small, fast, simple and easy to use, so it is suitable for encrypting massive data.

Disadvantages of symmetric passwords:

If the key exchange is not secure, the security of the key will be lost. Especially in the e-commerce environment, when the customer is an unknown and untrusted entity, how to make the customer obtain the key safely becomes a big problem.

Key management problems if there are more users. N* (NMur1) / 2

If the key is shared by multiple users, it cannot provide non-repudiation

For example:

Assuming that Alice and Bob know each other, in order to ensure that the communication message is not intercepted by others, they agree on a password in advance to encrypt the message transmitted between them, so that even if someone intercepts the message without a password, they cannot know the content of the message. As a result, confidentiality is realized.

However, the above implementation process has the following problems:

1): if Alice and Bob don't know each other on the Internet, how can Alice negotiate (or transmit) a shared key (password) with Bob?

2): if Alice wants to communicate with 100 people, how many passwords does he need to remember? And 1000, 10000 people. What about correspondence?

3): if Alice communicates with others using the same password as Bob, how do you know that the message must have come from Bob?

As a result, asymmetric passwords are introduced.

2. Asymmetric passwords:

Use a pair of keys: one for encrypting information and the other for decrypting information.

There is an interdependence between the two keys: that is, information encrypted with either key can only be decrypted with the other key.

The encryption key is different from the decryption key, public key encryption and private key decryption, and vice versa, private key encryption and public key decryption.

The key is divided according to its nature, one of which is exposed to the outside world as a public key, and the other is retained by itself as a private key. The public key (Public key) is often used for data encryption (encrypting with the other party's public key) or signature verification (decrypting with the other party's public key), and the private key (Private key) is often used for data decryption (the sender encrypts with the receiver's public key) or a digital signature (encrypted with his own private key).

Confidentiality, integrity, non-repudiation

Common asymmetric encryption techniques:

Diffie-Hellman: the first to generate, calculate the discrete logarithm, is a key exchange protocol algorithm, no encryption, no digital signature.

The first asymmetric key agreement algorithm, which focuses on solving the key distribution problem.

Based on the difficult problem of calculating discrete logarithms over finite fields

The communicating parties exchange their public keys on untrusted networks and generate the same symmetric keys on their respective systems.

The original Diffie-Hellman algorithm is vulnerable to middlemen, and the way to deal with this is to authenticate before accepting someone's public key.

Encryption and digital signature functions are not provided.

RSA: large prime decomposition, encryption, signature

EI Gamal: discrete logarithm, encrypted, signifiable, slowest

Elliptic curves: calculate discrete logarithms, similar to RSA, faster

Variants of DSA:EI, discrete logarithm, unencrypted, signable, slower than RSA

Knapsack: knapsack algorithm, encrypted, signified, eliminated

DSS: digital signature Standard

As follows:

First of all, in order to ensure the confidentiality of the message, Alice encrypts the data with the public key of Bob, so that only the private key of Bob can decrypt the message, so only Bob can see the message.

This enables confidentiality, but how does Bob verify that the message is from Alice, because anyone can get the public key of Bob. As a result, there are the following ways:

In order to prove to Bob that she did send the message, Alice encrypted the message with her own private key and then sent it to Bob,Bob to decrypt the message with Alice's public key, so she knew that the message was indeed sent by Alice, because only messages encrypted with Alice private key could be decrypted with her public key.

Authentication is implemented, but anyone can decrypt the message with the public key of Alice, so there is no way to guarantee confidentiality, so there is the following way:

Alice first encrypts the data with its own private key (to achieve authentication), and then uses the public key of Bob to encrypt the message ciphertext that has just been encrypted (to achieve confidentiality), and then sends it to Bob,Bob to decrypt with its own private key and then with the public key of Alice, thus realizing confidentiality and authentication.

However, the asymmetric algorithm itself is resource-consuming and slow, and it is encrypted twice here, which is absolutely unacceptable for bulk data. Is there a better way? This leads to the following hybrid encryption:

III. Hybrid encryption

To put it simply, hybrid encryption is to exchange symmetric keys with asymmetric algorithms and encrypt data with symmetric keys.

As follows:

Alice first randomly generates a session key, then encrypts the message with this session key, then encrypts the session key with Bob's public key, and then sends both the message ciphertext and the session key ciphertext (digital envelope) to Bob,Bob to receive the message first decrypt the digital envelope with its own private key, get the session key, and then decrypt the message ciphertext with the session key.

Note that authentication cannot be implemented here, and Alice cannot prove to Bob that the message was sent on its own.

4. Hash algorithm (hash function, one-way encryption)

Message integrity:

There are many protocols that use parity bits and cyclic redundancy check (Cyclic Redundancy Check,CRC) functions to detect whether the bit stream has been changed as it is transferred from one computer to another. However, parity bits and cyclic redundancy checks usually detect only unintentional changes.

If the message is intercepted by the user, the check value is recalculated after the change, so that the receiver will never know that the bitstream has been tampered with. To achieve this protection, a hashing algorithm is needed to detect intentional or unintentional unauthorized changes to the data.

Hash (hash) function (also known as hash function): the input can be a message of any length, producing a fixed-length output through an one-way operation. This output, called a hash value (hash value, also known as a hash digest), has the following characteristics:

The Hash value should be unpredictable.

The Hash function is an one-way function and is irreversible.

The Hash function is deterministic (unique) and should always produce the same output Y for input X.

Finding any pair such that H (x) = H (y) is computationally infeasible (strongly collision-free, birthday-resistant)

For any given packet x, find y that is not equal to x, such that H (y) = H (x) is computationally infeasible (weakly collision-free).

Types of hashes:

MD2:128 bit, slower than MD4, MD5

MD4:128

MD5:128, more complex than MD4

HAVAL algorithm: variable, MD5 variant

SHA secure hash: SHA-1 160bit, SHA-256 256bit, SHA-384,SHA-512

Tiger:192 bit, faster than MD5 and SHA-1

RIPEMD-160:160 bit, a substitute for MD4 and MD5

As follows:

Alice uses hashing algorithm to calculate message digest 1, and then appends message digest 1 to message plaintext and sends it to Bob,Bob. After receiving the message, message digest 2 is calculated with message plaintext using the same hashing algorithm, and then compared with message digest 1. If the same is the same, the message has not been tampered with.

But simply doing this does not achieve true integrity. If someone intercepts the modification of the message in the middle and recalculates the message digest attached to it, Bob still thinks that the message has not been tampered with. At the same time, authentication cannot be implemented, so there is a digital signature:

Digital signature:

Digital signature refers to the data that the user encrypts the hash digest (Hash digest) of the original data with his own private key.

The information receiver uses the public key of the message sender to decrypt the digital signature attached to the original message and obtains the hash digest. By comparing it with the hash summary you generated with the raw data you received, you can confirm the following two points:

The information is sent by the signer (authentication, non-repudiation)

The information has not been trusted since it was issued until it was received (integrity)

Digital signature standard:

In 1991, NIST proposed a federal standard FIPS 186 (using SHA) for the Digital signature Standard (Digital Signature Standard,DSS), which was last updated in 2013 as FIPS 186-4, including DSA, RSA, and ECC

DSS has two ways to create signatures, DSA and RSA. Unlike RSA, DSA can only be used for digital signatures and is slower than RSA, and RSA can be used for digital signature, encryption, and key distribution.

As follows:

Alice uses the hash algorithm to calculate the message digest, then encrypts the message digest (digital signature) with its own private key, and then sends the message plaintext and digital signature to Bob,Bob to receive the message. Decrypt the digital signature with the public key of Alice to get the original message digest (verify the identity of Alice), use the same hashing algorithm to calculate the message digest, and then compare the two message digests. If the message digest is the same, the message has not been tampered with.

Note: if a third party Tom acts as a middleman here, he can tamper with the message or recalculate the message digest, but Tom does not have the private key of Alice to encrypt the message digest. If Tom encrypts the message digest with its own private key, when Bob receives the message, it will not be able to decrypt the digital signature to get the original message digest text.

To sum up, the different functions of the algorithm:

As can be seen from the above, in these implementations, the public key is very important, so how do we verify the user's public key, as in this example, how does Alice get the public key of Bob, and how does it verify that the public key is Bob? At this point, you need a third party that both parties trust, thus introducing PKI:

5. Public key Infrastructure (PKI)

PKI is a set of system used to use, manage and control public key cryptosystem by software, communication protocol, data format, security policy and so on. It has three main purposes: to issue a public key / certificate, to prove the entity that binds the public key, and to provide a verification of the validity of the public key.

PKI provides basic services:

Confidentiality

Integrity

access control

Authenticity

Undeniability

Digital Certificate:

PKI technology uses certificates to manage the public key, and through the third-party trusted institution certification authority CA (Certificate Authority), the user's public key and other identification information (such as name, email, × × number, etc.) are tied together to verify the user's identity on the Internet network.

A public key certificate is a digitally signed declaration that binds the value of the public key to the identity of the principal (individual, device, and service) holding the corresponding private key. By signing the certificate, CA can verify that the private key corresponding to the public key on the certificate is owned by the principal specified by the certificate.

The format of the digital certificate is specified by the CCITT X.509 international standard, which includes the following points:

Name of the owner of the certificate

The public key of the certificate owner

The validity period of the public key

Units that issue digital certificates

Serial number of the digital certificate (Serial number)

The name of CA and sign the certificate with the digital signature of CA

The identifier followed by CA to determine the certificate principal identity policy

The use of key pairs (public keys and associated private keys) identified in the certificate

Location of Certificate revocation list (CRL)

ITU-T X.509 is not the only format for certificates. For example, Pretty Good Privacy (PGP) secure email is a certificate unique to relying on PGP.

CA:

The authority responsible for issuing and managing digital certificates

Specific functions:

Receive a request to verify the digital certificate of the end user forwarded by RA.

Determine whether to accept the application for the end-user digital certificate-approval of the certificate.

Generate key pairs and certificates

Issue a certificate to the applicant

Provide authoritative notarization of organization and responsibility for issued certificates

Receive the query and revocation of end-user digital certificate.

Generate and publish Certificate revocation list (CRL)

Key management (key backup, key recovery, key update)

Archiving of digital certificates.

Key archiving

Historical data archiving.

To put it simply, the function of PKI is to use a trusted organization CA to issue a digital certificate to the user. The certificate contains the user's public key (this public key can be generated by the user and submitted to CA, or CA can generate and send to the user) and related identity information. Take the Alice and Bob of this article as an example. In order to prove to Bob that she is Alice and a public key is her own, Alice applies for a certificate from a CA institution that both Alice and Bob trust. Alice first generates a pair of key pairs (private key and public key), saves her private key on her computer, and then applies for a certificate for CA with the public key. CA accepts the application and issues a digital certificate to Alice. The certificate contains the public key of Alice and other identity information. Of course, CA calculates the message digest of this information and encrypts the message digest (digital signature) with its own private key attached to the Alice certificate to prove that the certificate was issued by CA itself. After obtaining the certificate of Alice, Bob decrypts the message digest with the public key in the certificate of CA (self-signed), thus confirming that the certificate of Alice is issued by CA, the information in the certificate has not been tampered with, and the public key of Alice is also obtained.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report