Computer Science/Computer Network

8. Security

  • -
728x90
반응형

Motivation

  1. Field of network security
    • how bad agents can attack computer networks
    • how we can defend networks against attacks
    • how to design architectures that are immune to attacks
  1. Internet not originally designed with (much) security in mind
    • original vision : “a group of mutually trusting users attached to a transparent network
    • Internet protocol designers playing “catch-up”
    • security considerations in all layers

      → OSI의 각 layer에서 security와 관련된 issue를 다뤄야한다는 것

Bad Agent Example

Packet Interception

Packet sniffing

  • broadcast media (shared Ethernet, wireless)
  • promiscuous network interface reads/records all packets (e.g. including passwords) passing by
💡
packet sniffing은 네트워크에서 packet를 가로채는 행위를 의미한다. 이를 통해 네트워크의 성능 문제를 진단하거나 보안 문제를 탐지할 수 있다. 하지만, 반대로 악의적인 목적으로도 이용할 수 있다. 이를 통해 비밀번호 등을 가로챌 수 있기 때문이다.
💡
일반적으로 NIC는 자신에게 전송된 packet만 읽고 저장하지만, promiscuous mode에서의 NIC는 네트워크 상의 모든 packet를 읽고 기록할 수 있다.

Denial of service (DoS)

Attackers make resources (server, bandwidth) unavailable to legitimate traffic by overwhelming resource with bogus(illegal) traffic

  1. Select target
  1. Break into hosts around the network
  1. Send packets to target from compromised hosts

Fake Identity : IP spoofing

Send packet with false source address

Lines of Defense

  1. Confidentiality via encryption : 암호화를 통해서 정보의 기밀성을 보장하는 것. 즉, 허가되지 않은 사람들이 해당 내용을 읽거나 해독할 수 없게끔하는 것
  1. Authentication : 본인 확인 절차이다. 예를 들어 휴대폰의 SIM 카드는 사용자가 네트워크에 인증하도록 돕는 역할을 수행한다.
  1. Integrity checks : digital signature를 통해 데이터가 변경되거나 조작되는 것을 방지하거나 탐지하게 된다.
  1. Access restrictions : 비밀번호로 접근을 제한시키거나 Virtual Private Network(VPN)의 사용등으로 접근을 제한하는 것이다. 즉 미인증된 사용자가 민감한 resource에 접근하는 것을 막는다.
  1. Firewalls : 네트워크의 접근 및 핵심 부분에 위치한 specialized된 device이다.

    → 기본적으로 모든 것을 차단하고 필터링 규칙에 따라 특정 패킷만을 통과시킨다. 이에 따라 DoS 공격과 같은 보안 위협을 감지하고 대응할 수 있게 된다.

Goals of Network Security

  1. Confidentiality : 수신자와 의도된 receiver가 해당 message의 내용을 이해할 수 있어야 한다.
    1. sender encrypts message
    1. receiver decrypts message
  1. Authentication : sender, receiver want to confirm identity of each other
  1. Message integrity : sender, receiver want to ensure message not altered without detection
  1. Access and availability : services must be accessible and available to users

    → AoS같은 상황이 일어나면 안된다는 것이다.

Principles of Cryptography : Symmetric Key

The Language of Cryptography

💡
즉, encryption과 decryption을 거치면 원래 message가 나올 수 있게끔 해야한다.

Breaking an Encryption Scheme

We can distinguish three different scenarios, depending on what information the intruder has

Cipher-text only attack

Trudy want to analyze the cipher-text so that he want to find the original message or public key

→ With no certain information about the contents of the plain text message

There is two approach

  1. brute force : search through all keys
  1. statistical analysis
💡
위 방법에서는 Trudy가 암호화된 메세지(cipher-text)만 가지고 있는 상황이다.

Known-plaintext attack

In this case, the intruder know for sure that some words appeared in the cipher-text message. By using that information, the intruder can determined the (plaintext, cipher-text) pairings for some letters.

