[TIL] HTTP : The Definitive Guide "p313 ~ p315"

시윤·2025년 4월 12일

[TIL] Two Pages Per Day

목록 보기
126/146
post-thumbnail

Chapter 14. Secure HTTP

(해석 또는 이해가 잘못된 부분이 있다면 댓글로 편하게 알려주세요.)


✏️ 원문 번역


Symmetric-Key Cryptography

Let’s talk in more detail about how keys and ciphers work together. Many digital cipher algorithms are called symmetric-key ciphers, because they use the same key value for encoding as they do for decoding (e = d). Let’s just call the key k.

  • Key와 Cipher가 함께 동작하는 방식에 대해 자세히 알아봅시다.

  • 많은 디지털 Cipher 알고리즘이 암호화와 복호화에 동일한 키 값을 사용하므로(e = d) Symmetric-key Cipher라고 불립니다.

  • 두 키가 동일하므로 앞으로는 키를 k라고 표현합시다.

In a symmetric key cipher, both a sender and a receiver need to have the same shared secret key, k, to communicate. The sender uses the shared secret key to encrypt the message and sends the resulting ciphertext to the receiver. The receiver takes the ciphertext and applies the decrypting function, along with the same shared secret key, to recover the original plaintext (Figure 14-7).

  • Symmetric Key Cipher에서는 송신자와 수신자는 동일한 비밀 키를 공유하여 통신해야 합니다.

  • 송신자는 공유 비밀 키를 사용하여 메시지를 암호화하여 결과로 생성된 Ciphertext를 수신자에게 전송합니다.

  • 수신자는 동일한 공유 비밀 키를 사용하여 복호화 함수에 Ciphertext를 적용하고, 원본 Plaintext를 복원합니다. (Figure 14-7)

Some popular symmetric-key cipher algorithms are DES, Triple-DES, RC2, and RC4.

  • 자주 사용되는 Symmetric Key Cipher 알고리즘에는 DES, Triple-DES, RC2, RC4가 있습니다.

Key Length and Enumeration Attacks

It’s very important that secret keys stay secret. In most cases, the encoding and decoding algorithms are public knowledge, so the key is the only thing that’s secret!

  • 비밀 키가 사적으로 유지되는 것은 굉장히 중요한 문제입니다.

  • 대부분 암호화 및 복호화 알고리즘은 공개되어 있기 때문에 오직 키값만이 비밀로 유지됩니다.

A good cipher algorithm forces the enemy to try every single possible key value in the universe to crack the code. Trying all key values by brute force is called an enumeration attack. If there are only a few possible key values, a bad guy can go through all of them by brute force and eventually crack the code. But if there are a lot of possible key values, it might take the bad guy days, years, or even the lifetime of the universe to go through all the keys, looking for one that breaks the cipher.

  • 좋은 Cipher 알고리즘은 공격자가 모든 가능한 키 값을 시도하여 암호를 해독할 수밖에 없도록 강제하는 알고리즘입니다.

  • 브루트포스 방식으로 모든 키 값을 시도하는 것을 Enumeration Attack이라고 이야기합니다.

  • 만약 가능한 키 값의 경우의 수가 많지 않다면 공격자가 브루트포스 방식으로 모든 경우의 수를 시도하여 결국 해독에 성공할 수 있습니다.

  • 하지만 가능한 키의 값이 매우 많다면 공격자는 Cipher를 깨뜨릴 키를 찾아내는 데 며칠, 몇 년, 혹은 우주의 생애만큼의 시간이 걸릴 수도 있습니다.

The number of possible key values depends on the number of bits in the key and how many of the possible keys are valid. For symmetric-key ciphers, usually all of the key values are valid.* An 8-bit key would have only 256 possible keys, a 40-bit key would have 2^40 possible keys (around one trillion keys), and a 128-bit key would generate
around 340,000,000,000,000,000,000,000,000,000,000,000,000 possible keys.

  • 가능한 키 값의 개수는 키가 가진 비트 수와 유효한 키의 개수에 의해 결정됩니다.

  • 일반적으로 Symmetric-key Cipher는 모든 키 값이 유효합니다.

  • 8비트의 키가 주어지면 가능한 키의 종류는 256개며, 40비트의 키가 주어지는 경우 2^40 종류의 키가 생성될 수 있습니다.

  • 또한 128비트의 키는 약 340,000,000,000,000,000,000,000,000,000,000,000,000종류의 키를 만들어낼 수 있습니다.

