개발 일기

[Information Security] Cryptographic Tools 본문

Computer Science/보안

[Information Security] Cryptographic Tools

개발 일기장 주인 2025. 3. 29. 16:42
Necessities of cryptographic tools for Information Security

1. Network Security
: Becuase messages are sent over a public network, so the packet could be intercepted and modified.

2. System Security
: The data in memory and storage is usually protected by access control mechanisms.However, it can still be vulnerable to attacks such as unauthorized access. So, the sensitive data should be encrypted.

🟠 Symmetric Encryption  ( ≒ Conventional Encryption ≒ Single-Key Encryption )

 

정의

universal technique for providing confidentiality for transmitted or stored data

 

two requirements for secure use

  1. strong encryption algorithm
  2. sender & receiver must have obtained copies of the secret key in a secure fashion and must keep it secure

🔸 Attacking Symmetric Encryption

  • Cryptanalytic Attacks
    • Rely on:
      Nature of the algorithm
      knowledge of the general characteristics of the plaintext
      some sample plaintext-ciphertext pairs

    • Exploits the characteristics of the algorithm to attempt to deduce(≒infer) a specific plaintext or the key being used
  • Brute-Force Attack
    • Try all possible keys until an intelligible translation into plaintext is obtained
      on average half of all possible keys must be tried to achieve success(2^(n-1))

🔸 Comparison of Three Popular Symmetric Encryption Algorithms

1. Data Encryption Standard (DES) ( ≒ Data Encryption Algorithm(DEA))

  • most widely used encryption
  • Uses 64bit plaintext block and 56bit key to produce a 64bit ciphertext block

  • Strength concerns:
    • DES is the most studied encryption algorithm in existence
    • use of 56bit key ➜ too short so, vulnerability to brute force.

2. Triple DES (3DES)

  • Repeats basic DES algorithm three times using either two or three unique keys
  • 168(= 56*3)bit key length overcomes the vulnerability to brute force attacks of DES

 

  • Drawbacks:
    • Algorithm is sluggish in software. (=speed is three times slower)
    • uses a 64bit block size so. complexity of birthday attack = 2^(64/2) = 2^32. 
      ➜ not so quite big

3. Advanced Encryption Standard(AES)

  • 3DES was not reasonable for long term use
  • Symmetric block cipher

 

Feistel vs SPN

더보기

Feistel vs SPN

블록 암호는 데이터를 고정된 크기(예: 64비트, 128비트)로 나누어 암호화하는데,
이때 암호 내부에서 데이터를 어떻게 변환하는지에 따라 Feistel 구조SPN 구조로 나뉘어.

설계 방식특징대표 알고리즘
Feistel 구조 입력을 두 부분으로 나누고, 한쪽을 변환하여 다른 쪽과 섞는 방식 DES, 3DES, Blowfish
SPN 구조 여러 번의 치환(Substitution)과 전치(Permutation) 연산을 반복 AES, PRESENT, Serpent

🟠 Practical Security Issues

블록 크기인 64/128bit보다 message가 더 길면?  이거 때매 Block & Stream Ciphers 이 개념이 나옴

Typically symmetric encryption is applied to a unit of data larger than a single 64-bit or 128-bit block.
(DES/Triple DES are 64bits and AES is 128bits)

 

1️⃣ Divide the message to shorter chunks and encrypt each independently with the same key

  • Electronic codebook (ECB) mode
  • simplest approach to multiple-block encryption
  • each block of plaintext is encrypted using the same key
  • cryptanalysts may be able to exploit the regularities in the plain text
    - if AAA/BCD/AAA is encrypted, than first block and third block result will be same.

2️⃣ Mode of operations

  • Adding inter-block interactions to prevent the repetition of identical blocks
  • overcomes the weakness of ECB
  • ex) CBC, CFB, OFB, CTR ...

🟠 Block & Stream Ciphers

🔸 Block Cipher

  • processes the input one block of elements at a time
  • produces an output block for each input block
  • reuse keys
  • more common

🔸 Stream Cipher

  • processes the input elements(bit/byte) continuously
  • produces output one element at a time
  • faster and use far less code
  • encrypts plaintext one byte (or bit) at a time
  • pseudorandom stream is one that is unpredictable without knowledge of the input key
    → gemerate stream key using pseudorandom stream
