I understand that nowadays passwords are not stored in plaintext, only as password + salt and hashed (minimum). But I haven't found any exact confirmation that gpg does NOT store (cache, place in RAM) the passphrase in plaintext.

And if a password is stored in plaintext, i.e. it is decrypted repeatedly using this password, how is it protected so that it is not stolen from the cache (RAM or wherever it is located)?

  • 1
    I think you have some confusion here. A password needed for decryption cannot be stored as a hash since it is not reversible and so access to the password would not be possible. A hash is only used if it is about password verification since in this case one just hashes the entered password the same way and compares it to the stored hash, i.e. no reversing the hash needed. In case of GPG the passphrase is used to encrypt the private key, so it cannot be stored as hash. Jan 6 at 19:57
  • 1
    OS separate processes from each other so one normal processes cannot simply read the memory of another one. Additionally gnupg locks the memory so that it does not get swapped out to disk. root might maybe able to read the memory (/dev/mem) but then a root user might even use a different kernel with weakened protection. In virtual environments the hypervisor will of course also be able to inspect the memory. Jan 6 at 20:15
  • 2
    @NewLinux any user who is able to snoop the memory at will is capable of snooping the input to gpg as well. If the machine is that compromised, you can't safely use gpg on it.
    – vidarlo
    Jan 6 at 20:28
  • 1
    @SteffenUllrich That's not completely true. Generally, processes can inspect/dump the memory of other processes running under the same uid (at least on linux and windows). A process may however take steps to prevent other unprivileged processes from accessing their memory, and it is possible gnupg does that.
    – nobody
    Jan 6 at 21:05
  • 1
    @nobody: Thanks for your input and you are at least partially right. I don't know about Windows. But as far as I know in Linux the process needs to have ptrace privileges enabled. Some systems have this disabled by default, others not. But it is just a config option away. Jan 6 at 21:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.