org-journal icon indicating copy to clipboard operation
org-journal copied to clipboard

Add support for age encryption via age.el

Open fapdash opened this issue 5 months ago • 4 comments

  • require age.el if the package is installed https://github.com/anticomputer/age.el
  • add new customizable variable org-journal-encryption-extension to control the file extension appended to the file name to trigger transparent encryption
  • recognize .age files as journal files
  • generate encrypted files based on chosen file extension instead of hard coding .gpg
  • support .age files in org-journal-re-encrypt-journals - only re-encrypt files for the currently chosen encryption extension - functional change: don't edit/re-save files that aren't encrypted. I assume that they where handled by this function in the past was an oversight and not intended. - allow multiple recipients for age encryption

closes #441


age encyrption works with this change. TODOs from age encrypted journal files get added to the agenda. (org-journal-enable-agenda-integration)

I wasn't sure how to do optional dependencies for Emacs packages. If someone tries to set age as extension the org-journal-re-encrypt-journals function will fail because of missing functions, of course.

org-journal-re-encrypt-journals works for me if age-default-recipient and age-default-identity are set, but things got a bit weird when I hadn't set those. I might be missing some settings, but at some point age encryption wasn't working at all and I had to restart Emacs.

Theoretically org-journal would work with any encryption that implements transparent, as long as the org-journal--list-files and org-journal--dir-and-file-format->pattern would get consider the value of org-journal-encryption-extension in their regexes. If we don't want to implement this then it's probably better to make org-journal-encryption-extension of :type '(choice (const :tag "age" age) (const :tag "gpg" gpg)) instead of 'string.

Instructions for testing

  • Get age binaries: https://github.com/FiloSottile/age/releases/latest
  • Place binaries in $PATH

Create age keys:

age-keygen -o key.txt
age-keygen -y key.txt > key.pub

Example age.el configuration for testing:

(use-package age
  :ensure t
  :demand t
  :custom
  (age-program "age")
  (age-default-identity "~/.age/key.txt")
  (age-default-recipient '("~/.age/key.pub"))
  :config
  (age-file-enable))

Activate age encrption for org-journal:

(setq 
  org-journal-encrypt-journal t
  org-journal-encryption-extension "age")

fapdash avatar Aug 25 '24 17:08 fapdash