💡
즉, intruder가 (plaintext, ciphertext) pairing을 일부 아는 경우를 known-plaintext attack이라고 한다.

Chosen-plaintext attack

In this approach, trudy can get cipher-text for chosen plaintext

→ 원하는 plaintext를 선택하고 그 정보로부터 사용된 암호화 키나 알고리즘을 찾아내려고 하는 것이다.

Symmetric Key Cryptography

Sender와 Receiver가 동일한 key KSK_S를 사용하는 것이다.

예를 들어 다음과 같은 상황을 생각하면 된다.

하지만 이와 같은 방식은 statistical analysis 공격에 취약할 수 밖에 없다.

  1. e, t는 일반적인 영어에서 통계적으로 가장 빈번하게 사용된다는 점을 이용할 수 있다.
  1. 추가적으로 in, it, the, ion, ing 같은 단어들이 자주 사용된다는 점 또한 이용할 수 있다.

→ 이러한 취약점을 바탕으로 이러한 암호화방식을 쉽게 깰 수 있다.

  • Q : How do Bob and Alice agree on key value?
    1. 보안된 online channel
    1. Public Key Cryptography : 각자의 비밀키와 공개키 쌍을 생성하고, 서로의 공개키로 메세지를 암호화하여 전송한다.

Simple Encryption Scheme

  • Substitution cipher : substituting one thing for another
    • monoalphabetic cipher : substitute one letter for another

A Better Encryption Approach

  • n substitution ciphers : M1,M2,,MnM_1, M_2, \dots, M_n
  • cycling pattern

    → ex : M1,M3,M4,M3,M2M_1, M_3, M_4, M_3, M_2

  • for each new plaintext symbol, use subsequent substitution pattern in cyclic pattern

    → ex : dog : d from M1M_1, o from M3M_3, g from M4M_4

Symmetric Key Crypto : DES

DES : Data Encryption Standard

  • US encryption standard
  • 56bit symmetric key, 64bit plaintext input
  • Block cipher with cipher block chaining : 이전 블록의 암호문이 다음 블록의 암호화에 영향을 주는 것이다.
  • How secure is DES?
    • 56bit key encrypted phrase decrypted in less than a day by using brute force
  • Making DES more secure

    3DES : encrypt 3 times with 3 different keys

Symmetric Key Crypto : AES

AES : Advanced Encryption Standard

  • Symmetric-key NIST standard, replaced DES
  • Processes data in 128 bit blocks
  • 128, 192 or 256 bit keys
  • Brute force decryption taking 1 sec on DES, takes 149 trillion years for AES

    → 그만큼 DES보다 AES가 더 안전한 암호화 방식이라는 것이다.

Principles of Cryptography : Public Key

  • Sender, receiver do no share secret key
  • public encryption key known to all
  • private decryption key known only to receiver
💡
즉, sender는 receiver의 public key를 활용해서 encryption을 한다. 그리고 해당 암호화된 packet이 receiver에게 도착하면 receiver의 private key를 이용하여 decryption을 하는 것이다.

Requirements

  1. need KB+K_B^{+} and KBK_B^{-} such that
    KB(KB+(m))=mK_B^{-}(K_B^{+}(m)) = m
  1. given public key KB+K_B^{+}, it should be impossible to compute private key KBK_B^{-}

→ 이를 만족하는 algorithm이 RSA 이다.

