Getting Started with safety knowledge

Source: Internet
Author: User
Tags hmac http digest authentication md5 hash oauth rfc asymmetric encryption

1. Common attack methods

    1. Destroying the integrity of information, tampering with information
    2. Denial of Service
    3. Eavesdropping, interception of information
    4. Fake
    5. Deny
    6. Replay
    7. Guessing predictions
    8. Drag Library, Information disclosure
2. Fundamentals of Cryptography

2.1 HASH

    1. Introduced
      1. Abstract, the arbitrary size of the data mapped to a fixed length of summary information, different information has a different hash value.
      2. Irreversible, the original data cannot be rolled back by the hash value.
    2. Use:
      1. Prevent tampering with information
      2. Ensure information integrity
      3. Data de-weight
    3. Common algorithms:
      1. Checksum: is a simple sum check code, generally used in communication to ensure the integrity and accuracy of data, such as the TCP protocol.
      2. Crc32:32bit, good performance, high collision rate, generally used for picture to go heavy.
      3. Md5:128bit, general user password encryption, file verification, for password encryption is not safe, because the collision condition has been found
      4. SHA1: The basic same as MD5, has found the collision condition, but for the file check still no problem
      5. SHA256: Relatively secure, can be used for password encryption
      6. Bloom Filter: A number of hash function combination to go to the weight, generally used for large data volume, such as Search engine Web page included. If it says that an item is not in a collection, it certainly isn't, and if so, there's a small possibility.

2.2 Random Number

    1. Introduced
      1. Specify a range and seed, randomly generate a number
    2. Use:
      1. Anti-guessing predictions that allow hackers to guess less about information addresses or encryption factors.
      2. Prevent replay, the random number in each request is inconsistent, the user replay request when the random number has been used to deny the request.
      3. Hash as a salt, let the same plaintext add salt to generate a different hash value, to prevent the use of dictionary attacks to crack passwords.
      4. In the encryption algorithm as the IV (initialization vector), the same plaintext block to generate different ciphertext, to increase the difficulty of cracking.
      5. Randomly extract data from the collection to ensure that it is unique over time, such as the TCP seq.
      6. Dynamic password, and time, seed-dependent random number.
    3. Common algorithms:
      1. Linear congruence: The most commonly used pseudo-random number generation algorithm, if it is known that the seed is likely to be predicted.
      2. GUID: Global unique string that is hard to guess.

2.3 Symmetric encryption

    1. Description: Encryption and decryption need to use the same key, there are stream encryption and block encryption, generally can be large data volume encryption.
    2. Use:
      1. Prevent Information disclosure
      2. Prevent information interception
    3. Common algorithms:
      1. Des:64bit key, less difficult to crack
      2. 3DES: Sanchong des,128bit Key, more difficult to crack
      3. Rc2:des suggested alternative algorithm, key length variable, 1-128bit, faster
      4. RC4: High strength, fast speed, unsafe
      5. AES: Widely used encryption algorithm, fast, high security level, has become the United States encryption Standard, the current AES standard implementation is Rijndael algorithm

2.4 Asymmetric Encryption

    1. Introduced:
      1. Encryption and decryption use different keys, generally only a small amount of data can be encrypted, and poor performance.
      2. Public keys can be exposed, and public key-encrypted data private keys can be decrypted, and vice versa.
      3. The private key needs to be kept secret, the private key is signed, and the public key can verify the signature.
      4. The confidentiality of asymmetric encryption algorithm is better, it eliminates the need for end-user exchange of key.
    2. Use:
      1. Verification of identity, digital signature, can solve the problem of denial, forgery, tampering and impersonation, etc.
      2. Data encryption to prevent information disclosure and interception
    3. Common algorithms:
      1. RSA: Based on large number operations and mathematical principles, you can use different keys for encryption and decryption.
      2. DSA: Data Signature Algorithm,
3. Identity authentication scheme

3.1HTTP Basic Certification

    1. Description: The user name appends a colon and then strings the password, and the resulting string is then encoded with the BASE64 algorithm.
    2. Advantages:
      1. Browser support is extensive.
    3. Disadvantages:
      1. Cannot prevent information from leaking, base64 is just encoding, not encryption.
      2. Can't prevent eavesdropping
      3. Cannot prevent replay
      4. Cannot prevent drag library
    4. Usage scenarios:
      1. Basic authentication can be used in a trusted network environment.
      2. Use HTTPS to do the transport layer.

