1. HTTP의 약점
1) 평문(암호화하지 않은) 통신이기 때문에 도청 가능
HTTP는 자신을 암호화하는 기능이 없기 때문에 통신 전체가 암호화되지 않는다. 즉, 평문으로 HTTP메시지를 보내게 된다. 이를 방지하기 위해 a. 통신 암호화(SSL이나 TLS이라는 다른 프로토콜을 조합해서 HTTP 통신 내용을 암호화할 수 있다.)나 b. 콘텐츠 암호화(콘텐츠 내용 자체를 암호화하는 방법)등을 이용할 수 있다.
2) 통신 상대를 확인하지 않기 때문에 위장 가능하다.
HTTP를 사용한 리퀘스트나 리스폰스에서는 통신 상대를 확인하지 않는다. 따라서 누구든지 리퀘스트를 보낼 수 있고 누구든지 리스폰스를 반환할 수 있다. 이를 보완하기 위해 상대를 확인하는 증명서의 기능을 하는 SSL을 활용할 수 있다. SSL은 암호화뿐만 아니라 상대를 확인하는 수단으로 증명서를 제공한다. 이 증명서는 제3 기관에 의해 발행되는 것이기 때문에 위조하는 것이 거의 불가능하다.
3) 완전성을 증명할 수 없기 때문에 변조 가능
HTTP가 완전성을 증명할 수 없다는 뜻은 만약 리퀘스트나 리스폰스가 발신된 후에 상대가 수신할 때까지의 사이에 변조되었다고 하더라도 이 사실을 알 수 없다는 것을 의미한다.
2. HTTPS( HTTP + 암호화 + 인증 + 완전성 보호 = HTTPS)
위와 같은 문제점을 해결하기 위해 HTTP에 암호화나 인증 등의 구조를 더한 것을 HTTPS라고 부른다.
HTTPS는 통신을 하는 소켓 부분을 SSl(SecureSocketLayer)이나 TLS(Transport LayerSecurity)라는 프로토콜로 대체하고 있다.
즉, HTTP는 SSL과 통신하고 SSL이 TCP와 통신한다. SSl이라는 껍질을 덮어쓴 HTTP가 HTTPS이다.
1) 공개 키 암호화 방식
암호화와 복호화에 하나의 키를 같이 사용하는 방식을 공통키 암호라고 부른다.
공통 키 암호의 딜레마로 나온 것이 두 개의 키를 사용하는 공개키 암호이다. 공개키 암호를 사용한 암호화는 암호를 보내는 측이 상대의 공개키를 사용해 암호화한다. 그리고 암호화된 정보를 받아들인 상대는 자신의 비밀키를 사용해 복호화를 실시한다.
2) HTTP는 하이브리드 암호 시스템
공개키 암호는 공통 키 암호에 비해 처리 속도가 늦다. HTTP는 공개키와 공통 키 암호의 양쪽 장점을 살릴 수 있도록 각각의 방식을 조합해서 통신한다. 키를 교환하는 곳에서는 공개키 암호를 사용하고 그 후의 통신에서 메시지를 교환하는 곳에서는 공통 키 암호를 사용한다.
3) 공개키가 정확한지 아닌지 증명하는 증명서
어떤 서버와 공개키 암호를 사용해서 통신을 하려고 할 때 공개키가 본래 의도한 서버에서 발행한 공개키인지 확신할 수가 없다. 이를 위해 제3기 관인 인증기관을 이용해 안전성을 확보한다. (공개키 인증서)
HTTPS에서는 클라이언트 증명서도 이용할 수 있다. 클라이언트 증명서를 이용해 서버 증명서와 같이 통신하고 있는 상대가 의도한 클라이언트인 것을 증명하는 클라이언트 인증을 할 수 있다. 그러나 비용상의 이유로 은행 인터넷 뱅킹과 같은 곳에서만 사용된다.
3. 항상 HTTPS를 사용하지 않는이유?
SSL 통신이 지연되는 이유에는 두 가지가 있다. 하나는 통신 속도가 떨어지는 것과 다른 하나는 CPU나 메모리 등의 리소스를 다량으로 소비하며 처리가 느려지는 것이다. 네트워크 부하는 HTTP를 사용하는 경우에 비해 2배에서 100배 정도 느려질 수 있다. TCP 접속과 HTTP 리퀘스트, 리스폰스 이외에 SSL에 필요한 통신이 추가되어 처리해야 할 통신이 증가하기 때문이다.
즉, 항상 HTTPS를 사용하지 않는 이유는 암호화 통신은 CPU와 메모리 등 리소스를 많이 필요로 하기 때문이다. 특히 액세스가 많은 웹 사이트 등에서 암호화를 하면 그 부하가 상당하기 때문에 암호화를 사용하는 경우에는 모든 콘텐츠를 암호화하는 것이 아니라 숨겨야 할 정보만 암호화하면서 리소스를 절약한다. 추가적으로 HTTPS를 사용하기 위해서 증명서가 필요하지만, 이를 사용하기 위해서 구매해야 한다. 이 비용 또한 상당하기 때문에 HTTP만 선택하는 경우도 있다.
4. 대칭키 암호화와 비대칭키 암호화
- 대칭키 암호화
- 클라이언트와 서버가 동일한 키를 사용해 암/복호화 진행
- 키가 노출되면 매우 위험, 연산 속도가 빠름
- 비대칭키 암호화
- 1개의 쌍으로 구성된 공개키와 개인키를 암호화/복호화 하는데 사용함
- 키가 노출되어도 비교적 안전하지만 연산 속도가 느림.
5. Pem file의 역할 SSL/TLS
In the context of SSL/TLS certificates, .pem files are typically used to store the SSL certificate and the associated private key. Let’s break down the role of each file in your example:
1. abc.com_20240610A2C12.crt.pem (Certificate file):
• This file contains the public SSL certificate for your domain (abc.com in this case).
• The certificate is used by clients (e.g., browsers) to establish a secure connection with the server, ensuring that the server is who it claims to be. It may include information such as the domain name, the issuing Certificate Authority (CA), the validity period, and the public key.
• The certificate is presented to clients during the SSL/TLS handshake to verify the server’s identity.
2. abc.com_20240610A2C12.key.pem (Private key file):
• This file contains the private key associated with the public SSL certificate.
• The private key is used by the server to decrypt the encrypted data sent by clients. It also helps in signing data during the SSL handshake, ensuring that the server holds the private key corresponding to the public key in the certificate.
• This key is highly sensitive and must be kept secure because anyone with access to it can impersonate the server.
How They Work Together:
• When a client (e.g., a web browser) attempts to connect to your server, the server sends the public certificate (.crt.pem) to the client.
• The client uses the public key from the certificate to encrypt data and send it back to the server.
• The server uses its private key (stored in the .key.pem file) to decrypt this data.
• The private key is never shared, while the certificate (public key) is sent to clients.
Both files are essential for enabling SSL/TLS on a server: the certificate file proves the server’s identity, and the private key enables encrypted communication.
6. AES-256, SHA-256, BCrypt, 공개키(비대칭키), 대칭키
1) Hashing의 의미
Hashing is the process of taking an input (or “message”) and generating a fixed-size string of characters, which is typically a “digest” that represents the original data. Hashing is commonly used in computer science for various purposes, such as verifying data integrity, storing passwords, and enabling efficient data retrieval.
Key Characteristics of Hashing:
1. Fixed-Length Output:
• Regardless of the size of the input data, the hash function produces a fixed-length output. For example, SHA-256 always generates a 256-bit (32-byte) hash value, even if the input is one byte or one gigabyte.
2. Deterministic:
• The same input will always produce the same hash output. This consistency is crucial for uses like verifying data integrity.
3. One-Way Function:
• Hash functions are designed to be one-way, meaning it’s practically impossible to reverse the process and determine the original input from the hash. This property makes hashing useful for things like storing passwords securely.
4. Avalanche Effect:
• A small change in the input results in a significantly different hash output. This ensures that even similar inputs generate very different hashes, which is vital for security purposes.
5. Collision Resistance:
• It’s difficult (though not impossible) to find two different inputs that produce the same hash value. This property, called collision resistance, is essential for maintaining the uniqueness of hashes.
Common Uses of Hashing:
1. Data Integrity Verification:
• Hashes are used to verify that data hasn’t been altered. For example, when you download a file, its hash is often provided by the source so you can check if the file was modified or corrupted during transfer.
2. Password Storage:
• Hashing is used to securely store passwords. Instead of storing plain-text passwords in a database, systems store hashed passwords. When a user logs in, the system hashes the entered password and compares it to the stored hash.
3. Digital Signatures:
• Hashing plays a crucial role in digital signatures. A document’s hash is encrypted with a private key to generate a digital signature, ensuring both the document’s integrity and the authenticity of the signer.
4. Hash Tables and Data Structures:
• Hashing is also used in data structures like hash tables, where it helps in quickly retrieving data by mapping input keys to specific locations in memory.
Hashing vs. Encryption:
• Hashing is a one-way process, meaning you cannot recover the original input from the hash. It’s typically used for integrity checks and securing sensitive data like passwords.
• Encryption, on the other hand, is reversible. Data is transformed using an encryption key, and the original data can be decrypted using a decryption key.
Common Hashing Algorithms:
• SHA-256 (Secure Hash Algorithm)
• MD5 (Message Digest Algorithm 5)
• SHA-1 (Secure Hash Algorithm 1)
• BCrypt (designed for password hashing, with salting and cost factor features)
2) BCrypt
BCrypt is also a hashing algorithm, but it is specifically designed for secure password hashing and differs in key ways from general-purpose hashing algorithms like SHA-256. Here’s a breakdown of BCrypt and its purpose:
What is BCrypt?
• BCrypt is a cryptographic hash function designed for securely hashing passwords. It is based on the Blowfish cipher and was created with the goal of being slow and computationally expensive, making it much harder for attackers to perform brute force or dictionary attacks.
How BCrypt Differs from Algorithms Like SHA-256:
1. Purpose:
• SHA-256 and other cryptographic hash functions (e.g., MD5, SHA-1) are designed for general data integrity verification, not specifically for passwords.
• BCrypt is purpose-built for password hashing. It’s designed to make brute-force attacks much more difficult by being deliberately slow.
2. Key Features of BCrypt:
• Adaptive Cost Factor: BCrypt allows for a configurable “work factor,” which makes the hash computation slower. As computing power increases over time, you can increase the cost factor to ensure that password hashing remains computationally expensive.
• Salting: BCrypt automatically adds a unique salt (random value) to each password before hashing, which helps defend against rainbow table attacks. Even if two users have the same password, their BCrypt hashes will be different due to the unique salt.
• Slowness: By being slower than traditional hash functions like SHA-256, BCrypt is more resistant to brute-force attacks, where attackers try many possible passwords to guess the correct one.
3. Password Hashing vs. General Hashing:
• General Hashing (SHA-256): Primarily used for data integrity checks, digital signatures, and other purposes where speed is important. It’s fast and deterministic but not designed to be slow or handle the specific security needs of password storage.
• Password Hashing (BCrypt): BCrypt is designed to be slow and resistant to attacks targeting passwords. The added cost factor and salting mechanisms make it more secure for password storage.
Why BCrypt is Preferred for Password Hashing:
• Slows Down Attackers: BCrypt is computationally expensive, meaning that brute-force attempts to guess passwords will take significantly longer. This makes it much more secure than using fast hash functions like SHA-256 for passwords.
• Built-in Salting: Each password hash generated with BCrypt contains a random salt, preventing attackers from using precomputed hash databases (rainbow tables) to crack passwords.
Conclusion:
Yes, BCrypt is a hashing algorithm, but it is specifically designed for securely hashing passwords. It includes features like salting, adjustable cost, and deliberate slowness to provide stronger protection against password-cracking attacks. It is commonly recommended for password storage, whereas general-purpose algorithms like SHA-256 are better suited for data integrity checks and cryptographic applications.
3) Hashing 알고리즘 적용 된 값에서 평문 끄집어 낼 수 있나
Why You Can’t Reverse a Hash:
1. One-way Function: Hash functions like SHA-256 (which your example hash appears to be from) are designed to be one-way functions. This means that once data is hashed, it cannot be reversed to obtain the original input. The process is non-reversible by design.
2. Collision Resistance: Although theoretically possible, finding two different inputs that generate the same hash (called a collision) is extremely difficult with strong hash functions like SHA-256 due to their mathematical complexity.
3. Preimage Resistance: Given a hash output, it is computationally infeasible to find any input that produces that hash. In other words, starting with a hash like 3a7bd3e2360a3d80af0a359baf9be82678a4a01a8aae4c6f326f6ffb16c25b23, there’s no efficient way to determine what input (plain text) produced it.
Methods People Might Try:
• Brute Force Attack: One could theoretically try every possible combination of input text, hash it, and compare the result with the given hash until they find a match. However, if the original text was sufficiently complex (long, containing various characters), this would take an infeasible amount of time, especially for strong hashing algorithms like SHA-256.
• Rainbow Tables: These are precomputed tables of common inputs and their corresponding hash values. However, modern security practices use techniques like salting (adding random data to the input before hashing) to make rainbow tables ineffective.
4) AES-256 = 대칭키 암호화 알고리즘
AES-256 (Advanced Encryption Standard with a 256-bit key) is not a public key encryption method. It is a symmetric key encryption algorithm, meaning the same key is used for both encryption and decryption of data.
Key Differences Between Symmetric and Public-Key (Asymmetric) Encryption:
1. Symmetric Encryption (like AES-256):
• Same key is used for both encryption and decryption.
• The key must be securely shared between the parties.
• It’s faster and efficient for encrypting large amounts of data.
• Example algorithms: AES, DES, RC4.
2. Asymmetric (Public-Key) Encryption:
• Two keys are used: one for encryption (public key) and one for decryption (private key).
• The public key can be shared openly, but the private key is kept secret.
• Asymmetric encryption is generally slower and used for smaller data, such as encrypting the symmetric key (for hybrid encryption systems).
• Example algorithms: RSA, ECC (Elliptic Curve Cryptography), DSA.
AES-256 Role:
• AES-256 is often used in combination with asymmetric encryption in a hybrid encryption system. For example, the symmetric AES key might be encrypted using a public-key algorithm like RSA, while AES-256 handles the actual data encryption due to its speed.
In short, AES-256 is a symmetric encryption method, not a public-key (asymmetric) one.
'개발관련 도서 > Http&Network Basic' 카테고리의 다른 글
제11장 웹 공격 기술 (0) | 2021.07.21 |
---|---|
제9장. HTTP에 기능을 추가한 프로토콜/ 제10장 웹 콘텐츠에서 사용하는 기술 (0) | 2021.07.19 |
제 8장 누가 액세스하고 있는지를 확인하는 인증 (0) | 2021.07.18 |
6장 HTTP 헤더 (0) | 2021.07.14 |
제 5장. HTTP와 연계하는 웹 서버 (0) | 2021.07.13 |