> > As for not typing the same password twice and not using > org-crypt-use-before-save-magic, we should somehow fix this. > (I am starting a new thread branch.) >
„Not using org-crypt-use-before-save-magic“ is currently a user decision, not a bug. For instance, I don't use it because it adds around 5 seconds to each saving of a large file. If it were instantaneous I would enable it. With it disabled, this explains why I often find unencrypted sections at the end of the day… I have to rely on myself to reencrypt them again. > One simple idea is to disable backups if encryption fails. > Or use `write-contents-functions' instead of `before-save-hook' - that > way, Emacs will not ignore errors thrown by org-crypt and will not > actually save anything if encryption fails. > Disabling backups makes sense too, if we decide that unencrypted private data shouldn't end up in backups. I don't have an absolute opinion. Some people may prefer having backups of all data (including private unencrypted data). If it's possible to detect whether encryption failed in this buffer, there could be a warning saying „Last encryption failed. Really save?“. Or just a message in the style of „Encryption failed. Saving the file may store unencrypted data in disk, and in backups and cache if enabled“. Totally preventing the user from saving a file seems harsh but it also seems safer. Since users have different safety preferences, Emacs can let the user decide what the do, through a question or optional setting. > > At the end of the day when I do "git diff" + "git commit" sometimes I > > realize there's unencrypted data and then I have to reencrypt it. In > > the meantime I might have killed and reopened the buffer, thus > > updating the file cache. > > That may be a problem by org-encrypt and something to document in > > org-crypt itself. The point is that users of org-encrypt should take > > extra precautions when enabling org-element-cache-persistent. Like: > > not closing buffers while the sections are unencrypted. > > These things should be considered bugs. And we should fix them. Cache and > other libraries should not be responsible for special treatment of > optional org-crypt library. > You can't fix all bugs all the time, so you can't base security on „we strongly believe there are no more bugs“. If doing an extra verification (to avoid storing private data on disk in unencrypted form) is fast, it's better with the verification. In addition, „leaving some encrypted sections unencrypted for a short amount of time, and closing and reopening the buffer during that time“ isn't a bug, it's a possible user behaviour that we can't control. But org-crypt can mention that that behaviour is unsafe when using on-disk cache. Or detect it (if it's fast) and warn the user. > Cache and > other libraries should not be responsible for special treatment of > optional org-crypt library. That's arbitrary. Both persistent cache and org-crypt are optional, but any of them can check whether the other is enabled and try to do what the user wants. I know they both have separate responsibilities, but if there are only these 2 parts, one of them must be the one caring about „unencrypted data leaking into disk caches“. It would be different If we had a third component… E.g. imagine we had a component/overlay/text property/… in Emacs that could tell whether a buffer's region contains very private information or not; then all other components could just obey that setting (that section won't be backed up, it won't end up in disk cache, … It can even be displayed in a different face). Then org-crypt just needs to set that flag when encryption fails. Does something like that exist? Anyway this is a bit utopic or overengineered. Simpler ways of improving things are with documentation (e.g. „Don't do this, it's unsafe“), with messages („You're doing this, which may be unsafe“), or with questions („Really do this unsafe thing?“)