더보기

🔹 예시 1: 평문과 키 스트림 XOR 연산

  1. 평문 (M): "Hello"
    • 바이트 값: b"Hello" → [72, 101, 108, 108, 111]
  2. 키 스트림 (k): 0x3a, 0x9f, 0x2c, 0xa7, 0x48 (랜덤으로 생성된 예시 값)
    → 이때 키 스트림 k는 대칭키인 K를 Pseduorandom byte generator에 넣어서 생성된다.(Plain txt와 같은 길이)
    • 바이트 값: [58, 159, 44, 167, 72]
  3. XOR 연산:
    • 첫 번째 바이트: 72 ^ 58 = 114
    • 두 번째 바이트: 101 ^ 159 = 58
    • 세 번째 바이트: 108 ^ 44 = 64
    • 네 번째 바이트: 108 ^ 167 = 47
    • 다섯 번째 바이트: 111 ^ 72 = 39
  4. 암호문 (C):
    • 바이트 값: [114, 58, 64, 47, 39]
    • 16진수 표현: 72 3a 9f 2c a7 48 (암호화된 바이트)

복호화 시에도 똑같은 K를 pseudorandom byte generator에 넣으면 동일한 key stream k가 생성되어 XOR을 통해 복호화 가능


🟠 Message Authentication

🔸 Message Authentication without Confidentiality

  • msg encryption by itself doesn't provide a secure form of authentication
  • combine authentication and confidentiality in a single algorithm by encryption a message plus its authentication tag
  • when Message Authentication without Confidentiality prefer?
    1. same message is broadcast to a number of destinations
    2. one side has a havy load and cannot afford the time to decrypt all incoming messages
    3. authentication of a computer program in plaintext is an attractive service

 

🔸 Message Authentication using a Message Authentication Code (MAC)

 

   Why the MAC needed?

  1. Authenticating the Sender(truth authenticator)
  2. Message Integrity

MAC과 Hashing algorithm의 차이
MAC uses a secret key for authentication, while hashing is a keyless function for data integrity.

MAC uses a symmetric key 𝐾 K to generate a MAC, and since an attacker does not know 𝐾, they cannot create a valid MAC. So, It ensuring message integrity and authentication.

 

🔸 Message Authentication using on One-way Hash Function

1️⃣ Using Symmetric Encryption

  • Don't need confidentiality
  • For authentication
  • Comparing hashing value can ensure integrity

2️⃣ Using Public-Key Encryption

  • digital Signature
  • encrypted with private key, and decrypted with public key
  • Only sender know the private key. So, i can authenticate
  • Comparing hashing value can ensure integrity

 

3️⃣ Using Secret Value

 

Hash Function Requirements

1. can be applied to a block of data of any size
2. produces a fixed-length output
3. H(x) is relatively easy to cmpute for any given x
4. one-way or pre-image resistance: computationally infeasible to find x such that H(x) = h
5. weak collision resistance: computationally infeasible to find y ≠ x such that H(y) = H(x)
6. strong collision resistance: computationally infeasible to find any pair (x,y) such that H(x) = H(y)

🟠 Public-Key Encryption( Asymmetric encryption)

더보기

1. Encryption with Public Key (공개 키로 암호화)

  • 설명: 발신자가 받는 사람의 공개 키를 사용하여 메시지를 암호화하는 방식입니다.
  • 쓰임새:
    • **기밀성 (Confidentiality)**을 보장하기 위해 사용됩니다.
    • 공개 키는 누구나 알 수 있지만, 해당 공개 키에 대응하는 비공개 키는 오직 수신자만 알고 있습니다. 따라서 발신자는 수신자의 공개 키를 사용하여 메시지를 암호화하고, 수신자는 자신만이 알고 있는 비공개 키를 사용하여 암호화된 메시지를 복호화할 수 있습니다.
    • 예를 들어, Alice가 Bob에게 비밀 메시지를 보내고 싶을 때, Alice는 Bob의 공개 키로 메시지를 암호화합니다. 그 후, Bob만 자신의 비공개 키로 메시지를 복호화할 수 있습니다.
  • 장점:
    • 수신자는 자신의 비공개 키를 가지고 있기 때문에, 외부에서 메시지를 안전하게 암호화할 수 있습니다.
    • 전송되는 데이터는 중간에 누구나 볼 수 있지만, 암호화된 형태로만 존재하므로 보안성이 높습니다.

