Lets say Alice and Bob have a secret key k1. This key is 50 chars long and is cryptographically random. Alice generates a cryptographically random string (e.g. 16 chars long) and hashes this string and k1 with an algorithm like pbkfd2 or scrypt to generate a new key k2.

Alice then encrypts the message with k2 using AES-CBC. Alice sends the encrypted message and the random string (in plaintext) to Bob. Bob then generates k2 by hashing k1 and the random string to decrypt the message. This way every message is encrypted with a different key. Is this approach secure?

  • "This key is 50 chars long" keys are binary. 32 bytes would result in 256 bits of key material, which should be plenty. However, you seem to be talking about a passphrase. Your random string should probably be considered a salt. CBC is vulnerable against plaintext & padding oracle attacks, and is by itself not secure for transport security. This all besides the answer given by mti2935. So no, not secure. Commented Mar 20, 2023 at 12:13

1 Answer 1


This protocol would not provide perfect forward secrecy (PFS).

Consider a passive eavesdropper, Eve, between Alice and Bob, who records all of the messages sent between Alice and Bob, for many years. Eventually, Alice experiences a breach, and k1 is disclosed. Eve now has everything she needs to go back and decrypt all of the messages sent between Alice and Bob.

With protocols that provide PFS (such as Signal Protocol and modern versions of TLS), this type of attack is not possible.

  • What if Alice encrypts the random string with Bobs public key and sends it like this. Would it provide PFS then?
    Commented Dec 7, 2022 at 21:42
  • No, because if Bob's private key is ever compromised, then Eve can go back and decrypt everything that was ever encrypted with Bob's public key and sent to Bob. For PFS, you need ephemeral key exchange. See signal.org/blog/asynchronous-security for some interesting reading on this subject.
    – mti2935
    Commented Dec 7, 2022 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .