Photo by Karla Hernandez on Unsplash

Decrypting Ciphertext

--

I love puzzles. I love the challenge. I love finding patterns. I suppose it’s the main reason I do Cybersecurity. Basically, it is the way my brain is wired, I think. And doing crypto is a great joy of mines. To encrypt something, and then to be able to decrypt it, is something that I love. Sometimes we know the secret keys, and other times, not. But, it is in our human nature to solve problems, and it is the reason we have been so successful as a species. Our abilities to reason and to find sense in things that do not follow a standard path. So let’s do some ciphertext decrypting.

Overall with our ciphertext, we normally have a Base64 format, as the bytes in our cipher stream will contain non-printing characters. So, we might have [here]:

U2FsdGVkX18kH6hnY7hTQc/oR+6hDdawq9RflrNLWsA=

In this case, I have used 128-bit AES in CBC mode and with the PBKDF2 standard key derivation method in OpenSSL. How do we then decrypt this? Well, we just use OpenSSL with decryption (-d) and with the required password to get [here]:

echo  U2FsdGVkX18kH6hnY7hTQc/oR+6hDdawq9RflrNLWsA= | openssl enc -aes-128-cbc -pass pass:"qwerty" -d -base64 -pbkdf2
hello

We then get a plaintext message of “hello”. If we try the wrong password we get an exception:

echo  U2FsdGVkX18kH6hnY7hTQc/oR+6hDdawq9RflrNLWsA= |…

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.