• 3 Posts
  • 10 Comments
Joined 9 months ago
cake
Cake day: November 17th, 2024

help-circle





  • At the simplest level: An encryption algorithm doesn’t concern itself with whether or not the right key was provided*. It takes a key, some encrypted data, and then spits out whethever the math says it should.

    Programmers will build on top of an algorithm to add more complex security features. An example of which might be “Tell the user whether or not their key actually worked” or “Tell the user if someone tampered with the encrypted data”.

    The actual implementation of these security features is different for every situation, and can get quite complex.

    Here is a very simple example of what someone might do:

    1. Take the data that someone wants to encrypt eg “hello world”
    2. Put a known constant value at the beginning of the data eg using the constant “sentinel” with “hello world” becomes “sentinelhello world”
    3. Encrypt everything together

    Then when decrypting, you look for the word “sentinel” at the beginning, and then spit back everything after that. If the word “sentinel” isn’t the first thing you see, then you know the key is incorrect.

    In the case of AES algorithm, it has a special way of padding the plaintext before encrypting. If the padding doesn’t show up after decrypting, then the key is incorrect.

    * A general statement, not necessarily representative of common encryption algorithms