2. Encryption with Private Key (개인 키로 암호화)

  • 설명: 발신자가 자신의 개인 키를 사용하여 메시지를 암호화하는 방식입니다.
  • 쓰임새:
    • 인증 (Authentication) 및 **무결성 (Integrity)**을 보장하기 위해 사용됩니다.
    • 발신자가 자신의 비공개 키로 메시지를 암호화하면, 수신자는 발신자의 공개 키로 이를 복호화할 수 있습니다. 이를 통해 수신자는 해당 메시지가 발신자의 개인 키로 암호화되었음을 확인하고, 발신자가 실제로 보낸 메시지임을 인증할 수 있습니다.
    • 이 방식은 디지털 서명에서 사용됩니다. 예를 들어, Alice가 Bob에게 서명된 메시지를 보내고자 할 때, Alice는 자신의 비공개 키로 메시지를 암호화하여 서명합니다. Bob은 Alice의 공개 키로 이를 복호화하여, 메시지가 Alice에 의해 서명되었음을 확인할 수 있습니다.
  • 장점:
    • 메시지의 발신자 인증이 가능합니다.
    • 디지털 서명은 메시지가 전송 중에 변경되지 않았음을 증명할 수 있습니다.
    • 수신자는 공개 키로 서명을 확인하고, 메시지가 정확하게 전송되었음을 검증할 수 있습니다.

🔸 Digital Signature ( ≒ Encryption with Private Key)

  • the sender user encrypts data using his or her own private key to sign a message or document.
  • Anyone who knows the corresponding public key can decrypt the message.
  • Digital signatures provide authentication and integrity.

Symmetric Key Distribution

더보기

