Re: org-crypt fails if default key is expired while non-default key is to be used

2023-04-18 Thread Karl Voit
* Ihor Radchenko  wrote:
> Karl Voit  writes:
>
>>> Ok. What about
>>>
>>> (let ((context (epg-make-context nil t t)))
>>>   (epg-decrypt-string context (epg-encrypt-string context "test" 
>>> (epg-list-keys context org-crypt-key
>>>
>>
>> It asks me for the passphrase of the orgmode key (the correct one)
>> and prints out "test".
>
> We just followed what org-crypt does... And you see no error.
> I have no more ideas how to investigate the original failure without a
> reproducer.

Fully understand. If it was an issue that was caused just by me, the
better. Thanks for investing into that issue or non-issue anyway!

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-31 Thread Ihor Radchenko
Karl Voit  writes:

>> Ok. What about
>>
>> (let ((context (epg-make-context nil t t)))
>>   (epg-decrypt-string context (epg-encrypt-string context "test" 
>> (epg-list-keys context org-crypt-key
>>
>
> It asks me for the passphrase of the orgmode key (the correct one)
> and prints out "test".

We just followed what org-crypt does... And you see no error.
I have no more ideas how to investigate the original failure without a
reproducer.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-30 Thread Karl Voit
Hi Ihor,

* Ihor Radchenko  wrote:
> Karl Voit  writes:
>
>>> What is the return value of
>>>
>>> (epg-list-keys (epg-make-context nil t t) org-crypt-key)
>>>
>>> ?
>>>
>>> Does it show the right key?
>>
>> It shows:
>>
>> (#s(epg-key ultimate
>> (#s(epg-sub-key ultimate ... nil 1 4096 "ABC12345" 1515327255 
>> nil "...ABC12345")
>>#s(epg-sub-key ultimate ... nil 1 4096 "FFF" 1515327255 
>> nil "."))
>> (#s(epg-user-id ultimate "Karl Voit (Internal key for orgmode) 
>> " nil
>>
>> ... with ABC12345 being the correct key for org-crypt and FFF being my
>> default OpenPGP key.
>
> Ok. What about
>
> (let ((context (epg-make-context nil t t)))
>   (epg-decrypt-string context (epg-encrypt-string context "test" 
> (epg-list-keys context org-crypt-key
>

It asks me for the passphrase of the orgmode key (the correct one)
and prints out "test".

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-30 Thread Ihor Radchenko
Karl Voit  writes:

>> What is the return value of
>>
>> (epg-list-keys (epg-make-context nil t t) org-crypt-key)
>>
>> ?
>>
>> Does it show the right key?
>
> It shows:
>
> (#s(epg-key ultimate
> (#s(epg-sub-key ultimate ... nil 1 4096 "ABC12345" 1515327255 nil 
> "...ABC12345")
>#s(epg-sub-key ultimate ... nil 1 4096 "FFF" 1515327255 
> nil "."))
> (#s(epg-user-id ultimate "Karl Voit (Internal key for orgmode) 
> " nil
>
> ... with ABC12345 being the correct key for org-crypt and FFF being my
> default OpenPGP key.

Ok. What about

(let ((context (epg-make-context nil t t)))
  (epg-decrypt-string context (epg-encrypt-string context "test" (epg-list-keys 
context org-crypt-key

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-29 Thread Karl Voit
Hi Ihor,

* Ihor Radchenko  wrote:
> Karl Voit  writes:
>
>>> May I know how exactly did you set `org-crypt-key'? Do you happen to
>>> have CRYPTKEY properties somewhere in your buffer?
>>
>> Sure. My config is on
>> https://github.com/novoid/dot-emacs/blob/master/config.org and I've
>> set it with:
>>
>> (setq org-crypt-key "ABC12345")  ;; I may have to mask this online as well 
>> ;-)
>
> What is the return value of
>
> (epg-list-keys (epg-make-context nil t t) org-crypt-key)
>
> ?
>
> Does it show the right key?

It shows:

(#s(epg-key ultimate
(#s(epg-sub-key ultimate ... nil 1 4096 "ABC12345" 1515327255 nil 
"...ABC12345")
   #s(epg-sub-key ultimate ... nil 1 4096 "FFF" 1515327255 nil 
"."))
(#s(epg-user-id ultimate "Karl Voit (Internal key for orgmode) 
" nil

... with ABC12345 being the correct key for org-crypt and FFF being my
default OpenPGP key.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-24 Thread Ihor Radchenko
Karl Voit  writes:

>> May I know how exactly did you set `org-crypt-key'? Do you happen to
>> have CRYPTKEY properties somewhere in your buffer?
>
> Sure. My config is on
> https://github.com/novoid/dot-emacs/blob/master/config.org and I've
> set it with:
>
> (setq org-crypt-key "ABC12345")  ;; I may have to mask this online as well ;-)

What is the return value of

(epg-list-keys (epg-make-context nil t t) org-crypt-key)

?

Does it show the right key?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-23 Thread Karl Voit
Hi Ihor,

* Ihor Radchenko  wrote:
> Karl Voit  writes:
>
>> When I invoked org-decrypt-entry, decrypting works like always. Then
>> I modified something in this heading which is tagged with :crypt:.
>> On saving that buffer, org-crypt issues an error message:
>>
>> | Error: (error "GPG error: \"Encrypt failed\", \"Unusable public key:
>> | A1234567; Exit\"")
>>
>> This A1234567 key is my default key and not the org-openpgp-key.
>>
>> org-encrypt-entry is causing this error at:
>>
>> |;; Text and key have to be identical, otherwise we
>> |;; re-crypt.
>> |(if (and (equal crypt-key key)
>> | (string= checksum (sha1 contents)))
>> |(get-text-property 0 'org-crypt-text contents)
>> |  (epg-encrypt-string epg-context contents crypt-key)))
>>
>> After fixing the expiry date of A1234567, org-crypt was working
>> properly, using the correct org-openpgp-key again.
>>
>> I do think this is wrong behavior: when the default key is expired
>> but a specific secondary key is used, encryption should be possible.
>
> All we do here is calling `epg-encrypt-string' with crypt key obtained
> using `org-crypt-key-for-heading', which see.
>
> May I know how exactly did you set `org-crypt-key'? Do you happen to
> have CRYPTKEY properties somewhere in your buffer?

Sure. My config is on
https://github.com/novoid/dot-emacs/blob/master/config.org and I've
set it with:

(setq org-crypt-key "ABC12345")  ;; I may have to mask this online as well ;-)

: grep -i CRYPTKEY *
... is empty when applied to my Org-mode files.

The only thing to fix my situation was to re-import a non-expired
version of my default OpenPGP sec key.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: org-crypt fails if default key is expired while non-default key is to be used

2023-01-23 Thread Ihor Radchenko
Karl Voit  writes:

> When I invoked org-decrypt-entry, decrypting works like always. Then
> I modified something in this heading which is tagged with :crypt:.
> On saving that buffer, org-crypt issues an error message:
>
> | Error: (error "GPG error: \"Encrypt failed\", \"Unusable public key:
> | A1234567; Exit\"")
>
> This A1234567 key is my default key and not the org-openpgp-key.
>
> org-encrypt-entry is causing this error at:
>
> | ;; Text and key have to be identical, otherwise we
> | ;; re-crypt.
> | (if (and (equal crypt-key key)
> |  (string= checksum (sha1 contents)))
> | (get-text-property 0 'org-crypt-text contents)
> |   (epg-encrypt-string epg-context contents crypt-key)))
>
> After fixing the expiry date of A1234567, org-crypt was working
> properly, using the correct org-openpgp-key again.
>
> I do think this is wrong behavior: when the default key is expired
> but a specific secondary key is used, encryption should be possible.

All we do here is calling `epg-encrypt-string' with crypt key obtained
using `org-crypt-key-for-heading', which see.

May I know how exactly did you set `org-crypt-key'? Do you happen to
have CRYPTKEY properties somewhere in your buffer?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at