Prerequisite : modular arithmetic

  • x mod nx\text{ mod }n  : remainder of xx when divide by nn
  • Facts
    • {(a mod n)+(b mod n)} mod n=(a+b) mod n\{(a\text{ mod }n) + (b\text{ mod }n)\} \text{ mod }n = (a+b)\text{ mod }n
    • {(a mod n)(b mod n)} mod n=(ab) mod n\{(a\text{ mod }n) - (b\text{ mod }n)\} \text{ mod }n = (a-b)\text{ mod }n
    • {(a mod n)(b mod n)} mod n=(ab) mod n\{(a\text{ mod }n) * (b\text{ mod }n)\} \text{ mod }n = (a*b)\text{ mod }n
    • ay mod n=ay mod n mod na^y\text{ mod }n = a^{y\text{ mod }n}\text{ mod }n

    Therefore,

    (a mod n)d mod n=ad mod n(a\text{ mod }n)^d\text{ mod }n = a^d\text{ mod }n
  • Euler’s Theorem
    aϕ(n)=1(mod n)a^{\phi(n)}= 1(\text{mod } n)

    if GCD of aa and ϕ(n)\phi(n) is 1

    💡
    이때, ϕ(n)\phi(n)은 Euler phi function으로 n보다 작거나 같은 양의 정수 중 n과 서로소인 것들의 개수이다. 만약 nnn=pqn = pq (p,qp, q is prime)이면 ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1)이다.
    • Proof

      ϕ\phi is multiplicative. Therefore,

      ϕ(ab)=ϕ(a)ϕ(b)\phi(ab) = \phi(a)\phi(b)

      In addition, if aa is a prime

      ϕ(a)=a1\phi(a) = a - 1

      Therefore, if n=pqn = pq where p,qp, q are prime

      ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1)

Public Key Encryption : RSA

It uses 2 big prime numbers to generate public key and private key.

→ Since, it requires exponential calculation, it is computationally more intensive than DES

Therefore, in reality, we use public key crypto like RSA to establish secure connection, then establish second key (symmetric session key) for encrypting data

  • Session key : KSK_S
    • Bob and Alice use RSA to exchange a symmetric session key KSK_S
    • once both have KSK_S, they use symmetric key cryptography
💡
쉽게 말해서 연결을 안전하게 한 이후에는 symmetric session key를 생성해서 데이터를 암호화한다. 이를 통해 public key crypto의 보안성과 symmetric key crypto의 처리 속도 장점을 모두 활용할 수 있게 된다.
💡
추가적으로 이러한 session key 는 한 세션 동안만 사용되는 임시적인 암호화 키이다.

Note

  • message : just a bit pattern
  • bit pattern can be uniquely represented by an integer number

    → thus, encrypting a message is equivalent to encrypting a number

    💡
    예를 들어 10010001이라는 메세지가 있다고 했을 때 10진수로는 145로 유일하게 표현된다. 결과적으로 message를 encrypt한다는 것은 숫자를 encrypt한다는 것과 같은 말이다.

Creating public/private key pair

  1. Choose two large prime numbers p,qp, q
  1. Compute n=pqn = pq, z=ϕ(n)z = \phi(n)
  1. Choose ee (with e<n)e < n) that as no common factors with zz

    → By Euler’s theorem ez=1(mod n)e^z = 1 (\text{mod }n)

  1. Choose dd such that ed1ed - 1 is exactly divisible by zz

    ed mod z=1ed\text{ mod }z = 1

    Public key : (n,e)Private key : (n,d)\text{Public key : }(n, e) \\ \text{Private key : }(n, d)
    💡
    eezz가 서로소인 경우에는 해당하는 dd가 unique하다. 이러한 dd는 Extended Euclidean Algorithm을 통해 찾을 수 있다.

Encryption, decryption

  1. given (n,e)(n, e) and (n,d)(n, d) as computed above
  1. to encrypt message mm, compute
    c=me mod nc = m^e\text{ mod }n
    💡
    단순히 ee승 해주고 nn으로 modular 연산을 취해주면 된다.
  1. to decrypt received bit pattern cc, compute
    m=cdmod nm = c^d \text{mod }n
    💡
    단순히 dd승 해주고 nn으로 modular 연산을 취해주면 된다.

It works since