공개키 암호화를 이용한 대칭키 분배 과정

  1. 대칭키(세션 키) 생성
    • 송신자는 대칭키(세션 키)를 생성합니다. 이 키는 실제 메시지를 암호화하는 데 사용됩니다. 각 통신 세션에 대해 새로운 대칭키를 생성하여 보안성을 높입니다.
  2. 수신자의 공개키로 대칭키 암호화(encryption with receiver's public key)
    • 송신자는 생성한 대칭키를 수신자의 공개키로 암호화합니다. 이 과정은 대칭키를 안전하게 전송하는 방법입니다.
  3. 암호화된 대칭키 전송
    • 암호화된 대칭키는 수신자에게 전송됩니다. 이 암호화된 대칭키는 오직 수신자의 개인키로만 복호화할 수 있습니다.
  4. 수신자는 개인키로 대칭키 복호화(decryption with receiver's private key)
    • 수신자는 자신의 개인키를 사용하여 암호화된 대칭키를 복호화합니다. 이렇게 복호화된 대칭키는 송신자와 안전하게 공유된 키가 되어, 이후의 통신에서 메시지를 암호화하고 복호화하는 데 사용됩니다.
  5. 대칭키로 데이터 암호화
    • 이제 송신자와 수신자는 대칭키를 사용하여 메시지를 효율적으로 암호화하고 복호화

➜ encryption with receiver's public key/decryption with receiver's private key이게 Confidentiality를 보장해서 대칭키를 교환할 수 있는 것이다.

Requirements for Public-Key Cryptosystems

﹒Computationally easy to create key paris
﹒Computationally easy for sender knowing public key to encrypt messages
﹒Computationally easy for receiver knowing private key to decrypt ciphertext
﹒Computationally infeasible for opponent to determine private key from public key
﹒Computationally infeasible for opponent to otherwise recover original message
Useful if either key can be used for each role

🟠 Asymmetric Encryption Algorithms

  • RSA
    • most widely accepted and implemented approach to public-key encryption
    • block cipher in which the plaintext and ciphertext are integers between 0 and n-1 for some n.
  • Diffie-Hellman Key Exchange Algorithm
    • Enables tow users to securely reach agreement about a shared secret
    • that can be used as a secret key for subsequent symmetric encryption of messages
    • Limited to the exhcnage of the keys
  • Digital Signature Standard (DSS)
    • provides only a digital signature function with SHA-1
    • cannot be used for encryption or key exchange
      ➜ for integrity & authentication
  • Elliptic Curve Cryptography(ECC)
    • security like RSA, but with much smaller keys

🔸 Digital Signatures

  • 데이터 무결성과 신원 확인을 위해(For Data Integrity and Authentication)
  • 전자 서명은 메시지의 해시값을 송신자의 개인키로 암호화하여 서명을 생성하고, 수신자는 송신자의 공개키로 서명을 검증하여 메시지의 무결성과 송신자의 신원을 확인합니다.

  • used for authenticating both "source" and data "integrity"
  • created by encrypting hash code with "private key"
  • does not provide confidentiality
  • Message is safe from alteration but not eavesdropping

🔸 Public Key Certificate Use

Create signed digital certificate (특정 서버에 대한 SSL 인증서 발급)

  1. Generate hash code of unsigned certificate
    (unsigned certificate containes userID, user's public key, information concerning the CA)
  2. Generate digital signature using CA’s private key ➜ "Signed Certificate"

 

Use certificate to verify user's public key 

(클라이언트가 서버에 HTTPS 요청을 보낼 때, 서버는 자신의 SSL 인증서를 클라이언트에게 전달. 클라이언트는 이 인증서에 포함된 디지털 서명을 CA의 공개 키를 사용해 검증. 만약 서명이 유효하지 않거나 복호화가 되지 않으면, 해당 서버가 신뢰할 수 있는 인증 기관(CA)에 의해 공인된 서버가 아니라는 의미로 판단하여 "안전하지 않은 사이트" 경고를 표시.)

  1. Generate hash code of certificate not including signature
  2. Verify digital signature using CA's public key(decrypting)
  3. compare hash code and decrypted digital signature
  4. return signature valid or not valid

🔸 Digital Envelopes (symmetric encryption + public-key encryption)

  • 기밀성을 위한 것(For Confidentality)
  • 대칭키로 암호화한 메시지를 보낼 때, 수신자의 공개키로 암호화한 대칭키를 함께 보내고, 수신자는 자신의 개인키로 대칭키를 복호화하여 해당 대칭키로 메시지를 복호화하여 원본 메시지를 얻는다.
  • 송신 내용 암호화에 사용된 송신자의 비밀키(대칭키)를 수신자만 볼 수 있도록수신자의 공개키(비대칭키)로 암호화 시킨 전자화된 봉투

Creation of a Digital Envelope:

  1. The message is encrypted with a random symmetric key to create an encrypted message.
  2. The random symmetric key is then encrypted with the receiver's public key to generate an encrypted symmetric key.
  3. The digital envelope consists of the encrypted message and the encrypted symmetric key.

Opening a Digital Envelope:

  1. The digital envelope is separated into the encrypted message and the encrypted symmetric key.
  2. The receiver decrypts the encrypted symmetric key using their private key.
  3. The receiver then decrypts the encrypted message using the decrypted symmetric key to obtain the original message.

🟠 Random Numbers

  • keys for public-key algorithms
    (because every users need to have different key pair for security)
  • stream key for symmetric stream cipher
    무조건 비대칭키에만 쓰이는 것은 아님(대칭키의 stream cipher에서 stream key 생성 시 사용)
  • symmetric key for use as a temporary session key or in creating a digital envelope
  • handshaking to prevent replay attacks
  • session key
Requirements of Random Number

Randomness
- uniform distribution
- independence

Unpredictability
- each number is statistically independent
- should not be able to predict

🔸 True random number generator (TRNG - Random)

  • nondeterministic source to produce randomness
  • statistically random
  • most operate by measuring unpredictable natural processes
  • increasingly provided on modern processors

🔸 Pseudorandom

  • deterministic algorithms and produced sequences of numbers that are not statistically random
  • sequences produced that satisfy statistical randomness tests
  • likely to be predictable (created by some algorithms but observer cannot find regularities)

Common to encrypt transmitted data, Much less common for stored data

 

Iphone's Secure Enclave