> For the complete documentation index, see [llms.txt](https://chunhthanhde.gitbook.io/google-learning-programs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chunhthanhde.gitbook.io/google-learning-programs/google-it-support-professional-certificate/course-5-it-security-defense-against-the-digital-dark-arts/module-2-pelcgbybtl-cryptology/2.public-key-or-asymmetric-encryption/2.asymmetric-vs-symmetric-cryptography.md).

# Asymmetric vs Symmetric Cryptography 🔑🔒

### **Comparison** 🌟

* **Asymmetric Encryption**:
  * **Strengths**: Allows secure communication over untrusted channels.
  * **Weaknesses**: Computationally expensive and complex.
  * **Use Case**: Ideal for securely exchanging keys.
* **Symmetric Encryption**:
  * **Strengths**: Faster and more efficient for encrypting large amounts of data.
  * **Weaknesses**: Requires a secure method to share the secret key.
  * **Use Case**: Suitable for efficient data encryption once the key is securely exchanged.

### **Hybrid Approach** 🔄

* **Combination**: Many secure communication systems use both types of encryption to leverage their strengths.
  * **Key Exchange**: Asymmetric encryption is used to securely transmit the symmetric key.
  * **Data Encryption**: Symmetric encryption is used for fast and efficient data encryption.

### **Message Authentication Codes (MACs)** 🛡️

* **Purpose**: Authenticate received messages and ensure data integrity.
  * **Difference from Digital Signatures**: Uses a shared secret key for both generating and verifying the MAC.
  * **Example**: HMAC (Keyed Hash Message Authentication Code).

### **HMAC (Keyed Hash Message Authentication Code)** 🔑🖥️

* **Function**: Uses a cryptographic hash function and a secret key.
  * **Hash Functions**: SHA-1, MD5, etc.
  * **Process**: Generate MAC, send with message, and verify by comparing computed MAC with received MAC.

### **CMAC (Cipher-Based Message Authentication Code)** 🔐

* **Function**: Uses a symmetric cipher and a shared key to generate a MAC.
  * **Block or Stream Ciphers**: DES, AES.
  * **Process**: Encrypt message using a block cipher in a specific mode.

### **CBC-MAC (Cipher Block Chaining Message Authentication Code)** 🔗

* **Mechanism**: Builds MACs using block ciphers in CBC mode.
  * **CBC Mode**: Incorporates previously encrypted blocks into subsequent blocks.
  * **Integrity**: Any modification to the plaintext results in a different final output, ensuring message integrity.

### **Summary** 📈

* **Asymmetric Encryption**: Secure key exchange, but slower.
* **Symmetric Encryption**: Fast data encryption, requires secure key sharing.
* **MACs**: Ensure message authenticity and integrity.
  * **HMAC**: Uses hash functions and a secret key.
  * **CMAC**: Uses symmetric ciphers for MAC generation.
  * **CBC-MAC**: Uses CBC mode to ensure data integrity.

🔒🔑📧