m=(me mod n)d mod n=med mod n=med mod n mod n=m1 mod n=m\begin{align} m &= (m^e\text{ mod }n)^d\text{ mod }n \\ &=m^{ed}\text{ mod }n \\ &=m^{ed\text{ mod }n}\text{ mod }n \\ &= m^1\text{ mod }n \\ &= m\end{align}
💡
nn은 굉장히 큰 2개의 소수들의 곱이므로 mm보다 항상 크다. 따라서 (5)가 성립한다. 추가적으로 (4)을 보면 왜 ed mod n=1ed\text{ mod }n = 1로 설정했는지 이해할 수 있다.

Example

Another Important property

KB(KB+(m))=KB+(KB(m))=mK_B^{-}(K_B^{+}(m)) = K_{B}^{+}(K_B^{-}(m)) = m

Security of RSA

Suppose you know the public key (n,e)(n, e). How hard is it to determine dd?

→ Essentially need to find factors of nn without knowing the two factors pp and qq

  • When pp and qq are known
    1. Find the value of Euler’s phi function : (p1)(q1)(p - 1)*(q-1)
    1. Find dd by following equation by using Extended Euclidean Algorithm
      ed mod z=ed mod ϕ(n)=1ed \text{ mod } z = ed\text{ mod }\phi(n) = 1
    💡
    ϕ(n)\phi(n)을 계산할 수 있으므로 dd를 쉽게 구할 수 있다.
  • When pp and qq are unknown
    1. Factorize nn
    1. Find the value of Euler’s phi function : (p1)(q1)(p - 1)*(q-1)
    1. Find dd by following equation by using Extended Euclidean Algorithm
      ed mod z=ed mod ϕ(n)=1ed \text{ mod } z = ed\text{ mod }\phi(n) = 1
    💡
    이때 1번 과정이 굉장히 어렵기 때문에 RSA Algorithm이 안전하다는 것이다. eezz가 소인수이기만 하면 dd의 유일성은 보장이 되고 고정된 ee에 대해서 소인수인 zz는 무한 개이므로 dd 또한 zz를 모르면 개수가 무한개이다.

Message Authentication and Integrity

Goal : Bob wants Alice to “prove” her identity to him

Protocol 1.0

But it has a problem

💡
즉 다시 말해서 network 상에서는 직접적으로 Alice를 볼 수 없기 때문에 intruder가 Alice라고 속일 수 있는 문제점이 발생한다.

Protocol 2.0

Alice says “I am Alice” in an IP packet containing her source IP address

💡
하지만 spoofing을 통해서 intruder가 source IP address를 바꾸게 되면 이를 구분할 수 없는 문제점이 발생한다.

Protocol 3.0

Alice says “I am Alice” and sends her secret password to “prove” it

💡
하지만 통신 경로가 안전하지 않은 경우, 이러한 네트워크 통신을 통해 password를 전송하면 password가 중간에 가로채일 수 있다. 이렇게 되면 문제가 발생할 수 있다.

Protocol 4.0

Goal : avoid playback attack

nonce : number (R) used only once in a life time

To prove Alive is “live”, Bob sends Alice nonce, R

→ Alice must return R, encrypted with shared secret key

→ 즉 nonce R을 Alice에게 보내고, Alice는 공유된 비밀 키로 암호화된 R을 반환함으로써 Authentication을 한다는 것이다.

💡
즉, protocol 4.0에서는 이미 안전하게 공유된 비밀 키를 가지고 있다고 가정한다.
💡
주의할 점은 해당 비밀키는 shared symmetric key 라는 것이다.

Protocol 5.0

앞서 언급한 것처럼 Protocol은 shared symmetric key를 사용한다. Protocol 5.0에서는 public key technique를 사용해서 보다 좀 더 안전하게 Authentication을 진행하려고 한다.

