Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passforios works with gpg-generated keys, but not passphrase2pgp ones #5

Open
jakajancar opened this issue Oct 4, 2019 · 6 comments

Comments

@jakajancar
Copy link

jakajancar commented Oct 4, 2019

See mssun/passforios#318. Likely a bug there, but something is different between the keys that makes one work but not the other one.

The only difference I can see is the Authentication usage, but that shouldn't matter.

Key generated by passphrase2pgp (not working):

sec  ed25519/A0F42AA25ECE82CF
     created: 1970-01-01  expires: never       usage: SCA 
     trust: ultimate      validity: ultimate
ssb  cv25519/DCFD5B0A1DF33E4F
     created: 1970-01-01  expires: never       usage: E   
[ultimate] (1). Jaka Jancar <[email protected]>

Key generated by gpg (working):

sec  ed25519/0564372101766863
     created: 2019-10-04  expires: never       usage: SC  
     trust: ultimate      validity: ultimate
ssb  cv25519/72759FECE62D9A8E
     created: 2019-10-04  expires: never       usage: E   
[ultimate] (1). Jaka Jancar <[email protected]>
@jakajancar
Copy link
Author

They also have differing packets and subpackets:

passphrase2pgp (not working):

# off=0 ctb=94 tag=5 hlen=2 plen=88
:secret key packet:
	version 4, algo 22, created 0, expires 0
	pkey[0]: [80 bits] ed25519 (1.3.6.1.4.1.11591.15.1)
	pkey[1]: [263 bits]
	skey[2]: [255 bits]
	checksum: 1155
	keyid: A0F42AA25ECE82CF
# off=90 ctb=b4 tag=13 hlen=2 plen=28
:user ID packet: "Jaka Jancar <[email protected]>"
# off=120 ctb=88 tag=2 hlen=2 plen=100
:signature packet: algo 22, keyid A0F42AA25ECE82CF
	version 4, created 0, md5len 0, sigclass 0x13
	digest algo 8, begin of digest 2f 64
	hashed subpkt 2 len 4 (sig created 1970-01-01)
	hashed subpkt 16 len 8 (issuer key ID A0F42AA25ECE82CF)
	hashed subpkt 27 len 1 (key flags: 03)
	hashed subpkt 30 len 1 (features: 01)
	data: [255 bits]
	data: [255 bits]
# off=222 ctb=9c tag=7 hlen=2 plen=93
:secret sub key packet:
	version 4, algo 18, created 0, 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: 1065
	keyid: DCFD5B0A1DF33E4F
# off=317 ctb=88 tag=2 hlen=2 plen=97
:signature packet: algo 22, keyid A0F42AA25ECE82CF
	version 4, created 0, md5len 0, sigclass 0x18
	digest algo 8, begin of digest ff 1a
	hashed subpkt 2 len 4 (sig created 1970-01-01)
	hashed subpkt 16 len 8 (issuer key ID A0F42AA25ECE82CF)
	hashed subpkt 27 len 1 (key flags: 0C)
	data: [255 bits]
	data: [256 bits]

gpg (working):

# off=0 ctb=94 tag=5 hlen=2 plen=87
:secret key packet:
	version 4, algo 22, created 1570193808, expires 0
	pkey[0]: [80 bits] ed25519 (1.3.6.1.4.1.11591.15.1)
	pkey[1]: [263 bits]
	skey[2]: [248 bits]
	checksum: 11d9
	keyid: 0564372101766863
# off=89 ctb=b4 tag=13 hlen=2 plen=28
:user ID packet: "Jaka Jancar <[email protected]>"
# off=119 ctb=88 tag=2 hlen=2 plen=144
:signature packet: algo 22, keyid 0564372101766863
	version 4, created 1570193808, md5len 0, sigclass 0x13
	digest algo 8, begin of digest 3e 81
	hashed subpkt 33 len 21 (issuer fpr v4 9524727D0EF453D57F1A881E0564372101766863)
	hashed subpkt 2 len 4 (sig created 2019-10-04)
	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 0564372101766863)
	data: [256 bits]
	data: [253 bits]
