본문 바로가기

Security

AES GCM

Authenticated Encryption 방식 중의 하나입니다. Authenticated Encryption은 데이타를 암호화하면서 암호문에 대한 무결성을 제공해줍니다. ( 암호문이 중간에 바뀌었는지 그대로인지 확인할 수 있도록 해줍니다. )

en.wikipedia.org/wiki/Authenticated_encryption

 

Authenticated encryption - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Authenticated encryption (AE) and authenticated encryption with associated data (AEAD) are forms of encryption which simultaneously assure the confidentiality and authenticity of data.

en.wikipedia.org

 

AES CTR 방식으로 암호화를 하면서 동시에 cipher text의 MAC을 추가함으로써 authenticity(integrity)를 제공해줍니다.

 

AES CTR : en.wikipedia.org/wiki/Block_cipher_mode_of_operation#CTR

AES GCM : en.wikipedia.org/wiki/Block_cipher_mode_of_operation#GCM


AES GCM Encryption 입력

Plain Text 암호화할 대상 데이터입니다.
Key 대칭키이므로 암호화/복호화 시 동일한 Key가 사용됩니다.
Key length는 128, 256 bit 등등
IV(Initial Vector) 길이에 제한은 없지만 NIST 권고사항(csrc.nist.gov/publications/detail/sp/800-38d/final) 은 96 bit입니다.
AAD AAD(Additional Authentication Data), Authentication Code, Associated Data Header 등 여러 이름으로 불리웁니다.
AAD는 암호화되지 않으며 아래 Authentication Tag를 생성하는데 사용됩니다.

AES GCM Encryption 출력

Cipher Text Plain Text가 암호화된 데이터입니다.
Authentication Tag AAD와 Cipher Text를 대상으로 하는 일종의 MAC 값으로 대상의 위변조를 확인하는데 사용됩니다.

AES GCM Decryption 입력

Cipher Text 복호화를 수행할 대상 데이터입니다.
Authentication Tag Cipher Text가 변경되었는지 확인하기 위한 값입니다.
Key 비밀리에 전달되어야 합니다.
IV(Initial Vector) 비밀은 아니지만 암호화할 때와 동일한 IV가 사용되어야 합니다.
AAD 비밀이 아니지만 암호화할 때와 동일한 AAD가 사용되어야 합니다.

AES GCM Decryption 출력

Plain Text 복호화된 메세지 원문입니다. Authentication Tag 검증 시 중간에 바뀌었다고 판단되는 경우 Plain Text를 출력하지 않습니다.

주의사항

AES GCM에서는 IV가 Key만큼이나 중요합니다.

  • AES GCM 암호화 할때 마다 다른 IV를 사용해야 합니다.
  • 이 IV는 충분히 unique해야 합니다.

 

 

NIST 권고문 -  nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf

 

 

Android Developer Site -  developer.android.com/reference/javax/crypto/Cipher

'Security' 카테고리의 다른 글

OpenSSL을 이용한 ECDSA 시뮬레이션  (0) 2021.02.15