💡
nonce를 사용한다는 점에서는 Protocol 4.0과 동일하지만, public, private key를 사용한다는 점에서는 좀 더 안전하다.
💡
확인하는 방법은 private key는 Alice만 가지고 있을 것이므로 public key와 private key로 암호화한 R을 합성해서 R이 나오는지 여부를 체크하는 것이다. 그리고 Bob 입장에서는 public key를 활용해서 message를 암호화해서 보내면 안전하다고 생각하는 것이다. (물론 뒤에서 바로 나오지만, 안전하지 않다.)

But, it is not enough

But, there’s still a flaw in Protocol 5.0. It is called middle attack

→ Intruder poses as Alice to Bob. On the other hand, that intruder poses as Bob to Alice.

💡
즉, 중간에 껴서 모두를 속이는 것이다.
💡
중요한 점은 Intruder가 중간에 껴서 메세지를 가로챘다는 것을 모르게끔 하는 것이다. 그러한 측면에서는 문제가 없다.

Digital Signatures

Cryptographic technique analogous to hand-written signatures:

sender digitally signs document : he is document owner/creator

  • verifiable, non-forgetable

    → recipient can prove to someone else that only creater must have signed that document

  • simple digital signature for message mm
  1. Bob signs m by encrypting with his private key KBK_B^{-}
  1. The encrypted message is represented by KB(m)K_B^{-}(m)

Procedure

  1. Suppose Alice receives message mm, with signature : KB(m)K_B^{-}(m)
  1. Alice verifies mm signed by Bob by applying Bob’s public key KB+K_B^{+} to KB(m)K_B^{-}(m) then checks KB+(KB(m))=mK_B^{+}(K_B^{-}(m)) = m
  1. If KB+(KB(m))=mK_B^{+}(K_B^{-}(m)) = m, whoever signed mm must have used Bob’s private key

Alice thus verifies that

  1. Bob signed mm
  1. no one else signed mm
💡
Bob만이 Bob의 private key를 가질 수 있으므로 이를 담보할 수 있는 것이다.
  1. Bob signed mm and not mm'

non-repudiation : Alice can take mm, and signature KB(m)K_B^{-}(m) to court and prove that Bob signed mm

💡
Bob이 서명했다는 사실을 입증할 수 있고, 그 내용 또한 확인할 수 있으므로 인증으로의 역할을 수행할 수 있는 것이다.

Message Digests

However, it is computationally expensive to public-key-encrypt long messages

Goal : fixed length, easy to compute digital fingerprint

→ Use Hash function!

💡
즉 message의 크기를 Hash function을 통과시켜서 크기를 줄이고, 이거를 암호화시키는 방식을 취하겠다는 것이다.

Public Key Certification Authorities

  • Certification authority (CA) : Certification authority links the public key to a specific entity, E
  • Entity : An entity, such as an individual website or router, registers its public key with the CA. At this point, it must provide proof of identity to the CA
  • The CA then creates a certificate that binds the identity E to E’s public key
  • This created certificate includes E’s public key and is digitally signed by the CA - essentially stating “this is E’s public key”

When Alice wants Bob’s public key:

  1. Gets Bob’s certificate
  1. Apply CA’s public key to Bob’s certificate, get Bob’s public key
💡
즉 다시 말해서 Certificate Authority는 Digital Signature를 중간에서 담당해주는 기관이라고 할 수 있다.

Security Across TCP/IP Layers

