AES - Advanced Encryption Standard

What is AES?

AES stands for Advanced Encryption Standard. It’s a symmetric encryption algorithm used to securely encrypt and decrypt data. AES is widely used to protect sensitive information in files, emails, network communications, and databases.

Why is AES useful?

  • Data privacy and security are critical today. AES helps by: * Encrypting data so unauthorized users can’t read it. * Ensuring confidentiality during storage or transmission. * Providing fast, strong encryption resistant to attacks. * Without AES, sensitive data like passwords and financial info could be easily intercepted.

How it works?

  • Key generation – A secret key (128, 192, or 256 bits) is chosen, shared by sender and receiver.

  • Encryption – Plaintext is transformed into ciphertext using AES and the key.

  • Transmission/Storage – Ciphertext is sent or stored securely.

  • Decryption – The receiver uses the key to restore plaintext from ciphertext.

Where is AES used?

  • Secure websites (HTTPS) encrypt web traffic.

  • Wi-Fi security (WPA2/WPA3) uses AES.

  • File encryption tools (BitLocker, VeraCrypt, 7-Zip).

  • Messaging apps with end-to-end encryption (Signal, WhatsApp).

  • VPNs and secure tunnels to protect data in transit.

Which OSI layer does this protocol belong to?

  • AES operates primarily at the Presentation Layer (Layer 6).

  • Encryption/decryption transform data before it reaches the application.

  • It ensures confidentiality and proper formatting for application consumption.

Is AES Windows specific?

No. * AES is a widely used symmetric encryption algorithm. * It is platform-independent and implemented across Windows, Linux, macOS, and more.

Is AES Linux specific?

No. * AES is not Linux specific. * Supported on Linux through numerous cryptographic libraries.

Which Transport Protocol is used by AES?

  • AES is an encryption algorithm, not a protocol.

  • It can be used within protocols like TLS (which uses TCP), IPSec (which can use UDP or TCP), etc.

Which Port is used by AES?

  • AES itself does not use any ports.

  • Ports depend on the protocol (e.g., HTTPS uses TCP 443) that employs AES encryption.

Is AES using Client server model?

No. * AES is a cryptographic algorithm, not a communication model. * It can be used in both client-server and peer-to-peer communication for encrypting data.

  • In this section, you are going to learn

  • Terminology

  • Version Info

AES Version

AES Number

Year

Core Idea / Contribution

AES (Rijndael)

FIPS PUB 197

2001

Standardized the Rijndael block cipher as AES. Supports 128-bit block size with 128, 192, or 256-bit keys. Selected after a 5-year public competition by NIST.

AES Update

FIPS PUB 197 (Revised)

2023

Editorial update onlyno technical changes. Improved formatting, added diagrams, clarified definitions.

AES in Internet Protocols

RFC 3602 (AES-CBC), RFC 5116 (AES-GCM)

2003 / 2008

Specifies how AES is used in IPsec and other protocols. AES-CBC and AES-GCM modes defined for secure communication.

AES IPsec VPN Setup on Ubuntu with strongSwan(IPv4)

  • This guide explains how to configure a basic AES-encrypted IPsec VPN tunnel between two Ubuntu machines.

Prerequisites:

  • Two Ubuntu machines:

    • Server IP: 192.168.56.10 (test1)

    • Client IP: 192.168.56.11 (test2)

  • Both machines have strongSwan installed.

  • UFW firewall enabled (optional but recommended).

  • Step 1: Install strongSwan

On both machines, run:

test1:~$sudo apt update
test1:~$sudo apt install strongswan
test2:~$sudo apt update
test2:~$sudo apt install strongswan
  • Step 2: Configure IPsec

### Server Configuration (/etc/ipsec.conf)

config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn aesvpn
    auto=add
    keyexchange=ikev2
    authby=secret
    left=192.168.56.10
    leftid=@server
    leftsubnet=192.168.56.0/24
    right=192.168.56.11
    rightid=@client
    rightsubnet=192.168.56.0/24
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256!

### Client Configuration (/etc/ipsec.conf)

config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn aesvpn
    auto=start
    keyexchange=ikev2
    authby=secret
    left=192.168.56.11
    leftid=@client
    leftsubnet=192.168.56.0/24
    right=192.168.56.10
    rightid=@server
    rightsubnet=192.168.56.0/24
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256!
  • Step 3: Set Pre-Shared Key

On both machines, edit /etc/ipsec.secrets to add:

test1:~$@server @client : PSK "SuperSecretKey123!"
test2:~$@client @server : PSK "SuperSecretKey123!"
  • Step 4: Configure UFW Firewall Rules

test1:~$sudo ufw allow 500,4500/udp
test1:~$sudo ufw allow in proto esp from 192.168.56.11
test1:~$sudo ufw allow out proto esp to 192.168.56.11
test1:~$sudo ufw reload
test2:~$sudo ufw allow 500,4500/udp
test2:~$sudo ufw allow in proto esp from 192.168.56.10
test2:~$sudo ufw allow out proto esp to 192.168.56.10
test2:~$sudo ufw reload
  • Step 5: Start and Enable strongSwan Service

On both machines:

test1:~$sudo ipsec restart
test2:~$sudo ipsec restart
  • Step 6: Initiate the VPN Connection

test2:~$sudo ipsec up aesvpn
**Example Output:**

initiating IKE_SA aesvpn[1] to 192.168.56.10
generating IKE_AUTH request 1 [ IDi CERTREQ ]
sending packet: from 192.168.56.11[4500] to 192.168.56.10[4500] (1400 bytes)
received packet: from 192.168.56.10[4500] to 192.168.56.11[4500] (1400 bytes)
parsed IDr payload: ID_IPV4_ADDR: 192.168.56.10
received CERT request for "C=US, O=strongSwan, CN=server"
sending packet: from 192.168.56.11[4500] to 192.168.56.10[4500] (1400 bytes)
IKE_AUTH response processed
established IKE_SA aesvpn[1] successfully
establishing CHILD_SA aesvpn{1}
sending packet: from 192.168.56.11[4500] to 192.168.56.10[4500] (1400 bytes)
received packet: from 192.168.56.10[4500] to 192.168.56.11[4500] (1400 bytes)
established CHILD_SA aesvpn{1} successfully

(Optional) On the server machine:

test1:~$sudo ipsec up aesvpn
  • Step 7: Verify VPN Status

On either machine, check the IPsec connection status:

test1:~$sudo ipsec statusall
**Example Output:**
Security Associations (1 up, 0 connecting):
   aesvpn[1]: ESTABLISHED 4 minutes ago, 192.168.56.11[client]...192.168.56.10[server]
   IKEv2 SPIs: 123456789abcdef0_i 123456789abcdef0_r, rekeying in 10 minutes
   CHILD_SA aesvpn{1}: INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: c3f8e1a3_i 7d4b2c6e_o
   AES_CBC_256/HMAC_SHA2_256_128/NO_EXT_SEQ
   lifetime: 1h0m, bytes_i: 1500, bytes_o: 1200

   Connections:
   aesvpn: 192.168.56.11...192.168.56.10 IKEv2, dpddelay=30s
  • Step 8: Test Connectivity

test2:~$ping 192.168.56.10
  • Step 9: Capture IPsec (AES) Packets with Wireshark

  • Launch Wireshark on either machine.

  • Use the filter to capture ESP (IPsec encrypted) packets:

  • You should observe ESP packets flowing between 192.168.56.10 and 192.168.56.11.

  • Step-10: Capture the test using Wireshark.

    Download Wireshark capture

How to Decrypt IPsec ESP Packets in Wireshark

ESP traffic is encrypted using session keys negotiated during the IKE exchange. Decryption is only possible under specific conditions.

Option 1: Using strongSwan’s charon log (IKEv2)

Wireshark can use the IKE traffic (captured during tunnel setup) to derive ESP keys if:

  • You captured the IKE_SA negotiation (UDP 500 or 4500).

  • The encryption uses IKEv2 and no PFS (Perfect Forward Secrecy), or keys are known.

  • You have the pre-shared key (PSK) used.

Steps:

  1. Capture the full handshake (IKE_SA and CHILD_SA).

  2. In Wireshark: - Go to EditPreferencesProtocolsISAKMP. - Set the “IKEv2 decryption table” with: - Initiator/responder IPs - PSK: “SuperSecretKey123!”

  3. Enable ESP decryption in Protocols → ESP.

  4. Wireshark will automatically attempt to decrypt the ESP stream.

Option 2: Exporting Keys Manually (Advanced)

You can patch strongSwan to log keys to a file (requires rebuild with debug options), or use external plugins to extract keys. This method is complex and not always reliable.

Important Note:

IPsec use Perfect Forward Secrecy (PFS) with ephemeral keys, so you cannot decrypt ESP traffic by default without capturing the IKE negotiation or extracting keys in real time.