For conventional symmetric-key ciphers, 40-bit keys are considered safe enough for small, noncritical transactions. However, they are breakable by today’s high-speed workstations, which can now do billions of calculations per second.

  • 기존의 Symmetric-Key Cipher는 작고 사소한 트랜잭션에서 40비트 키를 사용하는 것이 충분히 안전하다고 여겨져 왔습니다

  • 하지만 1초에 수십억 번의 연산을 할 수 있는 오늘날의 고속 장치로 인해 Cipher가 깨질 수 있게 되었습니다.

In contrast, 128-bit keys are considered very strong for symmetric-key cryptography. In fact, long keys have such an impact on cryptographic security that the U.S. government has put export controls on cryptographic software that uses long keys, to prevent potentially antagonistic organizations from creating secret codes that the U.S. National Security Agency (NSA) would itself be unable to crack.

  • 반면 Symmetric-key 암호학에서 128비트의 키는 매우 강력한 것으로 알려져 있습니다.

  • 실제로 길이가 긴 키는 보안에 중대한 영향을 미칩니다.

  • 미국 정부는 악의적인 조직이 국가안보국(NSA)이 해독할 수 없는 비밀 암호를 생성하는 것을 방지하기 위해 길이가 긴 키를 사용하여 암호화된 소프트웨어에 대해 수출 규제를 시행하고 있습니다.

Bruce Schneier’s excellent book, Applied Cryptography (John Wiley & Sons), includes a table describing the time it would take to crack a DES cipher by guessing all keys, using 1995 technology and economics.† Excerpts of this table are shown in Table 14-1.

  • Bruce Scheneier의 저서 Applied Cryptography (John Wiley & Sons)에는 1995년도의 기술력과 경제력으로 DES Cipher를 해독하는 데 소요되는 시간을 나타낸 표가 포함되어 있습니다.

  • Table 14-1은 이 표의 일부입니다.

Given the speed of 1995 microprocessors, an attacker willing to spend $100,000 in 1995 could break a 40-bit DES code in about 2 seconds. And computers in 2002 already are 20 times faster than they were in 1995. Unless the users change keys frequently, 40-bit keys are not safe against motivated opponents.

  • 1995년의 마이크로프로세서 속도로 100,000달러를 소비한 공격자는 40비트 DES 코드를 약 2초만에 해독할 수 있습니다.

  • 2002년의 컴퓨터는 1995년에 비해 20배 가량 빨라졌습니다.

  • 사용자가 키를 빈번하게 바꾸지 않는 한 40비트의 키는 더 이상 공격자로부터 안전하지 않습니다.

The DES standard key size of 56 bits is more secure. In 1995 economics, a $1 million assault still would take several hours to crack the code. But a person with access to supercomputers could crack the code by brute force in a matter of seconds. In contrast, 128-bit DES keys, similar in size to Triple-DES keys, are believed to be
effectively unbreakable by anyone, at any cost, using a brute-force attack.

  • 56비트의 DES 표준 키 사이즈는 보다 안전합니다.

  • 1995년의 경제 수준을 기준으로 백만 달러를 소모하더라도 암호를 해독하기 위해 몇 시간이 소요됩니다.

  • 하지만 슈퍼컴퓨터를 사용하여 접근하는 사용자는 브루트포스를 통해 몇 초만에 암호를 해독할 수 있습니다.

  • 반면 Triple-DES 키와 크기가 비슷한 128비트의 DES 키는 브루투포스 공격을 사용하여 누구도 깨뜨릴 수 없는 것으로 알려져 있습니다.


Establishing Shared Keys

One disadvantage of symmetric-key ciphers is that both the sender and receiver have to have a shared secret key before they can talk to each other.

  • Symemtric-Key Cipher는 서로 통신을 진행하기 전에 송신자와 수신자가 동일한 비밀 키를 공유하고 있어야 한다는 문제가 있습니다.

If you wanted to talk securely with Joe’s Hardware store, perhaps to order some wood-working tools after watching a home-improvement program on public television, you’d have to establish a private secret key between you and www.joes-hardware.com before you could order anything securely. You’d need a way to generate the secret key and to remember it. Both you and Joe’s Hardware, and every other Internet user, would have thousands of keys to generate and remember.

  • 여러분이 공중파 TV에서 집 수리 프로그램을 시청한 후 목공 도구를 구매하고자 하는 상황입니다.

  • Joe's Hardware 상점과 안전하게 통신을 진행하고 싶다면 물건을 주문하기 전에 먼저 www.jodes-hardware.com과 비공개 비밀 키를 설정해야 합니다.

  • 비밀 키를 생성하고 기억할 수 있는 방법도 필요합니다.

  • 여러분과 Joe's Hardware, 그리고 다른 모든 인터넷의 사용자들은 생성하고 기억해야 하는 수천 개의 키를 가지고 있을 것입니다.

Say that Alice(A), Bob(B), and Chris(C) all wanted to talk to Joe’s Hardware(J). A, B, and C each would need to establish their own secret keys with J. A would need key kAJ, B would need key kBJ, and C would need key kCJ. Every pair of communicating parties needs its own private key. If there are N nodes, and each node has to talk securely with all the other N–1 nodes, there are roughly N^2 total secret keys: an administrative nightmare.

  • Alice(A), Bob(B), Chris(C)가 모두 Joe's Hardware와 통신하려 하는 상황이라고 가정해봅시다.

  • 우선 A, B, C는 각각 자신의 비밀 키 J를 설정해야 합니다.

  • A는 kAJ, B는 kBJ, C는 kCJ가 필요할 것입니다.

  • 통신중인 모든 그룹쌍은 고유한 비밀키를 요구합니다.

  • 만약 N개의 노드가 있고 각각의 노드가 다른 N-1개의 노드와 안전하게 통신해야 하는 상황이라면, 약 N^2개의 비밀 키가 필요하게 됩니다.

  • 이러한 경우 관리에 어려움을 겪을 수 있습니다.


✏️ 요약


Symmetric-Key Cryptography

: 송신자와 수신자가 동일한 공유 비밀 키를 사용하여 암호화 및 복호화를 수행하는 기술

  • Decryption : P=D(C,k)
  • Encryption : C=E(P,k)
  • Enumeration Attack : 브루트포스 방식으로 모든 키 값을 시도하는 공격 기법
  • 비트 수가 많고 유효한 키의 개수가 많을수록 가능한 키의 경우의 수 증가
  • 수많은 연결에 대하여 비밀 키를 생성하고 유지하기 어려울 수 있음

✏️ 감상


128비트 Symmetric Key는 지금도 안전할까

56비트의 키를 사용하는 DES(Data Encryption Standard)는 1999년도에 이미 22시간 정도 가량의 연산을 거쳐 해독에 성공했다. 시간이 흘러 DES를 보완한 3DES(Triple-DES) 기법이 등장했다. 3DES는 DES 알고리즘을 세 번 반복해서 적용한다. 즉 Plaintext를 K1으로 암호화한 Ciphertext를 다시 K2로 암호화하고, 그것을 K3로 한 번 더 암호화한다(혹은 두 개의 키만 사용하기도 한다). 초기의 3DES는 DES와 마찬가지로 parity bit를 제외하고 각각의 키가 56비트 사이즈를 가졌다. 하지만 지금은 112비트, 168비트까지 지원한다.

3DES는 DES에 비해 보안이 강화된 방식이지만 현재 기준으로는 얘도 별로 안전한 녀석이 아니다(...) 2016년에 OpenSSL은 3DES를 "weak cipher"로 지정하였으며, NIST 또한 2017년에 deprecation이 예정되어 있음을 발표했다. 3DES는 64비트의 블록으로 데이터를 분할하여 암호화하는 방식을 사용하고 있는데, 이 방식은 대규모 데이터에서 충돌 확률을 높인다. Birthday Paradox라고 생각하면 된다. 위 현상을 악용한 공격이 바로 Sweet32다. Sweet32 공격을 완벽히 성공하기 위해서는 약 785GB만큼의 데이터를 암호화해야 하지만 실제로는 약 백만 블록만에 충돌을 발견할 수 있다. 당시에 충돌을 발견할 때까지 소요된 시간은 약 25분이었다.

그래서 지금은 AES(Advanced Encryption Standard)를 사용한다. AES도 동일한 Block Cipher 방식을 사용하지만 한 블록당 사이즈가 128비트로 증가하였다. 블록의 사이즈가 증가한 만큼 주어진 데이터만으로 충돌을 발견할 확률이 현저히 줄어들었다. 키의 사이즈도 3DES보다 개선되어 최대 256비트까지 지원하고 있다.

https://en.wikipedia.org/wiki/Data_Encryption_Standard
https://en.wikipedia.org/wiki/Triple_DES
https://en.wikipedia.org/wiki/Advanced_Encryption_Standard

재밌으니까 심심할 때 읽어보시길... ><

profile
틈틈이 두 페이지씩 원서 읽기

0개의 댓글