Transport-layer Security (TLS)

  • Widely deployed security protocol above the transport layer

    → Supported by almost all browsers, web servers : https (port 443)

  • Provides
    1. confidentiality : via symmetric encryption
    1. integrity : via cryptographic hashing

      → sender가 보낼 message에 대한 hash 값을 생성하고, 해당 hash 값은 메세지와 함께 수신자에게 전송된다. 수신자 측에서는 받은 메세지로부터 동일한 hash function을 사용해서 새로운 hash 값을 생성한 뒤 이를 비교한다. 이를 통해 중간에 메세지가 변경되거나 손상되었는지 여부를 판단할 수 있다.

    1. authentication : via public key cryptography
  • What is needed
    1. handshake : Alice, Bob use their certificates, private keys to authenticate each other, and create session key
      💡
      일반적으로 server는 client에게 자신의 certificate를 보낸다. client가 해당 certificate를 보내면 CA의 public key를 활용하여 digital signature를 복호화하고 해당 값과 원본 인증서의 hash 값을 비교함으로써 유효성을 검사한다.
      💡
      실제로 public, private key는 매우 큰 2개의 소수의 곱을 사용하기 때문에 computational cost가 크다. 그래서 안전하게 handshaking을 진행한 이후에는 session key 를 이용해서 데이터를 주고받게 된다.
      • How to create a session key?
        1. premaster secret 생성: 클라이언트는 랜덤한 값을 premaster secret으로 선택한다.
        1. premaster secret 전송: 클라이언트는 이 premaster secret을 서버의 공개키로 암호화하여 서버에게 전송한다.
        1. master secret 생성: 서버는 자신의 개인 키로 premaster secret을 복호화하고, 클라이언트도 동일한 master secret을 가지고 있다. 그런 다음, 둘은 이 값을 기반으로 마스터 시크릿을 계산한다.
        1. session key 생성: 마지막으로, 클라이언트와 서버 모두 master secret, Client Hello 메시지의 랜덤 값, Server Hello 메시지의 랜덤 값을 사용하여 session key를 독자적으로 계산한다.
    1. key derivation : Alice, Bob use shared secret to derive set of keys
      💡
      해당 key들은 데이터 전송에 사용되며, symmetric encryption에 사용된다.
    1. data transfer
    1. connection closure : special messages to securely close connection
  • TLS provides an API that any application can use

IP Sec Protocol

  • Provides datagram level encryption, authentication, integrity for both user traffic and control traffic
  • Two modes
    1. transport mode
      • only datagram payload is encrypted, authenticated
    1. tunnel mode
      • entire datagram is encrypted, authenticated
      • encrypted datagram encapsulated in new datagram with new IP header, tunneled to destination
  • Two IPsec Protocols
    1. Authentication Header (AH) protocol

      → provides source authentication & data integrity but not confidentiality

    1. Encapsulation Security Protocol (ESP) protocol

      → provides source authentication, data integrity, and confidentiality

      💡
      More widely used than AH

Security Associations (SAs)

IPsec protocol은 network layer에서 security를 제공하기 위해서 데이터를 전송하기 위해 Security Association을 설정하는 것을 포함한다. 이때 security association는 single directional하므로 양방향 통신을 위해서는 2개의 security association이 필요하다.

  • Before sending data, security association established from sending to receiving entity
  • ending, receiving entities maintain state information about SA

Internet Key Exchange (IKE)

Internet Key Exchange는 IPsec 연결을 설정할 때 사용되는 protocol이다. 해당 protocol의 목적은 Security Association을 동적으로 형성하는 것이다.

→ 수작업으로 Security Association과 관련된 모든 정보들을 입력하는 것은 VPN 과 같이 endpoint들이 많은 환경에서는 적절하기 않다.

따라서 이러한 환경에서는 IKE가 사용된다.

IEEE 802.11 : Authentication, Encryption

For a mobile device to connect to an Access Point, it must go through the following steps

  1. Association : The mobile device establishes a connection with the AP over a wireless link
  1. Authentication : The mobile device must authenticate to the network via an Authentication Server (AS)

In this process, the Wi-Fi protected Access (WPA) protocol plays a key role. WPA provides a four-way handshake protocol for mutual authentication and derivation of shared symmetric session keys

→ WPA3 is the current version (2018)

Extensible Authentication Protocol (EAP) defines end to end request/response protocol between mobile device and AS

  • RADIUS protocol for transmission over UDP/IP to the authentication server
  • DIAMETER protocol is projected to eventually replace RADIUS

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.