Before version 1.42.6 old keys were saved, but not used for decryption. Starting with Delta Chat Android 1.42.6 this bug is fixed:
The problem you have is about importing the key though. XXX is the address and YYY is the “certificate issuer”, if they don’t match Delta Chat complains. Maybe it is actually a wrong check as it only allows “self-signed” keys:
Delta Chat supports simple keys where the key is signed with itself. If you have something more complicated, this is not tested and may fail, in this case we need more details about the structure of the key file you are trying to import.
Here is an example key:
$ gpg --list-packets alice-secret.asc
# off=0 ctb=94 tag=5 hlen=2 plen=88
:secret key packet:
version 4, algo 22, created 1582855645, expires 0
pkey[0]: [80 bits] ed25519 (1.3.6.1.4.1.11591.15.1)
pkey[1]: [263 bits]
skey[2]: [256 bits]
checksum: 1037
keyid: 64B08F61A9ED9443
# off=90 ctb=b4 tag=13 hlen=2 plen=25
:user ID packet: "Alice <alice@example.org>"
# off=117 ctb=88 tag=2 hlen=2 plen=144
:signature packet: algo 22, keyid 64B08F61A9ED9443
version 4, created 1582855645, md5len 0, sigclass 0x13
digest algo 8, begin of digest 13 7a
hashed subpkt 33 len 21 (issuer fpr v4 2E6FA2CB23B532D728634B5864B08F61A9ED9443)
hashed subpkt 2 len 4 (sig created 2020-02-28)
hashed subpkt 27 len 1 (key flags: 03)
hashed subpkt 11 len 4 (pref-sym-algos: 9 8 7 2)
hashed subpkt 21 len 5 (pref-hash-algos: 10 9 8 11 2)
hashed subpkt 22 len 3 (pref-zip-algos: 2 3 1)
hashed subpkt 30 len 1 (features: 01)
hashed subpkt 23 len 1 (keyserver preferences: 80)
subpkt 16 len 8 (issuer key ID 64B08F61A9ED9443)
data: [254 bits]
data: [249 bits]
# off=263 ctb=9c tag=7 hlen=2 plen=93
:secret sub key packet:
version 4, algo 18, created 1582855645, expires 0
pkey[0]: [88 bits] cv25519 (1.3.6.1.4.1.3029.1.5.1)
pkey[1]: [263 bits]
pkey[2]: [32 bits]
skey[3]: [255 bits]
checksum: 106f
keyid: E6DABADE14DE79B0
# off=358 ctb=88 tag=2 hlen=2 plen=120
:signature packet: algo 22, keyid 64B08F61A9ED9443
version 4, created 1582855645, md5len 0, sigclass 0x18
digest algo 8, begin of digest 2e 8f
hashed subpkt 33 len 21 (issuer fpr v4 2E6FA2CB23B532D728634B5864B08F61A9ED9443)
hashed subpkt 2 len 4 (sig created 2020-02-28)
hashed subpkt 27 len 1 (key flags: 0C)
subpkt 16 len 8 (issuer key ID 64B08F61A9ED9443)
data: [256 bits]
data: [256 bits]
In the signature packet issuer key ID 64B08F61A9ED9443 of the signature packet matches the secret key ID. If this is not the case for your key, importing fails.
Actually the key contains a signature with the ID of my previous/older key. But why should this be a problem?
I removed that signature and tried again to import it. Now I get: “IMEX failed to complete: incomplete input: Size(2320)”. The file is complete and bigger than 2320.
How did you delete the signature? Could you write down the steps that result in creation of the key with the same structure as yours to reproduce this “incomplete input” issue?
This is probably a bug in rPGP if the key is valid. “Incomplete input” is a parser error, size is the number of bytes expected when end of the file was reached.
I created a key pair via gpg --quick-gen-key and then added a signature via the “seahorse” gui, which used my default ID (old key). So I had a signature with my old ID.
I deleted the sig with gpg --edit-key.
$ gpg --quick-gen-key alice@example.org
About to create a key for:
"alice@example.org"
Continue? (Y/n)
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: revocation certificate stored as '/home/user/.gnupg/openpgp-revocs.d/FF2892D1DB3FF0FED28A87FFF0A82A638ED0F640.rev'
public and secret key created and signed.
pub ed25519 2023-12-08 [SC] [expires: 2026-12-07]
FF2892D1DB3FF0FED28A87FFF0A82A638ED0F640
uid alice@example.org
sub cv25519 2023-12-08 [E]
Then I run --edit-key:
$ gpg --edit-key FF2892D1DB3FF0FED28A87FFF0A82A638ED0F640
gpg (GnuPG) 2.4.3; Copyright (C) 2023 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
sec ed25519/F0A82A638ED0F640
created: 2023-12-08 expires: 2026-12-07 usage: SC
trust: ultimate validity: ultimate
ssb cv25519/1DD28ADB14B5C842
created: 2023-12-08 expires: never usage: E
[ultimate] (1). alice@example.org
gpg> uid 1
sec ed25519/F0A82A638ED0F640
created: 2023-12-08 expires: 2026-12-07 usage: SC
trust: ultimate validity: ultimate
ssb cv25519/1DD28ADB14B5C842
created: 2023-12-08 expires: never usage: E
[ultimate] (1)* alice@example.org
gpg> delsig
uid alice@example.org
sig!3 F0A82A638ED0F640 2023-12-08 [self-signature]
Delete this good signature? (y/N/q)y
Really delete this self-signature? (y/N)y
Deleted 1 signature.
gpg> save
Do you have some other signatures on the key and other UserID packets? Could you show the result of sq packet dump key.asc or gpg --list-packets key.asc (with key IDs etc. edited out if needed)?
No I didn’t delete the self-signature, just the additional signature from the old key. You would first have to sign it with a different key → error “non matching key”.
Then delsig this foreign key → error “incomplete input”.
Delta Chat REPL when asked to import with import-keys bob.asc fails with error:
IMEX failed to complete: "validating certificate with a non matching Key ID KeyId(e325f7dfe442b4bd) != KeyId(839be8a4097aab5a)"
Then I edited the key to remove the signature:
$ gpg --local-user alice@example.org --edit-key bob@example.net
gpg (GnuPG) 2.4.3; Copyright (C) 2023 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
sec ed25519/E325F7DFE442B4BD
created: 2023-12-09 expires: 2026-12-08 usage: SC
trust: ultimate validity: ultimate
ssb cv25519/E8F9A694C240CE27
created: 2023-12-09 expires: never usage: E
[ultimate] (1). bob@example.net
gpg> uid 1
sec ed25519/E325F7DFE442B4BD
created: 2023-12-09 expires: 2026-12-08 usage: SC
trust: ultimate validity: ultimate
ssb cv25519/E8F9A694C240CE27
created: 2023-12-09 expires: never usage: E
[ultimate] (1)* bob@example.net
gpg> delsig
uid bob@example.net
sig!3 E325F7DFE442B4BD 2023-12-09 [self-signature]
Delete this good signature? (y/N/q)
uid bob@example.net
sig! 839BE8A4097AAB5A 2023-12-09 alice@example.org
Delete this good signature? (y/N/q)y
Deleted 1 signature.
gpg> save
gpg --armor --export-secret-keys bob@example.net > bob2.asc
bob2.asc imports successfully in Delta Chat. I have tested both with the core 1.131.7 used in Android release 1.42.4 and with the current main branch.
There must be something else special about the key you are trying to import. Could you check the structure of the key you are trying to import with gpg --list-packets key.asc or sq packet dump key.asc?
If it is a test key anyway, could you post the contents of test2.asc here? I will try to reproduce myself, but if you already created a test key it’s easier to use it.
gpg automatically asks for a password on --quick-generate-key - is this meant by
“password-protected”?
The password is requested on --export-secret-keys, so the result should be password-free?
My default key I use with DeltaChat has this kind of password, too. I don’t remember being asked for it …
Looks like with GnuPG you need to change passphrase to empty first, then export it.
Alternatively, use sq:
$ sq key password encrypted-key.asc
Enter password to unlock E325F7DFE442B4BD (blank to skip):
New password:
Repeat new password:
-----BEGIN PGP PRIVATE KEY BLOCK-----
If you mean the key Delta Chat itself generated when you setup it, it is not passphrase-protected. Could be you added a passphrase after importing it in GnuPG. Delta Chat itself has no code to encrypt the key.
My default key is gpg-generated and on the desktop I have to enter the password on every startup. Maybe it was possible in D.C when I imported it years ago …
Now I removed the password and was able to import the test key. The problem now is that the old key is not working anymore so I can’t read messages anymore. And I have to remove its password to import it again!
And after key import the undecrypted message will stay undecrypted …
so many bugs on one single action.