3.1 HMAC

    1. Introduced:
      1. A hash algorithm, with a key and a message as input, generates a message digest as output.
      2. The message authentication code is a value obtained based on the key and the message digest "hash", which can be used for authentication and integrity checking of the data source.
    2. Principle:
      1. The client sends a message to the server, adds it with a key and a message, and then hashes a Mac
      2. The user then sends the plaintext message and Mac to the server
      3. Server knows key, uses the same algorithm to get Mac, see if the MAC is consistent with client request
      4. If the Mac is consistent, the message is sent by the person who owns the key, and the message has not been tampered with
    3. Advantages:
      1. Realize the identity authentication and realize the non-repudiation
      2. Guaranteed data integrity for tamper-proof results
      3. The important difference between HMAC and general cryptography is that it has the "instantaneous" nature that authentication is only valid at that time.
    4. Disadvantages:
      1. Message is plaintext, not anti-eavesdropping
      2. Cannot prevent replay
    5. Application:
      1. Challenge/Response (Challenge/response) identity authentication, such as Sip,http
      2. Cookie Signature

3.2 HTTP Digest authentication (Digest access authentication, rfc2069)

  1. Introduced
    1. It applies a hash function to the password before it is issued, which is more secure than the HTTP Basic authentication sent in clear text.
  2. Principle
    1. Client requests Authentication page, does not provide user name and password
    2. Server returns 401 reply
      1. Realm: Authentication domain, clear text,
      2. Nonce: Random number, clear text, use only once
    3. Client initiates request again
      1. The MD5 hash is computed for the combined value of the user name, authentication domain (realm), and password, and the result is called HA1.
      2. The combined value of the HTTP method and the digest of the URI computes the MD5 hash value, for example, "GET" and "/dir/index.html", and the result is called HA2.
      3. For HA1, server password random number (nonce), request count (NC, prevent replay), client password random number (cnonce), HA2 consolidation value calculation MD5 Get response value and cnonce.
    4. server receives the answer because the server has the same information as the client, so the server can perform the same calculations to verify the correctness of the response value submitted by the client.
  3. Advantages
    1. Password plaintext does not need to be transmitted, so the plaintext will not be disclosed, so that the server can not save the plaintext password, but only save HA1.
    2. Can be the client random number cnonce, enough to prevent the selection of plaintext attacks (hijacking to ciphertext after guessing encryption algorithm and plaintext).
    3. The nonce allows the timestamp to be included, expires after expiration, and prevents replay attacks.
    4. The server can also maintain a list of recently issued nonce to prevent nonce reuse.
    5. Anti-monitoring, anti-replay, anti-repudiation, identity authentication
  4. Disadvantages
    1. Many of the security options in RFC 2617 are optional and, at some point, are downgraded to RFC 2616.
    2. Vulnerable to man-in-the-middle attacks, digest access authentication does not provide any mechanism to help clients verify the identity of the server.
    3. Using HTTPS encryption together with these weak-text protocols solves many of the threats that digest access authentication attempts to prevent.
    4. The use of MD5 is used to MD5 irreversibility, but MD5 now has a way to attack, such as a brute-lifting attack (when the password is simpler), a dictionary attack,
    5. How to face conflict attacks (same as after different plaintext hashes) (rfc2617).
  5. Other instructions
    1. Each nonce can be allowed to be used only once, but this will force the client to repeat the authentication process when sending each request
    2. It is not possible for a nonce to expire immediately after it has been generated, because the client will not have any chance to use the nonce.
    3. The client can reuse the nonce for multiple requests, but it has to provide a new cnonce. In subsequent requests, the NC is larger than the previous one.

3.3 Https/tls

    1. Description: It is a secure transport protocol, but it can also be authenticated.
      1. encrypts the transmitted data: all traffic between the server and the client is encrypted.
      2. for authentication: Make sure that the server is the server he claims to be. The
      3. maintains the integrity of the data and ensures that the data is not altered during transmission.
      4. RC4, X509
    2. Handshake Mechanism-simplified version
      1. client to access a server, know the server domain name Domain
      2. clie NT initiates a request to server 2.1. SSL version number 2.2. Encryption algorithm type 2.3. Random number
      3. server returns answer to client 3.1 SSL version number 3.2 encryption algorithm type 3.3 Random number 3.4 own certificate (public key) 3.5 random number signature.
      4. Client verifies that the answer 4.1 certificate returned by the server is expired 4.2 The certificate's CA is reliable (compared to the local list of trusted CAs) whether the public key of the 4.3 server can unlock the random number signature that is returned by the servers # confirm that the server has the private key of the certificate Whether the domain name of the 4.4 server's certificate authority is the domain name of the server
      5. the client randomly generates a symmetric encryption key, which is then encrypted with the public key of the server and sent to the server
      6. The server decrypts the symmetric encryption key with its own three private key.
      7. Subsequent communication is encrypted with a symmetric encryption key.
    3. Benefits:
      1. anti-eavesdropping
      2. anti-replay
      3. anti-man attack,
      4. guaranteed data Integrity
      5. prevent session hijacking /li>
    4. disadvantage
      1. does not prevent information disclosure, drag libraries, just ensure transport Layer Security
      2. is generally not available for Client authentication and requires HTTP Basic authentication
      3. to establish a slow connection