Apache HTTPS and SSL Key Logging with AES Encryption Test Case (loaclhost)

  • To verify that an Apache HTTPS server can be configured with a self-signed SSL certificate, and HTTPS traffic can be decrypted using SSL key logging and Wireshark.

  • Step-1: Install Apache Web Server

    test:~$ sudo apt update
    test:~$ sudo apt install apache2 -y
    
  • Step-2: Allow Apache through the firewall

    test:~$ sudo ufw allow 'Apache Full'
    test:~$ sudo ufw enable
    test:~$ sudo ufw status
    
  • Step-3: Generate a self-signed SSL certificate

    test:~$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/ssl/private/selfsigned.key \
    -out /etc/ssl/certs/selfsigned.crt
    

    Enter values when prompted:

    • Country: IN

    • State: Karnataka

    • City: Bangalore

    • Organization: Personal

    • Organizational Unit: IT

    • Common Name: localhost

  • Step-4: Configure Apache for SSL

    test:~$ sudo nano /etc/apache2/sites-available/selfsigned.conf
    

    Paste the following:

    <VirtualHost * :443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
    
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/selfsigned.crt
        SSLCertificateKeyFile /etc/ssl/private/selfsigned.key
    
        <Directory /var/www/html>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
  • Step-5: Enable SSL module and site configuration

    test:~$ sudo a2enmod ssl
    test:~$ sudo a2ensite selfsigned.conf
    test:~$ sudo systemctl reload apache2
    
  • Step-6: Create a custom HTML page

    test:~$ cd /var/www/html
    test:~$ sudo mv index.html index.html.bak
    test:~$ sudo nano index.html
    

    Paste the following HTML:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>My Custom Page</title>
    </head>
    <body>
      <h1>Welcome to My Website!</h1>
      <p>This is a custom page served by Apache on HTTPS.</p>
    </body>
    </html>
    
  • Step-7: Set file permissions

    test:~$ sudo chown www-data:www-data /var/www/html/index.html
    test:~$ sudo chmod 644 /var/www/html/index.html
    
  • Step-8: Restart Apache

    test:~$ sudo systemctl restart apache2
    
  • Step-9: Test HTTPS in browser

    Open your browser and go to: https://localhost

    You should see your custom HTML page over HTTPS.

  • Step-10: Export SSL Key Log Environment Variable

    test:~$ export SSLKEYLOGFILE=$HOME/sslkeys.log
    
  • Step-11: Make an HTTPS request using curl

    test:~$ curl -k https://localhost
    

    Expected output:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>My Custom Page</title>
    </head>
    <body>
      <h1>Welcome to My Website!</h1>
      <p>This is a custom page served by Apache on HTTPS.</p>
    </body>
    </html>
    
  • Step-12: Confirm that SSL keys were logged

    test:~$ cat ~/sslkeys.log
    

    Example contents:

    CLIENT_HANDSHAKE_TRAFFIC_SECRET ...
    SERVER_HANDSHAKE_TRAFFIC_SECRET ...
    CLIENT_TRAFFIC_SECRET_0 ...
    SERVER_TRAFFIC_SECRET_0 ...
    EXPORTER_SECRET ...
    
  • Step-13: Capture HTTPS traffic using Wireshark

    • Start Wireshark and select the appropriate network interface

    • Begin packet capture

    • Do curl -k https://localhost

    • Stop the capture after traffic is generated

  • Step-14: Configure Wireshark to use SSL key log

    • Go to: Edit > Preferences > Protocols > TLS

    • Set (Pre)-Master-Secret log filename to: /home/username/sslkeys.log

    • Click OK

    • Reload the capture file

  • Expected result:

    • Apache serves the custom HTML page via HTTPS

    • curl and browser successfully connect

    • SSL keys are logged in sslkeys.log

    • Wireshark captures:

      • TLS handshake and application data

      • Decrypted HTTP packets when filtered by http

  • Step-15: Wireshark Capture

    Download wireshark capture

HTTPS Traffic Inspection Using SSLKeyLog Between Client Server

  • To verify that HTTPS traffic between a client and a server can be decrypted using SSL key logging and inspected in Wireshark.

  • SERVER SETUP — 192.168.0.10

  • Step-1: Set a static IP (if not already configured)

    test1$ ip a
    

    Confirm that the server’s IP is 192.168.0.10. If not, configure a static IP using /etc/netplan or your network manager.

  • Step-2: Apache HTTPS Setup

    If not already done, install Apache and configure SSL:

    test1$ sudo apt update
    test1$ sudo apt install apache2 openssl -y
    

    Generate a self-signed certificate (make sure CN = 192.168.0.10):

    test1$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
      -keyout /etc/ssl/private/selfsigned.key \
      -out /etc/ssl/certs/selfsigned.crt
    

    Configure Apache virtual host:

      test1$ sudo nano /etc/apache2/sites-available/selfsigned.conf
    
    Paste the following config:
    
    .. code-block:: apache
    
       <VirtualHost * :443>
        ServerName 192.168.0.10
        DocumentRoot /var/www/html
    
       SSLEngine on
       SSLCertificateFile /etc/ssl/certs/selfsigned.crt
       SSLCertificateKeyFile /etc/ssl/private/selfsigned.key
    
       <Directory /var/www/html>
           Require all granted
       </Directory>
       </VirtualHost>
    

    Enable the SSL site and module:

    test1$ sudo a2enmod ssl
    test1$ sudo a2ensite selfsigned.conf
    test1$ sudo systemctl restart apache2
    
  • Step-3: Confirm Apache is listening on port 443

    test1$ sudo ss -tuln | grep 443
    LISTEN 0 128 * :443 ...
    
  • CLIENT SETUP — 192.168.0.11

  • Step-4: Verify network connectivity to the server

    test2$ ping 192.168.0.10
    
  • Step-5: Test HTTPS access

    test2$ curl -k https://192.168.0.10
    
    Expected: HTML content from Apache server.
    
  • Step-6: Enable SSL Key Logging

    test2$ export SSLKEYLOGFILE=$HOME/sslkeys.log
    

    Re-run the HTTPS request to generate secrets:

    test2$ curl -k https://192.168.0.10
    

    Check the log:

    test2$ cat ~/sslkeys.log
    

    You should see lines like:

    CLIENT_TRAFFIC_SECRET_0 ...
    SERVER_HANDSHAKE_TRAFFIC_SECRET ...
    CLIENT_HANDSHAKE_TRAFFIC_SECRET ...
    
  • Step-7: Capture HTTPS traffic using Wireshark

Run Wireshark on the client

In Wireshark:

  • Capture traffic on the active interface (e.g., eth0)

  • Apply the following display filter: ip.addr == 192.168.0.10 && ip.addr == 192.168.0.11

  • Step-8: Configure Wireshark to use SSL key log

    • Go to: Edit > Preferences > Protocols > TLS

    • Set: (Pre)-Master-Secret log filename = /home/youruser/sslkeys.log

    • Reload the capture file

    • Expected Result:

      • Client successfully connects to server via HTTPS

      • SSL key log file is generated on client

      • Wireshark decrypts the HTTPS session using sslkeys.log

      • Decrypted HTTP content is visible in Wireshark

  • Step-9: Wireshark Capture

    Download wireshark capture

SSH Setup Using AES256-CTR Encryption

  • To verify that an SSH session can be securely established using AES-256-CTR encryption and confirmed through Wireshark packet inspection.

  • Setup Environment

    • Client: test2 (192.168.56.10)

    • Server: test1 (192.168.56.11)

    • Goal: Force AES-256-CTR cipher in SSH and verify via Wireshark.

  • Step-1: Install OpenSSH on Both Machines

    test1$ sudo apt update
    test1$ sudo apt install openssh-server openssh-client -y
    
    test2$ sudo apt update
    test2$ sudo apt install openssh-server openssh-client -y
    
  • Step-2: Start and Enable SSH on the Server

    test1$ sudo systemctl enable ssh
    test1$ sudo systemctl start ssh
    test1$ sudo systemctl status ssh
    
  • If using UFW firewall:

    test1$ sudo ufw allow ssh
    
  • Step-3: Check Supported SSH Ciphers on the Client

    test2$ ssh -Q cipher
    aes128-ctr
    aes192-ctr
    aes256-ctr
    aes128-gcm@openssh.com
    chacha20-poly1305@openssh.com
    ...
    
    This confirms that `aes256-ctr` is supported by your SSH client.
    
  • Step-4: Connect Using AES-256-CTR Cipher

    test2$ ssh -c aes256-ctr your_username@192.168.56.11
    

    Replace your_username with a valid user on test1.

    This enforces AES-256-CTR cipher during the SSH session.

  • Step-5: (Optional) Make AES Cipher Permanent via SSH Config

    test2$ nano ~/.ssh/config
    

    Add the following lines:

    Host 192.168.56.11
    User your_username
    Ciphers aes256-ctr
    
  • Step-6: Capture SSH Packets Using Wireshark

    • Run Wireshark on either test1, test2, or a system in between.

    • Start packet capture on the active network interface.

    • Use the display filter: ip.addr == 192.168.56.10 && ip.addr == 192.168.56.11

  • Step-7: Analyze Encryption Algorithm in Wireshark

    • Locate one of the SSH handshake packets (e.g., Frame 45).

    • Expand the SSH Protocol section.

    • Look for a line similar to: SSH Version 2 (encryption:aes256-ctr compression:none)

    This confirms that AES-256-CTR was negotiated and used for encryption.

    Important Note on Decryption:

    SSH traffic cannot be decrypted in Wireshark—even when the cipher (like aes256-ctr) is known—because SSH uses strong encryption mechanisms with ephemeral session keys and employs Perfect Forward Secrecy (PFS).

    This means:

    • Session keys are generated per connection and discarded after use.

    • They are not logged or recoverable, even by the client or server.

    • Tools like Wireshark cannot decrypt SSH traffic unless the keys are exposed via insecure implementations (which modern OpenSSH does not allow).

    Unlike HTTPS (which can use SSLKEYLOGFILE to export secrets), SSH offers no practical method for decrypting live or recorded traffic.

  • Step-8: Wireshark Capture

    Download wireshark capture

DNS over TLS Setup Using Unbound

  • To configure DNS over TLS (DoT) using Unbound DNS server and verify secure, encrypted DNS resolution. Additionally, export TLS keys to allow decryption of DNS packets in Wireshark.

    Test Environment:

    • Server: test1 (192.168.0.10)

    • Client: test2 (192.168.0.11)

    Server-Side Configuration (test1):

  • Step 1: Install Unbound

    test1$ sudo apt update
    test1$ sudo apt install unbound -y
    
  • Step 2: Generate TLS Certificates

    test1$ sudo mkdir -p /etc/unbound/private
    test1$ sudo openssl req -newkey rsa:2048 -nodes \
         -keyout /etc/unbound/private/server.key \
         -x509 -days 365 \
         -out /etc/unbound/private/server.pem
    
    test1$ sudo chown -R unbound:unbound /etc/unbound/private
    test1$ sudo chmod 700 /etc/unbound/private
    test1$ sudo chmod 600 /etc/unbound/private/server.*
    
  • Step 3: Configure Unbound

    Edit /etc/unbound/unbound.conf:

    test1$ sudo nano /etc/unbound/unbound.conf
    include-toplevel: "/etc/unbound/unbound.conf.d/* .conf"
    
    server:
         interface: 0.0.0.0
         port: 853
         username: unbound
         directory: "/etc/unbound"
         tls-cert-bundle: "/etc/ssl/certs/ca-certificates.crt"
         tls-service-key: "/etc/unbound/private/server.key"
         tls-service-pem: "/etc/unbound/private/server.pem"
         verbosity: 1
    
    remote-control:
        control-enable: yes
    
    access-control: 192.168.0.0/24 allow
    
  • Step 4: Allow Firewall Traffic on Port 853

    Using UFW:

    test1$ sudo ufw allow 853/tcp
    

    Or using iptables:

    test1$ sudo iptables -A INPUT -p tcp --dport 853 -j ACCEPT
    
  • Step 5: Start and Enable Unbound

    test1$ sudo systemctl restart unbound
    test1$ sudo systemctl enable unbound
    

Client-Side Configuration (test2):

  • Step 1: Install Tools

    test2$ sudo apt update
    test2$ sudo apt install dnsutils knot-dnsutils -y
    
  • Step 2: Export SSL Keys for Decryption

    Set the environment variable to log TLS session keys:

    test2$ export SSLKEYLOGFILE=$HOME/sslkeys.log
    

    Then perform the DNS query:

    test2$ kdig +tls @192.168.0.10 example.com
    

    Verify that the session keys are logged:

    test2$ cat ~/sslkeys.log
    

