I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #+TITLE: Encryption
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle encryption.el :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export :comments org
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. My source files encrypted with symmetric key encryption via *GPG*[fn:1]. This enables my workflow of storing my personal notes anywhere, including checked in to a public source repository. Emacs can cache the *GPG*[fn:1] password if you trust your session. *Pinentry*[fn:2] handled within Emacs to remain compatible without the [[file:desktop.org][Desktop]] module.
  10. * Configuring the gpg-agent
  11. :PROPERTIES:
  12. :header-args: :tangle ../config/gpg-agent.conf
  13. :END:
  14. When the *gpg-agent*[fn:1] loads it will read the configuration at ~~/.gnupg/gpg-agent.conf~. Override the default settings to allow Emacs to function as the *Pinentry*[fn:2] application.
  15. #+begin_src conf
  16. allow-emacs-pinentry
  17. allow-loopback-pinentry
  18. #+end_src
  19. ** Restarting the gpg-agent
  20. You may need to restart the *gpg-agent*[fn:1] to load the configuration without rebooting.
  21. #+begin_src shell
  22. gpgconf --reload gpg-agent
  23. #+end_src
  24. ** Creating a symbolic link
  25. Create the symbolic link to the configuration file
  26. #+begin_src emacs-lisp
  27. (dotfiles/symlink "~/.emacs.d/config/gpg-agent.conf"
  28. "~/.gnupg/gpg-agent.conf")
  29. #+end_src
  30. * Setting up pinentry in Emacs
  31. With the *Pinentry*[fn:2] package for Emacs prompts will now appear in the minibuffer. Increase the minimum prime bit size to increase performance during symmetric encryption.
  32. #+begin_src emacs-lisp
  33. (use-package pinentry
  34. :custom (epa-file-select-keys 2)
  35. (gnutls-min-prime-bits 4096)
  36. (epa-pinentry-mode 'loopback)
  37. (epa-file-encrypt-to dotfiles/public-key)
  38. (epa-file-cache-passphrase-for-symmetric-encryption t)
  39. :config (pinentry-start))
  40. #+end_src
  41. ** Including *.gpg files
  42. Override ~org-agenda-file-regexp~ to include =.org.gpg= files.
  43. #+begin_src emacs-lisp
  44. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  45. (setq org-agenda-file-regexp
  46. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  47. org-agenda-file-regexp)))
  48. #+end_src
  49. ** Encrypting roam files
  50. Irrelevant without the [[file:writing.org][Writing]] module, encrypt new files from capture templates.
  51. #+begin_src emacs-lisp
  52. (with-eval-after-load 'org-roam
  53. (setq org-roam-encrypt-files t))
  54. #+end_src
  55. * Managing passwords
  56. *Pass*[fn:3] makes managing passwords easy, encrypring them in a file structure and providing easy commands for generating, modify, and copying passwords. *Password-store.el*[fn:4] provides a wrapper for the functionality within Emacs.
  57. #+begin_src emacs-lisp
  58. (use-package password-store
  59. :custom (password-store-dir dotfiles/passwords))
  60. #+end_src
  61. Configure keybindings behind =SPC p=.
  62. + Copy with =p=
  63. + Rename with =r=
  64. + Generate with =g=
  65. #+begin_src emacs-lisp
  66. (dotfiles/leader
  67. "p" '(:ignore t :which-key "Passwords")
  68. "pp" '(password-store-copy :which-key "Copy")
  69. "pr" '(password-store-rename :which-key "Rename")
  70. "pg" '(password-store-generate :which-key "Generate"))
  71. #+end_src
  72. * Footnotes
  73. [fn:1] https://gnupg.org
  74. [fn:2] https://elpa.gnu.org/packages/pinentry.html
  75. [fn:3] https://passwordstore.org
  76. [fn:4] https://git.zx2c4.com/password-store/tree/contrib/emacs