>_ IzzyLab

Hands-on task

This task is step 12 of the course “TLS and certificates”

Encrypt a file with a password

medium~5 min

Encrypt /root/data.txt symmetrically with AES-256-CBC, deriving the key with PBKDF2 (default iteration count, no -iter), into /root/data.enc with the password izzylab, so that the file decrypts with this password.

What you'll practise:
  • symmetric encryption
  • openssl enc
  • aes-256
  • pbkdf2
  • kdf and salt

Topic breakdown

Symmetric encryption uses a single shared secret for both encryption and decryption — this is what sets it apart from the asymmetric scheme with a key pair. The password here is not equal to the cipher key: the key is derived from the password by a KDF, so a modern robust key derivation and a random salt are critical, and decryption must use exactly the same KDF parameters and cipher, otherwise you'll get bad decrypt. All of this is done by the openssl enc subcommand: the cipher choice, the direction (encryption or the reverse mode -d), and the way the password is supplied are set by separate flags.

What's checked

  1. the file /root/data.enc is created
  2. the file decrypts to the original text with the password

What it looks like