Expected entries:

CLIENT_HANDSHAKE_TRAFFIC_SECRET ...
SERVER_HANDSHAKE_TRAFFIC_SECRET ...
CLIENT_TRAFFIC_SECRET_0 ...
SERVER_TRAFFIC_SECRET_0 ...
  • Step 3: Allow Firewall Traffic (if needed)

    test2$ sudo ufw allow 853/tcp
    
  • Step-4: Wireshark Decryption Configuration

    1. Open Wireshark.

    2. Capture traffic between test1 and test2.

    3. Go to:

      EditPreferencesProtocolsTLS

    4. Set the (Pre)-Master-Secret log filename to: /home/test2/sslkeys.log

    5. Restart capture or open the saved pcapng

    6. Filter: ip.addr == 192.168.0.10 && ip.addr == 192.168.0.11

    7. Look inside decrypted TLS packets to see DNS query/response in plaintext.

Important Notes

  • DNS over TLS uses ephemeral keys, but since kdig uses OpenSSL, and we exported SSLKEYLOGFILE, decryption in Wireshark is possible.

  • This method only works if the client app uses OpenSSL and honors `SSLKEYLOGFILE`.

  • SSH and other protocols that use Perfect Forward Secrecy but do not expose keys cannot be decrypted this way.

Troubleshooting Tips

  • Check file permissions:

test1$ sudo chown -R unbound:unbound /etc/unbound/private
test1$ sudo chmod 700 /etc/unbound/private
test1$ sudo chmod 600 /etc/unbound/private/server.*
  • Validate Unbound configuration:

test1$ sudo unbound-checkconf
  • Check for logs:

test1$ sudo journalctl -u unbound -f
  • Step-5: Wireshark Capture

DHCP over AES-encrypted IPsec VPN using strongSwan and DHCP Relay on Ubuntu

  • This test case verifies successful DHCP IP address assignment over an AES-encrypted IPsec VPN tunnel using strongSwan and a DHCP relay between two Ubuntu machines.

Setup Overview:

  • VPN Tunnel: AES-encrypted IPsec between Server and Client

  • Server (VPN + DHCP): 192.168.56.10

  • Client (VPN + DHCP Relay): 192.168.56.11

  • Step-1: Install strongSwan on Both Machines

    On both server and client:

    test:~$ sudo apt update
    test:~$sudo apt install strongswan
    
  • Step-2: Configure IPsec with AES

    Server (192.168.56.10)

    Edit /etc/ipsec.conf:

    config setup
        charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"
    
    conn aesvpn
        auto=add
        keyexchange=ikev2
        authby=secret
        left=192.168.56.10
        leftid=@server
        leftsubnet=192.168.56.0/24
        right=192.168.56.11
        rightid=@client
        rightsubnet=192.168.56.0/24
        ike=aes256-sha256-modp2048!
        esp=aes256-sha256!
    

Client (192.168.56.11)

Edit /etc/ipsec.conf:

config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn aesvpn
    auto=start
    keyexchange=ikev2
    authby=secret
    left=192.168.56.11
    leftid=@client
    leftsubnet=192.168.56.0/24
    right=192.168.56.10
    rightid=@server
    rightsubnet=192.168.56.0/24
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256!
  • Step-3: Set Pre-Shared Key (PSK)

    On both machines, edit /etc/ipsec.secrets:

@server @client : PSK "SuperSecretKey123!"
  • Step-4: Allow IPsec Ports on Both Machines

    test1:~$sudo ufw allow 500,4500/udp
    test1:~$sudo ufw allow in proto esp from 192.168.56.11
    test1:~$sudo ufw allow out proto esp to 192.168.56.11
    test1:~$sudo ufw reload
    
    test2:~$sudo ufw allow 500,4500/udp
    test2:~$sudo ufw allow in proto esp from 192.168.56.10
    test2:~$sudo ufw allow out proto esp to 192.168.56.10
    test2:~$sudo ufw reload
    
  • Step-5: Start strongSwan

sudo systemctl restart strongswan-starter
sudo systemctl enable strongswan-starter

On client, initiate the tunnel:

test2:~$sudo ipsec up aesvpn
  • Step-6: Install DHCP Server on Server (192.168.56.10)

test1:~$sudo apt install isc-dhcp-server

Configure DHCP server by editing /etc/dhcp/dhcpd.conf:

subnet 192.168.56.0 netmask 255.255.255.0 {
range 192.168.56.100 192.168.56.150;
option routers 192.168.56.1;
option domain-name-servers 8.8.8.8;
}

Start DHCP server:

test1:~$sudo systemctl restart isc-dhcp-server
  • Step-7: Install and Configure DHCP Relay on Client (192.168.56.11)

Install relay agent:

test2:~$sudo apt install isc-dhcp-relay

Edit ``/etc/default/isc-dhcp-relay``:

.. code-block:: shell

   SERVERS="192.168.56.10"
   INTERFACES="eth0"
   OPTIONS=""
  • Replace eth0 with the actual interface name (use ip a to find it).*

Start and enable relay service:

test2:~$sudo systemctl restart isc-dhcp-relay
test2:~$sudo systemctl enable isc-dhcp-relay
  • Step-8: Test the Setup

    Check VPN status:

    test2:~$sudo ipsec statusall
    

You should see the aesvpn connection INSTALLED.

Request an IP via DHCP on client:

test2:~$sudo dhclient -v eth0

You should receive an IP within the DHCP server range.

TLS Communication with AES

  • To verify TLS communication using AES encryption, capture encrypted packets with Wireshark, and decrypt them using exported TLS session keys.

  • Setup Environment

  • Server: test1 (192.168.0.10)

  • Client: test2 (192.168.0.11)

  • Goal: Establish TLS connection with AES cipher, capture and decrypt traffic in Wireshark.

  • Step-1: Generate TLS Certificate and Private Key on Server

    test1:~$ openssl req -x509 -newkey rsa:2048 -nodes -keyout server.key -out server.crt -days 365
    
  • Step-2: Start TLS Server on Server (using AES cipher)

    test1:~$ openssl s_server -accept 4443 -cert server.crt -key server.key -cipher AES256
    
    Server listens on port 4443, keep terminal open.
    
  • Step-3: Connect from Client and Log TLS Session Keys

    test2:~$ openssl s_client -connect 192.168.0.10:4443 -keylogfile ~/sslkeylog.log
    
    Type message (e.g., "hello") and press Enter to send encrypted data.
    

    Verify key log file:

test2:~$ cat ~/sslkeylog.log

Confirm presence of `CLIENT_RANDOM` entries.
  • Step-4: Capture Packets Using Wireshark

  • Start Wireshark on any host/VM in the network.

  • Capture on the interface connected to 192.168.0.x network.

  • Optional capture filter: tcp.port == 4443

  • Step-5: Decrypt TLS Traffic in Wireshark

  • Open Wireshark capture.

  • Go to: Edit → Preferences → Protocols → TLS

  • Set (Pre)-Master-Secret log filename to: /home/youruser/sslkeylog.log

  • Click OK.

Wireshark will decrypt TLS packets automatically.

Right-click a TLS packet → Follow → TLS Stream to view plaintext.

  • Important Notes on Decryption

    • Decryption requires exported session keys via -keylogfile.

    • Without keys, TLS traffic remains encrypted due to ephemeral keys and PFS.

    • This differs from SSH where no practical key export exists.