# off=265 ctb=9c tag=7 hlen=2 plen=93
:secret sub key packet:
	version 4, algo 18, created 1570193808, 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: 127a
	keyid: 72759FECE62D9A8E
# off=360 ctb=88 tag=2 hlen=2 plen=120
:signature packet: algo 22, keyid 0564372101766863
	version 4, created 1570193808, md5len 0, sigclass 0x18
	digest algo 8, begin of digest 76 29
	hashed subpkt 33 len 21 (issuer fpr v4 9524727D0EF453D57F1A881E0564372101766863)
	hashed subpkt 2 len 4 (sig created 2019-10-04)
	hashed subpkt 27 len 1 (key flags: 0C)
	subpkt 16 len 8 (issuer key ID 0564372101766863)
	data: [256 bits]
	data: [255 bits]

@skeeto
Copy link
Owner

skeeto commented Oct 4, 2019 via email

@jakajancar
Copy link
Author

Tried and adding a date does not help.

passforios doesn't use GPG but https://github.com/krzyzanowskim/ObjectivePGP

I'm not using passphrase protection anywhere.

Keep in mind it's not a problem to import keys. Keys are in passforios and on my mac.

Encrypted on mac -> can be decrypted in passforios
Encrypted on passforios -> CANNOT be decrypted on mac

So problem is (I guess?) in encryption.

@jakajancar
Copy link
Author

Actually I'm not sure if they use ObjectivePGP or gopenpgp, both seems to be referenced in the source code.

@jakajancar
Copy link
Author

jakajancar commented Oct 4, 2019

I can reproduce this using the gopenpgp library directly:

package main

import (
    "fmt"
    "os"
    "log"
    "github.com/ProtonMail/gopenpgp/helper"
)

func main() {
    // Generated using: passphrase2pgp --uid 'passforios <[email protected]>' --input <(echo passforios) --subkey --armor
    const pubkey = `-----BEGIN PGP PUBLIC KEY BLOCK-----

mDMEAAAAABYJKwYBBAHaRw8BAQdA/w7UpmqD3wnD69YSKpJ8E7Ml8a6poRgolIpL
NmDdtEm0I3Bhc3Nmb3Jpb3MgPHBhc3Nmb3Jpb3NAZXhhbXBsZS5jb20+iGQEExYI
ABYFAgAAAAAJEPEjCrixFCE5AhsDAh4BAAChzQEAl899IV1vzHNqFiFjZQWxq1a0
oi9BVGaLJac+ECBs/NQA/jciYLJQnsdg/tcPdHJ63J5ZLBE7acdee+eE6QWbuRAH
uDgEAAAAABIKKwYBBAGXVQEFAQEHQM+cXZ5W1y+N6w1z4B2RQgaDvXYAvvXxQhD9
15ExxAUpAwEICYhhBBgWCAATBQIAAAAACRDxIwq4sRQhOQIbDAAAOZsA/3jvGQDh
C62jPKfVXZk2JrHuFzUcpYj7woFNz/Z24eOlAQDL5I2rA1FSS62lgISDlMjrkwmX
6iM98rMDdbAAP0v5Bw==
=aiqQ
-----END PGP PUBLIC KEY BLOCK-----
`

    armor, err := helper.EncryptMessageArmored(pubkey, "plain text")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Fprintf(os.Stdout, armor)
}

gpg -d fails with:

gpg: encrypted with 256-bit ECDH key, ID 54F7F66E3272CA09, created 1970-01-01
      "passforios <[email protected]>"
gpg: public key decryption failed: Wrong secret key used
gpg: decryption failed: No secret key

@Fastidious
Copy link

What version of gpg are you using, @jakajancar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants