Secure Messaging System

This document explains the process of encrypting messages using AES-256 and securing the keys with Kyber, a post-quantum cryptographic algorithm.

Overview

The goal is to securely encrypt packets of messages (binary files) using AES-256, with the AES session keys being securely exchanged using Kyber. This ensures robust security against both current and future cryptographic threats.

Steps

  1. Key Generation: Generate a pair of public and private keys for the recipient using Kyber.
  2. Encrypting Session Key: For each message, generate a 256-bit session key and encrypt the key using the recipient's Kyber public key.
  3. Encrypting Messages: Encrypt the message using AES-256 with the generated session key.
  4. Storing Encrypted Data: Store the encrypted session key and the encrypted message together in a file.
  5. Decrypting Session Key: The recipient decrypts the AES session key using their Kyber private key.
  6. Decrypting Messages: The recipient uses the decrypted AES session key to decrypt the message.

Flowchart

+-----------------------+
| Generate Kyber Keys |
| (Public & Private) |
+-----------------------+
|
V
+-----------------------+
| For each message: |
| 1. Encrypt session key|
| with Kyber |
+-----------------------+
|
V
+-----------------------+
| Encrypt message using |
| AES-256 with session |
| key |
+-----------------------+
|
V
+-----------------------+
| Store encrypted session|
| key and encrypted |
| message in a file |
+-----------------------+
|
V
+-----------------------+
| For decryption: |
| 1. Decrypt session key|
| with Kyber |
| 2. Decrypt message |
| with AES-256 using |
| session key |
+-----------------------+

Detailed Explanation

The process ensures that the message is encrypted securely and can only be decrypted by the intended recipient, leveraging the strengths of both Kyber and AES-256 to secure messages effectively.

Key Generation

Use Kyber to generate a public/private key pair for the recipient. The public key is used to encrypt encryption, the private key is used to decrypt them.

Encrypting the Session Key

For each message file, generate a random 256-bit AES session key. Use the recipient's Kyber public key to encrypt this AES session key, creating an encapsulated session key that can be safely transmitted.

Encrypting the Message

Encrypt the message content with AES-256 using the generated session key. AES-256 ensures the message is encrypted with strong, symmetric encryption.

Storing the Encrypted Data

Combine the encrypted session key and the AES-encrypted message into a single file. This file is stored or transmitted securely.

Decrypting the Session Key

The recipient receives the file, extracts the encrypted session key, and uses their Kyber private key to decrypt the session key.

Decrypting the Message

With the decrypted AES session key, the recipient decrypts the message content to retrieve the original message.

Conclusion

This process ensures secure key exchange using Kyber and message encryption using AES-256, following best practices for cryptographic security.