WSS (WebSocket Secure) Setup with AES

  • To establish a secure WebSocket connection (wss://) between a Node.js server and client using TLS (AES encryption) and decrypt the traffic using Wireshark by exporting TLS session keys.

  • Setup Environment

  • Server: test1 (192.168.0.10)

  • Client: test2 (192.168.0.11)

  • Goal: Enable WSS, capture encrypted traffic, and decrypt using exported keys.

  • Prerequisites

  • Both machines have Node.js and npm installed.

  • Wireshark installed on the host or one of the VMs.

  • wscat installed on client for WebSocket testing.

  • Step-1: Prepare WSS Server on test1

    test1:~$ mkdir -p ~/ws-server/certs
    test1:~$ cd ~/ws-server
    
  • Step-2: Generate TLS Certificate and Key

    test1:~/ws-server$ openssl req -x509 -nodes -days 365 \
     -newkey rsa:2048 \
     -keyout certs/key.pem \
     -out certs/cert.pem \
    -subj "/CN=192.168.0.10"
    
  • Step-3: Create WSS Server Script

    test1:~/ws-server$ nano server.js
    

    Paste the following:

    const fs = require('fs');
    const https = require('https');
    const WebSocket = require('ws');
    
    const server = https.createServer({
      cert: fs.readFileSync(__dirname + '/certs/cert.pem'),
      key: fs.readFileSync(__dirname + '/certs/key.pem')
    });
    
    const wss = new WebSocket.Server({ server, path: '/ws' });
    
    wss.on('connection', (ws) => {
      console.log('Client connected');
      ws.send('Hello from backend WebSocket server');
    
      ws.on('message', (message) => {
      console.log('Received:', message.toString());
      ws.send(`You said: ${message}`);
      });
    
      ws.on('close', () => {
      console.log('Client disconnected');
     });
    });
    
    server.listen(3000, () => {
    console.log('HTTPS WebSocket server listening on port 3000');
    });
    
  • Step-4: Install Dependencies

    test1:~/ws-server$ npm init -y
    test1:~/ws-server$ npm install ws
    
  • Step-5: Enable Key Logging for TLS Decryption

    Set the SSLKEYLOGFILE variable to log session keys:

    test1:~/ws-server$ export SSLKEYLOGFILE=~/tlskeylog.log
    test1:~/ws-server$ node server.js
    HTTPS WebSocket server listening on port 3000
    
  • Step-6: Install wscat and Connect from Client

    test2:~$ sudo npm install -g wscat
    

    Connect to WSS server (skipping TLS verification due to self-signed cert):

    test2:~$ wscat -n -c wss://192.168.0.10:3000/ws --no-check
    Connected (press CTRL+C to quit)
    < Hello from backend WebSocket server
    >
    
    You can now exchange messages.
    
  • Step-7: Capture Packets with Wireshark

    • Start Wireshark on host or either VM.

    • Begin capturing on the interface connected to 192.168.0.x.

    • Use capture filter: tcp.port == 3000

  • Step-8: Decrypt WSS Traffic in Wireshark

  • On the system with SSLKEYLOGFILE, open Wireshark.

  • Go to: Edit → Preferences → Protocols → TLS

  • Set the (Pre)-Master-Secret log file path: /home/youruser/tlskeylog.log

  • Load your .pcapng file.

  • Wireshark will now decrypt the WSS stream.

Right-click → “Follow” → “TLS Stream” to see the plaintext WebSocket messages.

  • Important Notes

  • The SSLKEYLOGFILE method works because Node.js (via OpenSSL) supports session key export.

  • This setup demonstrates end-to-end encrypted WebSocket communication and successful decryption using key logging.

FTPS (Explicit TLS) Setup with AES Encryption using vsftpd

  • This guide demonstrates how to set up a secure FTPS server using vsftpd and connect using lftp from a client machine. Encryption is enforced using TLS (with AES) and verified via packet capture.

  • Setup Environment

    • Server: test1 (192.168.56.10)

    • Client: test2 (192.168.56.11)

    • Goal: Enable secure file transfer over FTPS with AES encryption and verify via Wireshark.

  • Step-1: Install vsftpd on Server

    test1:~$ sudo apt-get update
    test1:~$ sudo apt-get install vsftpd -y
    
  • Step-2: Configure vsftpd for Explicit TLS (FTPS)

    Edit /etc/vsftpd.conf and ensure the following settings are applied:

    local_enable=YES
    write_enable=YES
    chroot_local_user=YES
    allow_writeable_chroot=YES
    
    ssl_enable=YES
    allow_anon_ssl=NO
    force_local_data_ssl=YES
    force_local_logins_ssl=YES
    
    rsa_cert_file=/etc/ssl/certs/vsftpd.pem
    rsa_private_key_file=/etc/ssl/private/vsftpd.key
    
    pasv_enable=YES
    pasv_min_port=40000
    pasv_max_port=40100
    
    ssl_ciphers=HIGH
    
  • Step-3: Generate Self-Signed Certificate

    test1:~$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
     -keyout /etc/ssl/private/vsftpd.key \
     -out /etc/ssl/certs/vsftpd.pem \
     -subj "/CN=192.168.56.10"
    
  • Step-4: Restart vsftpd

    test1:~$ sudo systemctl restart vsftpd
    
  • Step-5: Allow Ports in UFW Firewall

    test1:~$ sudo ufw allow 21/tcp
    test1:~$ sudo ufw allow 40000:40100/tcp
    test1:~$ sudo ufw reload
    
  • Step-6: Create FTP User

    test1:~$ sudo adduser ftpuser
    # Set password when prompted
    
    Ensure `ftpuser` has a valid home directory and write permissions.
    
  • Step-7: Connect via lftp from Client

    test2:~$ lftp -u ftpuser 192.168.56.10
    
    Enter the password when prompted.
    
  • Step-8: Configure FTPS (TLS) Settings in lftp

    Inside the lftp prompt, run:

    set ftp:ssl-force true
    set ftp:ssl-protect-data true
    set ftp:ssl-protect-list yes
    set ftp:passive-mode on
    set ssl:verify-certificate no
    
  • Step-9: Test FTP Commands

    lftp> ls
    lftp> put send_rarp_request.c
    lftp> get send_rarp_request.c -o send_rarp_request_new.c
    
  • Step-10: Capture and Verify FTPS in Wireshark

  • Start Wireshark on either test1 or test2.

  • Use this display filter: tcp.port == 21 || (tcp.port >= 40000 && tcp.port <= 40100)

  • Look for AUTH TLS, TLS Handshake, and Encrypted Alert packets.

  • Encryption used: AES (TLS_RSA_WITH_AES_256_CBC_SHA or similar depending on negotiation).

  • Decryption is possible only if the session keys are logged using SSLKEYLOGFILE environment variable.

  • TLS Decryption with Wireshark

    To decrypt FTPS traffic:

    1. Export the session key on the client (or server) using:

      test2:~$ export SSLKEYLOGFILE=~/ftps_keys.log
       test2:~$ lftp -u ftpuser 192.168.56.10
      
    2. In Wireshark:

      • Navigate to Edit → Preferences → Protocols → TLS

      • Set the (Pre)-Master-Secret log filename to the path of ftps_keys.log

    3. Load the .pcap file and Wireshark will decrypt TLS streams.

    Not all versions of lftp/OpenSSL support exporting SSLKEYLOGFILE. If unsupported, decryption will not be possible.

  • Step-11: Wireshark Capture

    Download Wireshark Capture

  • Notes

  • Explicit FTPS uses port 21 for control and negotiates TLS via AUTH TLS.

  • Passive data ports (40000–40100) must be opened for file transfers to work.

  • Use ftp:// or raw IP with lftp. Do not use ftps:// for explicit FTPS.

  • To avoid certificate warnings during testing, disable cert verification using: set ssl:verify-certificate no

MQTT over TLS (Mosquitto Broker & Client) with AES Encryption

  • This guide sets up secure MQTT communication over TLS (port 8883) using Mosquitto. TLS encryption (with AES) is verified and decrypted using Wireshark.

  • Setup Environment

    • Broker: test1 (192.168.56.11)

    • Client: test2 (192.168.56.10)

    • TLS Port: 8883

    • Goal: Secure MQTT with TLS and decrypt traffic using session keys.

  • Step-1: Generate TLS Certificates (on Broker)

    test1:~$ openssl genrsa -out ca.key 2048
    test1:~$ openssl req -new -x509 -days 3650 -key ca.key -out ca.crt -subj "/CN=MQTT Test CA"
    
    test1:~$ openssl genrsa -out server.key 2048
    test1:~$ openssl req -new -out server.csr -key server.key -subj "/CN=192.168.56.11"
    
    test1:~$ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key \
    -CAcreateserial -out server.crt -days 365
    
  • Step-2: Configure Mosquitto for TLS

    test1:~$ sudo mkdir -p /etc/mosquitto/certs
    test1:~$ sudo cp server.crt server.key ca.crt /etc/mosquitto/certs/
    test1:~$ sudo chown mosquitto:mosquitto /etc/mosquitto/certs/*.crt /etc/mosquitto/certs/*.key
    test1:~$ sudo chmod 640 /etc/mosquitto/certs/*.crt /etc/mosquitto/certs/*.key
    

    Create config file /etc/mosquitto/conf.d/tls.conf:

    listener 8883
    cafile /etc/mosquitto/certs/ca.crt
    certfile /etc/mosquitto/certs/server.crt
    keyfile /etc/mosquitto/certs/server.key
    require_certificate false
    tls_version tlsv1.2
    

    Confirm /etc/mosquitto/mosquitto.conf includes:

    include_dir /etc/mosquitto/conf.d
    

    Restart Mosquitto:

    test1:~$ sudo systemctl restart mosquitto
    
  • Step-3: Copy CA Certificate to Client

    test1:~$ cp /etc/mosquitto/certs/ca.crt ~/
    test2:~$ scp pavithra@192.168.56.11:~/ca.crt ~/
    
  • Step-4: Build MQTT TLS Client in C (on Client)

    test2:~$ sudo apt install git cmake gcc libssl-dev -y
    test2:~$ git clone https://github.com/eclipse/paho.mqtt.c.git
    test2:~$ cd paho.mqtt.c
    test2:~/paho.mqtt.c$ mkdir build && cd build
    
    test2:~/paho.mqtt.c/build$ cmake .. -DPAHO_WITH_SSL=TRUE \
      -DOPENSSL_ROOT_DIR=/usr \
      -DOPENSSL_INCLUDE_DIR=/usr/include/openssl \
      -DOPENSSL_LIBRARIES=/usr/lib/x86_64-linux-gnu
    
    test2:~/paho.mqtt.c/build$ make
    test2:~/paho.mqtt.c/build$ sudo make install
    test2:~$ sudo ldconfig
    
  • Step-5: Write and Compile the TLS MQTT C Client

Save the following as mqtt_tls_client.c:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MQTTClient.h"

#define ADDRESS     "ssl://192.168.56.11:8883"
#define CLIENTID    "CClient"
#define TOPIC       "test/topic"
#define QOS         1
#define TIMEOUT     10000L

int main() {
MQTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
MQTTClient_SSLOptions ssl_opts = MQTTClient_SSLOptions_initializer;
int rc;

 if ((rc = MQTTClient_create(&client, ADDRESS, CLIENTID,
MQTTCLIENT_PERSISTENCE_NONE, NULL)) != MQTTCLIENT_SUCCESS) {
printf("Failed to create client: %d\n", rc);
return -1;
}

ssl_opts.trustStore = "/home/pavithra/ca.crt";
ssl_opts.enableServerCertAuth = 1;

conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.ssl = &ssl_opts;

if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS) {
printf("Failed to connect, return code %d\n", rc);
MQTTClient_destroy(&client);
return -1;
}

printf("Connected to MQTT broker via TLS.\n");

if ((rc = MQTTClient_subscribe(client, TOPIC, QOS)) != MQTTCLIENT_SUCCESS) {
printf("Failed to subscribe, return code %d\n", rc);
MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);
return -1;
}

while (1) {
char* topicName = NULL;
int topicLen;
MQTTClient_message* message = NULL;

rc = MQTTClient_receive(client, &topicName, &topicLen, &message, TIMEOUT);
if (rc == MQTTCLIENT_SUCCESS && message != NULL) {
printf("Message received: %.*s\n", message->payloadlen, (char*)message->payload);
MQTTClient_freeMessage(&message);
MQTTClient_free(topicName);
}
}

MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);
return 0;
}

Compile the client:

.. code-block:: shell

   test2:~$ gcc -Wall -o mqtt_tls_client mqtt_tls_client.c \
       -I/usr/include/openssl \
       -L/usr/local/lib -lpaho-mqtt3cs -lssl -lcrypto \
       -Wl,-rpath,/usr/local/lib
  • Step-6: Run with TLS Key Logging

    test2:~$ export SSLKEYLOGFILE=~/mqtt_keys.log
    test2:~$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    test2:~$ ./mqtt_tls_client
    Connected to MQTT broker via TLS.
    Message received: Hello over TLS
    
  • Step-7: Publish Message to Topic (From Another Terminal)

test2:~$ mosquitto_pub -h 192.168.56.11 -p 8883 \
  --cafile ~/ca.crt \
  --tls-version tlsv1.3 \
  -t test/topic -m "Hello over TLS"
  • Step-8: (Optional) Subscribe and Publish Using mosquitto_sub

    test2:~$ mosquitto_sub -h 192.168.56.11 -p 8883 \
        --cafile ~/ca.crt -t test/topic -d
    
    test2:~$ mosquitto_pub -h 192.168.56.11 -p 8883 \
        --cafile ~/ca.crt -t test/topic -m "Secure test message" -d
    
  • Step-9: Decrypt TLS in Wireshark

  • Open Wireshark

  • Go to: Edit → Preferences → Protocols → TLS

  • Set the (Pre)-Master-Secret log filename to:/home/pavithra/mqtt_keys.log

  • Load the pcap file and decrypt the MQTT TLS traffic.

  • Use display filter: tcp.port == 8883

  • Right-click a TLS packet → “Follow TLS stream” → View decrypted content.

AES IPsec VPN Setup on Ubuntu with strongSwan (IPv6)

  • This guide explains how to configure a basic AES-encrypted IPsec VPN tunnel between two Ubuntu machines using IPv6 addressing.

Prerequisites:

  • Two Ubuntu machines with IPv6 addresses:

    • Server IPv6: fd00:56::10 (test1)

    • Client IPv6: fd00:56::11 (test2)

  • Both machines have strongSwan installed.

  • UFW firewall enabled (optional but recommended).

  • Step 1: Install strongSwan

On both machines, run:

test1:~$ sudo apt update
test1:~$ sudo apt install strongswan
test2:~$ sudo apt update
test2:~$ sudo apt install strongswan
  • Step 2: Configure IPsec

### Server Configuration (/etc/ipsec.conf)

config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn aesvpn
    auto=add
    keyexchange=ikev2
    authby=secret
    left=fd00:56::10
    leftid=@server
    leftsubnet=fd00:56::/64
    right=fd00:56::11
    rightid=@client
    rightsubnet=fd00:56::/64
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256!

### Client Configuration (/etc/ipsec.conf)

config setup
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2"

conn aesvpn
    auto=start
    keyexchange=ikev2
    authby=secret
    left=fd00:56::11
    leftid=@client
    leftsubnet=fd00:56::/64
    right=fd00:56::10
    rightid=@server
    rightsubnet=fd00:56::/64
    ike=aes256-sha256-modp2048!
    esp=aes256-sha256!
  • Step 3: Set Pre-Shared Key

On both machines, edit /etc/ipsec.secrets to add:

test1:~$ @server @client : PSK "SuperSecretKey123!"
test2:~$ @client @server : PSK "SuperSecretKey123!"
  • Step 4: Configure UFW Firewall Rules

Server (fd00:56::10):

test1:~$ sudo ufw allow 500,4500/udp
test1:~$ sudo ufw allow in proto esp from fd00:56::11
test1:~$ sudo ufw allow out proto esp to fd00:56::11
test1:~$ sudo ufw reload

Client (fd00:56::11):

test2:~$ sudo ufw allow 500,4500/udp
test2:~$ sudo ufw allow in proto esp from fd00:56::10
test2:~$ sudo ufw allow out proto esp to fd00:56::10
test2:~$ sudo ufw reload
  • Step 5: Start and Enable strongSwan Service

On both machines:

test1:~$ sudo ipsec restart
test2:~$ sudo ipsec restart
  • Step 6: Initiate the VPN Connection

test2:~$ sudo ipsec up aesvpn

**Example Output:**

initiating IKE_SA aesvpn[1] to fd00:56::10
generating IKE_AUTH request 1 [ IDi CERTREQ ]
sending packet: from fd00:56::11[4500] to fd00:56::10[4500] (1400 bytes)
received packet: from fd00:56::10[4500] to fd00:56::11[4500] (1400 bytes)
parsed IDr payload: ID_IPV6_ADDR: fd00:56::10
received CERT request for "C=US, O=strongSwan, CN=server"
sending packet: from fd00:56::11[4500] to fd00:56::10[4500] (1400 bytes)
IKE_AUTH response processed
established IKE_SA aesvpn[1] successfully
establishing CHILD_SA aesvpn{1}
sending packet: from fd00:56::11[4500] to fd00:56::10[4500] (1400 bytes)
received packet: from fd00:56::10[4500] to fd00:56::11[4500] (1400 bytes)
established CHILD_SA aesvpn{1} successfully

(Optional) On the server machine:

test1:~$ sudo ipsec up aesvpn
  • Step 7: Verify VPN Status

On either machine:

test1:~$ sudo ipsec statusall

**Example Output:**

Security Associations (1 up, 0 connecting):
   aesvpn[1]: ESTABLISHED 4 minutes ago, fd00:56::11[client]...fd00:56::10[server]
   IKEv2 SPIs: 123456789abcdef0_i 123456789abcdef0_r, rekeying in 10 minutes
   CHILD_SA aesvpn{1}: INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: c3f8e1a3_i 7d4b2c6e_o
   AES_CBC_256/HMAC_SHA2_256_128/NO_EXT_SEQ
   lifetime: 1h0m, bytes_i: 1500, bytes_o: 1200

   Connections:
   aesvpn: fd00:56::11...fd00:56::10 IKEv2, dpddelay=30s
  • Step 8: Test Connectivity

test2:~$ ping6 fd00:56::10
  • Step 9: Capture IPsec (AES) Packets with Wireshark

  • Launch Wireshark on either machine.

  • Use the filter to capture ESP (IPsec encrypted) packets:

  • You should observe ESP packets flowing between fd00:56::10 and fd00:56::11.

  • Step 10: Capture the test using Wireshark.

    Download Wireshark capture

AES Encryption Packet

S.No

Protocol Packets

Description

Size(Bytes)

1

AES Encryption Packet

Used to encrypt a 128-bit block of plaintext using a symmetric key.

496 / 536 / 576

Plaintext Block

The original data to be encrypted.

16

Key

Secret key used for encryption. Can be 128, 192, or 256 bits.

16 / 24 / 32

Initialization Vector (IV)

Used in modes like CBC to ensure randomness. Not used in ECB mode.

16

Round Keys

Keys derived from the original key for each AES round.

176 / 208 / 240

State Matrix

Internal 44 byte matrix used during AES transformations.

16

S-Box

Substitution box used in the SubBytes step.

256

Ciphertext Block

The encrypted output after all AES rounds.

16

AES Decryption Packet

S.No

Protocol Packets

Description

Size(Bytes)

2

AES Decryption Packet

Used to decrypt a 128-bit ciphertext block using the same symmetric key.

496 / 536 / 576

Ciphertext Block

The encrypted data to be decrypted.

16

Key

Same symmetric key used during encryption.

16 / 24 / 32

Initialization Vector (IV)

Required for modes like CBC to reverse the XOR step.

16

Round Keys

Derived from the key, used in reverse order during decryption.

176 / 208 / 240

State Matrix

Internal 44 byte matrix used during AES transformations.

16

Inverse S-Box

Used in the InvSubBytes step during decryption.

256

Plaintext Block

The original data recovered after decryption.

16

S.no

Use Case

Description

1

Secure Web Communication

AES is used in HTTPS (SSL/TLS) to encrypt data between browsers and servers.

2

Wi-Fi Security

AES is the core encryption algorithm in WPA2 and WPA3 for protecting wireless networks.

3

File Encryption

Tools like BitLocker, VeraCrypt, and 7-Zip use AES to encrypt files and drives.

4

Messaging Apps

End-to-end encryption in apps like WhatsApp, Signal, and Telegram uses AES.

5

VPNs

AES encrypts data in transit to ensure privacy and security over public networks.

6

Mobile Device Encryption

iOS and Android use AES to encrypt user data stored on the device.

7

Database Encryption

AES is used to encrypt sensitive fields or entire databases (e.g., in SQL Server, Oracle).

8

Cloud Storage

Services like Google Drive and Dropbox use AES to encrypt files stored in the cloud.

9

Payment Systems

AES secures transaction data in systems like EMV chip cards and mobile wallets.

10

Military & Government Use

AES-256 is approved for encrypting classified and top-secret information.

S.no

Feature

Description

1

Symmetric Key Cipher

Uses the same key for both encryption and decryption.

2

Block Cipher

Operates on fixed-size blocks of data (128 bits).

3

Key Sizes

Supports 128, 192, and 256-bit keys for varying levels of security.

4

Number of Rounds

10, 12, or 14 rounds depending on key size.

5

SubstitutionPermutation Network (SPN)

Uses multiple rounds of substitution and permutation for encryption.

6

Fast and Efficient

Designed for high performance in both hardware and software.

7

Strong Security

Resistant to known attacks like brute-force, differential, and linear cryptanalysis.

8

Widely Adopted

Used globally in government, finance, and consumer applications.

9

Flexible Modes of Operation

Supports ECB, CBC, CFB, OFB, GCM, etc., for different use cases.

Symmetric Key Cipher - Testcases

#

Test Case

Description

Expected Result

1

Encrypt with AES-128

Use 128-bit key for encryption

Ciphertext generated

2

Decrypt with AES-128

Use same 128-bit key for decryption

Original plaintext recovered

3

Encrypt with AES-192

Use 192-bit key for encryption

Ciphertext generated

4

Decrypt with AES-192

Use same 192-bit key for decryption

Original plaintext recovered

5

Encrypt with AES-256

Use 256-bit key for encryption

Ciphertext generated

6

Decrypt with AES-256

Use same 256-bit key for decryption

Original plaintext recovered

7

Encrypt and Decrypt with Same Key

Use same key for both operations

Data integrity maintained

8

Encrypt and Decrypt with Wrong Key

Use different key for decryption

Decryption fails or produces garbage

9

Encrypt Empty String

Encrypt an empty string

Valid ciphertext generated

10

Decrypt Empty Ciphertext

Decrypt empty ciphertext

Empty string returned

11

Encrypt Short Text

Encrypt short plaintext

Ciphertext generated

12

Encrypt Long Text

Encrypt large plaintext

Ciphertext generated

13

Encrypt Binary Data

Encrypt binary input

Ciphertext generated

14

Decrypt Binary Ciphertext

Decrypt binary ciphertext

Original binary data recovered

15

Use Hex Key

Use hexadecimal key for AES

Encryption succeeds

16

Use Base64 Key

Use base64-encoded key

Encryption succeeds

17

Use Random Key

Generate random symmetric key

Encryption and decryption succeed

18

Use Static Key

Use fixed key

Consistent results

19

Use Weak Key

Use simple key (e.g., all zeros)

Encryption works but insecure

20

Use Strong Key

Use high-entropy key

Encryption secure

21

Use Key with Wrong Length

Use 100-bit key

Error or rejection

22

Use Key Padding

Pad key to valid length

Encryption succeeds

23

Use ECB Mode

Encrypt using AES in ECB mode

Ciphertext generated (less secure)

24

Use CBC Mode

Encrypt using AES in CBC mode

Ciphertext generated with IV

25

Use CFB Mode

Encrypt using AES in CFB mode

Ciphertext generated

26

Use OFB Mode

Encrypt using AES in OFB mode

Ciphertext generated

27

Use CTR Mode

Encrypt using AES in CTR mode

Ciphertext generated

28

Use GCM Mode

Encrypt using AES in GCM mode

Ciphertext and tag generated

29

Use IV with CBC Mode

Provide initialization vector

Encryption succeeds

30

Use Same IV Twice

Reuse IV in CBC mode

Encryption succeeds but insecure

31

Use Different IVs

Use different IVs for same plaintext

Different ciphertexts generated

32

Encrypt with Padding

Use PKCS#7 padding

Ciphertext generated

33

Decrypt with Padding

Remove padding after decryption

Original plaintext recovered

34

Encrypt Without Padding

Use plaintext with block size multiple

Ciphertext generated

35

Encrypt Non-Block-Aligned Data

Use data not aligned to block size

Padding applied

36

Encrypt with Hardware Support

Use AES-NI instructions

Fast encryption

37

Encrypt with Software Library

Use OpenSSL or PyCrypto

Encryption succeeds

38

Encrypt with Custom Implementation

Use custom AES implementation

Encryption succeeds if correct

39

Encrypt with Key Rotation

Rotate keys periodically

Encryption remains secure

40

Encrypt with Key Expiry

Use expired key

Encryption fails or flagged

41

Encrypt with Key Management System

Retrieve key from KMS

Encryption succeeds

42

Encrypt with Secure Element

Use secure element for key storage

Encryption succeeds

43

Encrypt with TPM

Use Trusted Platform Module

Encryption succeeds

44

Encrypt with HSM

Use Hardware Security Module

Encryption succeeds

45

Encrypt with Compliance Logging

Enable logging for audit

Logs show key usage

46

Encrypt with SIEM Integration

Send logs to SIEM

Events visible in SIEM

47

Encrypt with Access Control

Restrict key usage by role

Unauthorized access blocked

48

Encrypt with Key Backup

Use backup key if primary fails

Encryption continues

49

Encrypt with Key Revocation

Revoke compromised key

Key no longer usable

50

Encrypt with Key Derivation

Derive key from password using PBKDF2

Encryption succeeds with derived key

Block Cipher - Testcases

#

Test Case

Description

Expected Result

1

Encrypt 128-bit block

Encrypt exactly 128-bit plaintext

Ciphertext generated

2

Encrypt 256-bit block

Encrypt two 128-bit blocks

Two ciphertext blocks generated

3

Encrypt 64-bit block

Encrypt half-block with padding

One ciphertext block generated

4

Encrypt 129-bit block

Encrypt slightly over one block

Two ciphertext blocks generated

5

Encrypt 0-bit block

Encrypt empty input

Empty ciphertext

6

Encrypt 1024-bit block

Encrypt 8 blocks

8 ciphertext blocks generated

7

Encrypt with PKCS#7 padding

Pad to 128-bit block size

Valid ciphertext

8

Encrypt with ISO/IEC 7816-4 padding

Use alternate padding scheme

Valid ciphertext

9

Encrypt with no padding

Input is multiple of 128 bits

Ciphertext generated

10

Encrypt with incorrect padding

Input not padded correctly

Error or incorrect decryption

11

Decrypt 128-bit block

Decrypt one block

Original plaintext recovered

12

Decrypt 256-bit block

Decrypt two blocks

Original plaintext recovered

13

Decrypt with wrong padding

Padding mismatch

Error or garbage output

14

Encrypt with ECB mode

Block-by-block encryption

Identical blocks produce same ciphertext

15

Encrypt with CBC mode

Chained block encryption

Ciphertext varies with IV

16

Encrypt with CFB mode

Stream-like block encryption

Ciphertext generated

17

Encrypt with OFB mode

Output feedback mode

Ciphertext generated

18

Encrypt with CTR mode

Counter mode

Ciphertext generated

19

Encrypt with GCM mode

Authenticated encryption

Ciphertext and tag generated

20

Encrypt with same plaintext blocks

ECB mode

Identical ciphertext blocks

21

Encrypt with different IVs

CBC mode

Different ciphertexts

22

Encrypt with reused IV

CBC mode

Ciphertext same, insecure

23

Encrypt with IV = 0

CBC mode

Ciphertext generated, insecure

24

Encrypt with random IV

CBC mode

Ciphertext varies

25

Encrypt with IV length 128 bits

Invalid IV

Error or rejection

26

Encrypt with IV = 128 bits

Valid IV

Encryption succeeds

27

Encrypt with block-aligned data

No padding needed

Ciphertext generated

28

Encrypt with non-aligned data

Padding applied

Ciphertext generated

29

Encrypt with UTF-8 text

Multibyte characters

Ciphertext generated

30

Encrypt with ASCII text

Single-byte characters

Ciphertext generated

31

Encrypt with binary data

Raw bytes

Ciphertext generated

32

Encrypt with JSON data

Structured text

Ciphertext generated

33

Encrypt with XML data

Structured text

Ciphertext generated

34

Encrypt with image data

Binary file

Ciphertext generated

35

Encrypt with audio data

Binary file

Ciphertext generated

36

Encrypt with video data

Large binary file

Ciphertext generated

37

Encrypt with compressed data

ZIP or GZIP

Ciphertext generated

38

Encrypt with encrypted input

Double encryption

Ciphertext generated

39

Encrypt with corrupted block

Modify one block

Decryption fails or partial recovery

40

Encrypt with tampered IV

Modify IV

Decryption fails or incorrect

41

Encrypt with block chaining

CBC mode

Each block depends on previous

42

Encrypt with block independence

ECB mode

Each block independent

43

Encrypt with block size 128 bits

Invalid block size

Error or rejection

44

Encrypt with 128-bit aligned file

No padding needed

Ciphertext generated

45

Encrypt with 1MB file

Multiple blocks

Ciphertext generated

46

Encrypt with 1GB file

Large input

Ciphertext generated

47

Encrypt with streaming input

Block-by-block processing

Ciphertext generated

48

Encrypt with block corruption

Flip bits in ciphertext

Decryption fails

49

Encrypt with block replay

Replay old ciphertext block

Potential vulnerability

50

Encrypt with block reordering

Change block order

Decryption fails or incorrect

Key sizes - Testcases

#

Test Case

Description

Expected Result

1

Encrypt with 128-bit key

Use 16-byte key

Ciphertext generated

2

Encrypt with 192-bit key

Use 24-byte key

Ciphertext generated

3

Encrypt with 256-bit key

Use 32-byte key

Ciphertext generated

4

Decrypt with 128-bit key

Use same 128-bit key

Plaintext recovered

5

Decrypt with 192-bit key

Use same 192-bit key

Plaintext recovered

6

Decrypt with 256-bit key

Use same 256-bit key

Plaintext recovered

7

Encrypt with incorrect key size

Use 100-bit key

Error or rejection

8

Encrypt with oversized key

Use 512-bit key

Error or rejection

9

Encrypt with under-sized key

Use 64-bit key

Error or rejection

10

Encrypt with padded key

Pad to valid size

Encryption succeeds

11

Encrypt with hex 128-bit key

Use hex string

Ciphertext generated

12

Encrypt with hex 192-bit key

Use hex string

Ciphertext generated

13

Encrypt with hex 256-bit key

Use hex string

Ciphertext generated

14

Encrypt with base64 128-bit key

Use base64 string

Ciphertext generated

15

Encrypt with base64 192-bit key

Use base64 string

Ciphertext generated

16

Encrypt with base64 256-bit key

Use base64 string

Ciphertext generated

17

Encrypt with random 128-bit key

Generate random key

Ciphertext generated

18

Encrypt with random 192-bit key

Generate random key

Ciphertext generated

19

Encrypt with random 256-bit key

Generate random key

Ciphertext generated

20

Encrypt with static 128-bit key

Use fixed key

Consistent ciphertext

21

Encrypt with static 192-bit key

Use fixed key

Consistent ciphertext

22

Encrypt with static 256-bit key

Use fixed key

Consistent ciphertext

23

Encrypt with weak 128-bit key

All zeros

Works but insecure

24

Encrypt with weak 192-bit key

All ones

Works but insecure

25

Encrypt with weak 256-bit key

Repeating pattern

Works but insecure

26

Encrypt with strong 128-bit key

High entropy

Secure encryption

27

Encrypt with strong 192-bit key

High entropy

Secure encryption

28

Encrypt with strong 256-bit key

High entropy

Secure encryption

29

Encrypt with derived 128-bit key

Use PBKDF2

Ciphertext generated

30

Encrypt with derived 192-bit key

Use PBKDF2

Ciphertext generated

31

Encrypt with derived 256-bit key

Use PBKDF2

Ciphertext generated

32

Encrypt with key rotation

Rotate 128-bit key

Encryption remains secure

33

Encrypt with key rotation

Rotate 256-bit key

Encryption remains secure

34

Encrypt with expired key

Key marked expired

Encryption fails or flagged

35

Encrypt with revoked key

Key revoked

Encryption fails

36

Encrypt with key from KMS

Retrieve 128-bit key

Encryption succeeds

37

Encrypt with key from HSM

Use 256-bit key

Encryption succeeds

38

Encrypt with TPM key

Use 192-bit key

Encryption succeeds

39

Encrypt with secure element key

Use 128-bit key

Encryption succeeds

40

Encrypt with access-controlled key

Role-based access

Unauthorized blocked

41

Encrypt with backup key

Use backup 256-bit key

Encryption continues

42

Encrypt with key logging

Log 128-bit key usage

Logs generated

43

Encrypt with SIEM integration

Log 192-bit key usage

Events visible

44

Encrypt with compliance policy

Use 256-bit key

Policy enforced

45

Encrypt with FIPS-compliant key

Use validated key

Encryption succeeds

46

Encrypt with AES-NI and 128-bit key

Hardware acceleration

Fast encryption

47

Encrypt with OpenSSL and 192-bit key

Software library

Encryption succeeds

48

Encrypt with PyCrypto and 256-bit key

Software library

Encryption succeeds

49

Encrypt with custom AES and 128-bit key

Custom implementation

Works if correct

50

Encrypt with mismatched key size

Encrypt with 128-bit, decrypt with 256-bit

Decryption fails

Number of Rounds - Testcases

#

Test Case

Description

Expected Result

1

AES-128 Rounds

Use 128-bit key

10 rounds executed

2

AES-192 Rounds

Use 192-bit key

12 rounds executed

3

AES-256 Rounds

Use 256-bit key

14 rounds executed

4

AES-128 Round Count Check

Verify round count

10 rounds confirmed

5

AES-192 Round Count Check

Verify round count

12 rounds confirmed

6

AES-256 Round Count Check

Verify round count

14 rounds confirmed

7

AES-128 Round Key Generation

Generate round keys

11 round keys generated

8

AES-192 Round Key Generation

Generate round keys

13 round keys generated

9

AES-256 Round Key Generation

Generate round keys

15 round keys generated

10

AES-128 Final Round

Check last round

No MixColumns applied

11

AES-192 Final Round

Check last round

No MixColumns applied

12

AES-256 Final Round

Check last round

No MixColumns applied

13

AES-128 Round Timing

Measure time per round

Consistent timing

14

AES-192 Round Timing

Measure time per round

Slightly longer

15

AES-256 Round Timing

Measure time per round

Longest

16

AES-128 Round SubBytes

Validate SubBytes step

Correct substitution

17

AES-192 Round ShiftRows

Validate ShiftRows step

Correct shifting

18

AES-256 Round MixColumns

Validate MixColumns step

Correct mixing

19

AES-128 Round AddRoundKey

Validate key addition

XOR with round key

20

AES-192 Round Key Expansion

Validate key schedule

Correct keys derived

21

AES-256 Round Key Expansion

Validate key schedule

Correct keys derived

22

AES-128 Round Order

Check operation sequence

SubBytes ShiftRows MixColumns AddRoundKey

23

AES-192 Round Order

Check operation sequence

Same as above

24

AES-256 Round Order

Check operation sequence

Same as above

25

AES-128 Round Integrity

Tamper with round

Decryption fails

26

AES-192 Round Integrity

Tamper with round

Decryption fails

27

AES-256 Round Integrity

Tamper with round

Decryption fails

28

AES-128 Round Debug

Log each round

10 rounds logged

29

AES-192 Round Debug

Log each round

12 rounds logged

30

AES-256 Round Debug

Log each round

14 rounds logged

31

AES-128 Round Reversal

Decrypt step-by-step

Plaintext recovered

32

AES-192 Round Reversal

Decrypt step-by-step

Plaintext recovered

33

AES-256 Round Reversal

Decrypt step-by-step

Plaintext recovered

34

AES-128 Round Fault Injection

Inject fault in round

Output corrupted

35

AES-192 Round Fault Injection

Inject fault in round

Output corrupted

36

AES-256 Round Fault Injection

Inject fault in round

Output corrupted

37

AES-128 Round Skipping

Skip a round

Decryption fails

38

AES-192 Round Skipping

Skip a round

Decryption fails

39

AES-256 Round Skipping

Skip a round

Decryption fails

40

AES-128 Round Duplication

Duplicate a round

Decryption fails

41

AES-192 Round Duplication

Duplicate a round

Decryption fails

42

AES-256 Round Duplication

Duplicate a round

Decryption fails

43

AES-128 Round Count Mismatch

Use wrong round count

Decryption fails

44

AES-192 Round Count Mismatch

Use wrong round count

Decryption fails

45

AES-256 Round Count Mismatch

Use wrong round count

Decryption fails

46

AES-128 Round Key Mismatch

Use wrong round key

Decryption fails

47

AES-192 Round Key Mismatch

Use wrong round key

Decryption fails

48

AES-256 Round Key Mismatch

Use wrong round key

Decryption fails

49

AES-128 Round Visualization

Visualize each round

10 rounds shown

50

AES-256 Round Visualization

Visualize each round

14 rounds shown

Substitution-Permutation Network (SPN) - Testcases

#

Test Case

Description

Expected Result

1

Apply SubBytes

Substitute bytes using S-box

Bytes transformed

2

Apply ShiftRows

Permute rows of state matrix

Rows shifted

3

Apply MixColumns

Mix columns using matrix multiplication

Columns transformed

4

Apply AddRoundKey

XOR state with round key

State updated

5

SPN Round Execution

Execute full round

State transformed

6

SPN Initial Round

Apply AddRoundKey only

Initial transformation

7

SPN Final Round

Skip MixColumns

Final transformation

8

SPN with AES-128

10 rounds of SPN

Encryption succeeds

9

SPN with AES-192

12 rounds of SPN

Encryption succeeds

10

SPN with AES-256

14 rounds of SPN

Encryption succeeds

11

SPN Byte Substitution

Validate S-box mapping

Correct substitution

12

SPN Byte Inversion

Use inverse S-box

Correct decryption

13

SPN Row Permutation

Validate ShiftRows

Correct row shift

14

SPN Column Mixing

Validate MixColumns

Correct column mix

15

SPN Key Mixing

Validate AddRoundKey

Correct XOR operation

16

SPN Round Integrity

Tamper with round

Decryption fails

17

SPN Round Skipping

Skip substitution

Decryption fails

18

SPN Round Duplication

Duplicate permutation

Decryption fails

19

SPN Round Reordering

Change order of steps

Decryption fails

20

SPN Round Logging

Log each transformation

All steps visible

21

SPN Round Visualization

Visualize state matrix

Changes per round shown

22

SPN Fault Injection

Inject fault in substitution

Output corrupted

23

SPN Fault Injection

Inject fault in permutation

Output corrupted

24

SPN Fault Injection

Inject fault in key mixing

Output corrupted

25

SPN Round Count Check

Count SPN rounds

Matches AES spec

26

SPN Round Key Expansion

Generate round keys

Keys match round count

27

SPN Round Key Mismatch

Use wrong key

Decryption fails

28

SPN Round Key Reuse

Reuse key across rounds

Insecure encryption

29

SPN Round Key Rotation

Rotate keys

Encryption remains secure

30

SPN Round Key Derivation

Derive keys from master key

Keys generated correctly

31

SPN with ECB Mode

No IV used

SPN applied per block

32

SPN with CBC Mode

IV used

SPN applied with chaining

33

SPN with CFB Mode

Feedback used

SPN applied to stream

34

SPN with OFB Mode

Output feedback used

SPN applied to stream

35

SPN with CTR Mode

Counter used

SPN applied to counter blocks

36

SPN with GCM Mode

Authenticated encryption

SPN applied with tag

37

SPN with corrupted input

Modify plaintext

Output differs

38

SPN with corrupted output

Modify ciphertext

Decryption fails

39

SPN with corrupted S-box

Use wrong substitution table

Decryption fails

40

SPN with corrupted permutation

Use wrong ShiftRows

Decryption fails

41

SPN with corrupted MixColumns

Use wrong matrix

Decryption fails

42

SPN with corrupted round key

Use wrong key

Decryption fails

43

SPN with custom S-box

Use alternate substitution

Encryption works if reversible

44

SPN with custom permutation

Use alternate row shift

Encryption works if reversible

45

SPN with custom MixColumns

Use alternate matrix

Encryption works if reversible

46

SPN with custom round structure

Change order of steps

Encryption works if reversible

47

SPN with reduced rounds

Use fewer rounds

Encryption weaker

48

SPN with increased rounds

Use more rounds

Encryption stronger

49

SPN with round profiling

Measure time per step

Performance analyzed

50

SPN with round auditing

Log transformations

Audit trail available

Fast and Efficient - Testcases

#

Test Case

Description

Expected Result

1

Encrypt with AES-NI

Use hardware acceleration

Fast encryption

2

Decrypt with AES-NI

Use hardware acceleration

Fast decryption

3

Encrypt with OpenSSL

Use optimized software library

Fast encryption

4

Decrypt with OpenSSL

Use optimized software library

Fast decryption

5

Encrypt 1KB data

Measure time

< 1 ms (typical)

6

Encrypt 1MB data

Measure time

Fast performance

7

Encrypt 1GB data

Measure time

Efficient throughput

8

Encrypt on ARM CPU

Test on mobile processor

Efficient performance

9

Encrypt on Intel CPU

Test on desktop processor

High speed

10

Encrypt on GPU

Use GPU acceleration

High throughput

11

Encrypt on FPGA

Use hardware implementation

Very fast

12

Encrypt on ASIC

Use custom chip

Maximum efficiency

13

Encrypt with multithreading

Parallel processing

Speedup observed

14

Encrypt with SIMD

Use vector instructions

Performance boost

15

Encrypt with pipelining

Hardware pipeline

High throughput

16

Encrypt with low memory

Constrained environment

Still efficient

17

Encrypt on embedded system

IoT device

Acceptable speed

18

Encrypt on smartphone

Mobile device

Fast encryption

19

Encrypt on browser

JavaScript/WebCrypto

Fast and responsive

20

Encrypt with Python

Use PyCryptodome

Reasonable speed

21

Encrypt with C

Use native implementation

Very fast

22

Encrypt with Rust

Use safe and fast code

High performance

23

Encrypt with Go

Use Go crypto library

Efficient

24

Encrypt with Java

Use JCE

Fast encryption

25

Encrypt with .NET

Use System.Security.Cryptography

Fast encryption

26

Encrypt with Node.js

Use crypto module

Fast encryption

27

Encrypt with WebAssembly

Run in browser

Near-native speed

28

Encrypt with low CPU usage

Monitor CPU

Efficient resource use

29

Encrypt with low power

Measure energy

Power-efficient

30

Encrypt with low latency

Measure delay

Minimal latency

31

Encrypt with high throughput

Measure MB/s

High data rate

32

Encrypt with low overhead

Measure system load

Minimal impact

33

Encrypt with real-time input

Stream data

No lag

34

Encrypt with batch input

Process large files

Efficient

35

Encrypt with concurrent users

Multi-session

Scales well

36

Encrypt with cloud function

Serverless

Fast execution

37

Encrypt with Docker

Containerized app

No performance loss

38

Encrypt with Kubernetes

Scalable deployment

Efficient under load

39

Encrypt with load balancer

Distribute load

Maintains speed

40

Encrypt with caching

Reuse results

Faster response

41

Encrypt with precomputed keys

Avoid key expansion

Faster rounds

42

Encrypt with optimized S-box

Fast substitution

Improved speed

43

Encrypt with lookup tables

Precomputed values

Faster operations

44

Encrypt with minimal code

Lightweight implementation

Fast execution

45

Encrypt with optimized compiler

Use -O3 flag

Faster binary

46

Encrypt with JIT compilation

Runtime optimization

Fast execution

47

Encrypt with benchmarking

Compare libraries

AES is fastest

48

Encrypt with profiling

Identify bottlenecks

AES shows efficiency

49

Encrypt with stress test

High load

AES remains stable

50

Encrypt with performance logging

Log time and usage

AES performs well

Strong Security - Testcases

#

Test Case

Description

Expected Result

1

Brute-force AES-128

Attempt all key combinations

Computationally infeasible

2

Brute-force AES-192

Attempt all key combinations

Computationally infeasible

3

Brute-force AES-256

Attempt all key combinations

Computationally infeasible

4

Differential cryptanalysis

Analyze input-output differences

No useful patterns found

5

Linear cryptanalysis

Approximate linear expressions

No significant bias

6

Meet-in-the-middle attack

Try combining partial keys

Not effective

7

Related-key attack

Use similar keys

AES resists attack

8

Side-channel attack

Monitor power/timing

Requires physical access

9

Timing attack

Measure encryption time

No key leakage

10

Power analysis attack

Monitor power usage

No key leakage

11

Fault injection attack

Inject hardware faults

AES resists or detects

12

Chosen plaintext attack

Encrypt known plaintexts

No key leakage

13

Chosen ciphertext attack

Decrypt known ciphertexts

No key leakage

14

Known plaintext attack

Use known plaintext-ciphertext pairs

Key not revealed

15

Ciphertext-only attack

Analyze ciphertexts only

Key not revealed

16

Replay attack

Reuse old ciphertext

No effect without context

17

Key recovery attack

Attempt to derive key

Infeasible

18

Key schedule analysis

Analyze key expansion

No weakness found

19

Avalanche effect

Small input change large output change

Confirmed

20

S-box analysis

Analyze substitution layer

Non-linear and secure

21

MixColumns analysis

Analyze diffusion

Strong diffusion confirmed

22

ShiftRows analysis

Analyze permutation

Ensures diffusion

23

Round function analysis

Analyze round transformations

Secure structure

24

Round key independence

Ensure keys differ per round

Confirmed

25

Key sensitivity test

Small key change different ciphertext

Confirmed

26

Plaintext sensitivity test

Small plaintext change different ciphertext

Confirmed

27

Ciphertext indistinguishability

Ciphertext appears random

Confirmed

28

Entropy test

Measure ciphertext randomness

High entropy

29

Statistical test

Analyze ciphertext distribution

Uniform distribution

30

Frequency analysis

Check for patterns

No patterns found

31

Pattern resistance

Encrypt repeating patterns

No visible repetition

32

ECB mode weakness

Identical blocks same ciphertext

Confirmed (insecure mode)

33

CBC mode security

IV prevents repetition

Confirmed

34

GCM mode authentication

Detect tampering

Tag verification fails

35

CTR mode security

Counter ensures uniqueness

Confirmed

36

Key reuse detection

Reuse key with different IV

Still secure (with IV)

37

IV reuse detection

Reuse IV in CBC mode

Security compromised

38

Key derivation security

Use PBKDF2

Secure key generation

39

Password-based key

Use strong password

Secure if high entropy

40

Weak key detection

Use all-zero key

Works but insecure

41

Strong key enforcement

Use random key

Secure encryption

42

Key rotation policy

Rotate keys periodically

Maintains security

43

Key expiration policy

Expire old keys

Prevents long-term exposure

44

Key revocation test

Revoke compromised key

Key no longer usable

45

Secure key storage

Use HSM or TPM

Keys protected

46

Secure key transmission

Use TLS or encrypted channel

Keys not exposed

47

Secure implementation

Use validated library

No known vulnerabilities

48

Compliance check

FIPS 197 compliance

AES certified

49

Cryptanalysis resistance

Review academic attacks

AES remains secure

50

Long-term security

Evaluate against quantum threats

AES-256 recommended

Widely Adopted - Testcases

1

Use AES in HTTPS

Secure web traffic

Encrypted communication

2

Use AES in VPN

Encrypt VPN tunnel

Secure connection

3

Use AES in TLS

Transport Layer Security

Data confidentiality

4

Use AES in SSH

Secure shell sessions

Encrypted terminal

5

Use AES in IPsec

Secure IP packets

Encrypted network traffic

6

Use AES in Wi-Fi

WPA2/WPA3 encryption

Secure wireless access

7

Use AES in disk encryption

Full disk encryption (e.g., BitLocker)

Data protected

8

Use AES in file encryption

Encrypt files (e.g., 7-Zip, VeraCrypt)

Files secured

9

Use AES in cloud storage

Encrypt data at rest (e.g., AWS S3)

Data confidentiality

10

Use AES in mobile apps

Secure messaging (e.g., WhatsApp)

End-to-end encryption

11

Use AES in banking apps

Secure transactions

Data protected

12

Use AES in payment systems

Encrypt card data

PCI DSS compliance

13

Use AES in ATMs

Secure PIN and transaction data

Encrypted communication

14

Use AES in smart cards

Secure embedded data

Data encrypted

15

Use AES in passports

e-Passport chip encryption

Identity protection

16

Use AES in government systems

Classified data protection

AES-256 used

17

Use AES in military systems

Secure communications

AES-256 preferred

18

Use AES in healthcare

Encrypt patient records (HIPAA)

Data confidentiality

19

Use AES in legal tech

Secure document storage

Confidentiality ensured

20

Use AES in education

Secure student data

FERPA compliance

21

Use AES in IoT devices

Secure sensor data

Lightweight AES used

22

Use AES in automotive

Secure vehicle communication

Data encrypted

23

Use AES in blockchain

Encrypt wallet keys

Secure storage

24

Use AES in cryptocurrency

Secure private keys

AES-based encryption

25

Use AES in password managers

Encrypt vaults (e.g., LastPass)

Passwords protected

26

Use AES in email encryption

Secure email content

Encrypted messages

27

Use AES in backup systems

Encrypt backups

Data protected

28

Use AES in DRM

Protect digital content

Unauthorized access blocked

29

Use AES in video conferencing

Secure calls (e.g., Zoom)

Encrypted streams

30

Use AES in messaging apps

Secure chats (e.g., Signal)

End-to-end encryption

31

Use AES in browsers

Secure cookies and storage

Data encrypted

32

Use AES in OS security

Encrypt user data (e.g., macOS FileVault)

Data protected

33

Use AES in enterprise software

Secure business data

Compliance ensured

34

Use AES in DevOps

Secure secrets in CI/CD

Encrypted credentials

35

Use AES in container security

Encrypt volumes

Data confidentiality

36

Use AES in database encryption

Encrypt tables/columns

Data protected

37

Use AES in email servers

Secure SMTP/IMAP

Encrypted communication

38

Use AES in digital forensics

Secure evidence storage

Data integrity maintained

39

Use AES in law enforcement

Encrypt case files

Confidentiality ensured

40

Use AES in telecom

Secure voice/data

Encrypted channels

41

Use AES in satellite communication

Encrypt telemetry

Secure transmission

42

Use AES in smart homes

Secure device communication

Data encrypted

43

Use AES in wearables

Encrypt health data

Privacy protected

44

Use AES in gaming

Secure in-game transactions

Data protected

45

Use AES in e-commerce

Secure checkout

PCI DSS compliance

46

Use AES in logistics

Encrypt tracking data

Secure supply chain

47

Use AES in manufacturing

Secure industrial control systems

Data confidentiality

48

Use AES in energy sector

Secure smart grid data

Encrypted communication

49

Use AES in AI/ML pipelines

Encrypt training data

Privacy preserved

50

Use AES in national ID systems

Secure citizen data

Identity protection

Flexible Modes of Operation - Testcases

#

Test Case

Description

Expected Result

1

Encrypt with ECB mode

Basic block-by-block encryption

Identical blocks same ciphertext

2

Encrypt with CBC mode

Chained block encryption

Ciphertext depends on previous block

3

Encrypt with CFB mode

Stream-like encryption

Ciphertext generated

4

Encrypt with OFB mode

Output feedback mode

Stream cipher behavior

5

Encrypt with CTR mode

Counter mode

Parallelizable encryption

6

Encrypt with GCM mode

Authenticated encryption

Ciphertext + authentication tag

7

Decrypt with ECB mode

Decrypt ECB ciphertext

Plaintext recovered

8

Decrypt with CBC mode

Decrypt CBC ciphertext

Plaintext recovered

9

Decrypt with CFB mode

Decrypt CFB ciphertext

Plaintext recovered

10

Decrypt with OFB mode

Decrypt OFB ciphertext

Plaintext recovered

11

Decrypt with CTR mode

Decrypt CTR ciphertext

Plaintext recovered

12

Decrypt with GCM mode

Verify tag and decrypt

Plaintext recovered if tag valid

13

ECB mode pattern test

Encrypt repeating blocks

Identical ciphertext blocks

14

CBC mode IV test

Use different IVs

Different ciphertexts

15

CBC mode IV reuse

Reuse IV

Insecure encryption

16

CFB mode bit-level test

Encrypt bit-by-bit

Works like stream cipher

17

OFB mode bit-level test

Encrypt bit-by-bit

Works like stream cipher

18

CTR mode counter test

Use incrementing counter

Unique ciphertext blocks

19

GCM mode tag verification

Modify tag

Decryption fails

20

GCM mode tag omission

Omit tag

Decryption fails

21

ECB mode weakness

Analyze ciphertext

Patterns visible

22

CBC mode chaining

Analyze block dependency

Strong diffusion

23

CFB mode feedback

Analyze feedback loop

Stream-like behavior

24

OFB mode feedback

Analyze output feedback

Stream-like behavior

25

CTR mode parallelism

Encrypt blocks in parallel

High performance

26

GCM mode integrity

Tamper with ciphertext

Tag mismatch

27

ECB mode with padding

Use PKCS#7

Ciphertext generated

28

CBC mode with padding

Use PKCS#7

Ciphertext generated

29

CTR mode without padding

No padding needed

Ciphertext generated

30

GCM mode with AAD

Add associated data

Authenticated encryption

31

GCM mode without AAD

No associated data

Still secure

32

ECB mode with binary data

Encrypt image

Patterns visible

33

CBC mode with binary data

Encrypt image

Patterns hidden

34

CTR mode with binary data

Encrypt image

Patterns hidden

35

GCM mode with binary data

Encrypt image

Authenticated encryption

36

ECB mode with text

Encrypt text

Patterns visible

37

CBC mode with text

Encrypt text

Patterns hidden

38

CTR mode with text

Encrypt text

Patterns hidden

39

GCM mode with text

Encrypt text

Authenticated encryption

40

ECB mode decryption error

Use wrong key

Garbage output

41

CBC mode decryption error

Use wrong IV

Garbage output

42

CTR mode decryption error

Use wrong counter

Garbage output

43

GCM mode decryption error

Use wrong tag

Decryption fails

44

ECB mode performance

Measure speed

Fastest but insecure

45

CBC mode performance

Measure speed

Moderate speed

46

CTR mode performance

Measure speed

High speed

47

GCM mode performance

Measure speed

High speed + integrity

48

ECB mode compliance

Check FIPS compliance

Not recommended

49

CBC mode compliance

Check FIPS compliance

Approved with padding

50

GCM mode compliance

Check FIPS compliance

Approved and preferred

  • Reference links