3.4 OAuth

    1. Description: OAuth allows users to provide a token instead of a user name and password to access their data stored in a particular service provider. Each token authorizes a specific website (for example, a video editing site) to access a specific resource (for example, a video in only one album) within a specific period of time (for example, within the next 2 hours).
    2. Principle:
      1. The user accesses the client's Web site and wants to manipulate its own resources stored in the service provider.
      2. The client requests a temporary token from the service provider.
      3. After the service provider verifies the identity of the client, it grants a temporary token.
      4. After the client obtains the temporary token, the user is directed to the service provider's authorization page to request authorization from the user. In this procedure, the temporary token and the client's callback connection are sent to the service provider.
      5. The user enters the user name and password on the service provider's Web page, and then authorizes the client to access the requested resource.
      6. After the authorization is successful, the service provider directs the user back to the client's Web page.
      7. The client obtains an access token from the service provider based on the temporary token.
      8. The service provider grants a client access token based on the temporary token and the authorization of the user.
      9. The client uses the obtained access token to access the protected resources that are stored on the service provider.

4. Password Authentication Security

4.1 Dual factor authentication, dynamic password

    1. Description: 1. In short, two-factor authentication is an authentication system, such as an ATM, that you know plus a combination of the two elements you can have to work together.
      1. The current mainstream two-factor authentication system is based on time synchronization type,
      2. High market share of Dkey two-factor authentication system, RSA two-factor authentication system, etc.
      3. Mainstream hardware token, SMS password, USB key, hybrid token (usbkey+ dynamic password), secret card, phone token
    2. Advantages
      1. After the password is lost, the hacker cannot login to your account
    3. Disadvantages
      1. Inconvenient to use

4.2 Encrypt the user's password with a key

1. How to prevent the drag library?
1. User authentication security, AD,LDAP certification.
2. User information is stored in a separate server, providing intranet API calls and providing only a single query.

2. How do I prevent cracking after I drag the library?

Method 1:

      1. The native generates a key on the key storage disk, symmetric encryption key.
      2. When creating a user, the user provides password, and then the database is saved Db_password = Encrypt (key, hash (password))
      3. So the hacker dragged the database away, because there is no key to unlock with Db_password, so the user password is still safe.
      4. The user is provided with a password password, hash is hashed (password), and then Uncrypt (Key, Db_password),
        1. The two comparisons, the same is certification through
        2. Inconsistency is termination of authentication
      5. Advantages:
        1. Prevent drag libraries
      6. Disadvantages
      7. If you lose the key, you're screwed, and nobody's logged in.




          

Method 2:

      1. Password MD5 (MD5 (passwd) +salt), each user randomly generates a salt that exists along with the user information. Salt is longer than 20 bits, and it cannot be too long to affect efficiency.

4.3 Secure Remote Password protocol

    1. Introduced

      1. An authentication and key exchange system that is used to protect passwords and exchange keys in unreliable networks.
      2. Security is improved by eliminating the need to send plaintext passwords over the network and by using encryption through a secure key exchange mechanism.
      3. The server does not save hashed values of passwords or passwords to prevent dictionary attacks. Instead, just save the validation factor (verifier).
      4. The client and server can each calculate a session key, which has the same value. Prevent eavesdropping and session hijacking.
      5. Many game services end up with SRP certification, such as World of Warcraft.
    2. Advantages

      1. Anti-eavesdropping
      2. Anti-Violence hack, dictionary attack, weak password is not easy to be cracked
      3. Even if the password database is made public, the attacker still needs a large dictionary to search for the password.
      4. Fast, no need for certificates and third-party certification bodies
    3. Disadvantages

      1. Browser does not support, you have to implement
  否则服务器就会终止认证。

Getting Started with safety knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.