google / end-to-end

End-To-End is a crypto library to encrypt, decrypt, digital sign, and verify signed messages (implementing OpenPGP)
Apache License 2.0
4.13k stars 298 forks source link

OpenKeyChain ECDSA Public Keys don't import #193

Closed koto closed 9 years ago

koto commented 9 years ago

From sirdarckcat on October 26, 2014 21:22:00

== PLEASE DONT PUT ANY KEYS HERE ==

Debug instructions:

  1. Please build the extension and go to chrome-extension://<extension-
    id>/prompt.html and try to encrypt, decrypt or import a key from there.

2. Note the error shown in red (if any)

Key Binding Signature Verification Failed

  1. Open the JavaScript console (Tools -> JavaScript Console)
    4. Copy the output from the console here.

"CustomError: Binding signature verification failed.
at e2e.openpgp.error.Error (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:5597:20)
at new e2e.openpgp.error.ParseError (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:5601:27)
at JSCompiler_prototypeAlias.addBindingSignature (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:12468:13)
at JSCompiler_prototypeAlias.parse (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:13207:18)
at Object.e2e.openpgp.block.factory.parseBlock (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:13298:380)
at Object.e2e.openpgp.block.factory.parseByteArrayMulti (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:13319:43)
at e2e.openpgp.ContextImpl.getKeyDescription (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/launcher_binary.js:16096:44)
at e2e.ext.actions.GetKeyDescription.e2e_ext_actions_Action_prototype$execute (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/settings_binary.js:7500:38)
at e2e.ext.actions.ImportKey.e2e_ext_actions_Action_prototype$execute (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/settings_binary.js:7517:144)
at null. (chrome-extension://okgecdkahgdmfcliiklafejolcocgcpe/settings_binary.js:18473:16)"

Have you tested if this key/message works in other implementations? (PGP
Desktop, GnuPG, etc..)

OpenKeyChain works ;)

If you can, please copy the output of gpg --list-packets .

-----BEGIN PGP PUBLIC KEY BLOCK-----  

mFIEVE1WqxMIKoZIzj0DAQcCAwSKPMnHw+VcvS8kthUP5dNPgf71RO/3ruqi0mqp  
TifjpHQeJs3puS45mj3EWZWeY4nB7HINbzf0iDvOP5kCY8s8tClFZHVhcmRvIFZl  
bGEgTmF2YSA8c2lyZGFyY2tjYXRAZ21haWwuY29tPoh5BBMTCgAhBQsJCAcDBhUK  
CQsIAwQWAgMBAhkBBYJUTVasAp4BApsjAAoJEASEfVw1RBQjFhABANu6ur8ccVGN  
FGL0eqh9t4UgR5pQXQlSQtYnXPR7R+WsAQDZMylgxf7ZYu7vh0Tjoo5SuAGP4gJw  
Al/gzvD/YPGilLhWBFRNVqwSCCqGSM49AwEHAgMERIGwMgcVTaDhryFxVUS21C2l  
s8FstvT60WmhyLZiTgEmaecz1jbFw0odUqFRTIB9DUiSOw5GkqxF6PWJtxo46gMB  
CAeIYQQYEwoACQWCVE1WrAKbDAAKCRAEhH1cNUQUIx44AQDmYhevo9zSYddaISXA  
PHi4RHJg29LVtMi8ygWVCg1gEAEAiCdX5oJC0aF6O338+2hsS8Rj9SGDFqsKZ3BI  
XlRbceQ=  
=WcB0  
-----END PGP PUBLIC KEY BLOCK-----  

Original issue: http://code.google.com/p/end-to-end/issues/detail?id=156

koto commented 9 years ago

From koto@google.com on December 04, 2014 06:18:18

gpg --import

gpg: key 35441423: no valid user IDs gpg: this may be caused by a missing self-signature

koto commented 9 years ago

From sirdarckcat on December 04, 2014 10:17:40

is that gpg 2.1? it's an ECC key

dlg-yahoo commented 9 years ago

Here's the output of pgpdump:

Old: Public Key Packet(tag 6)(82 bytes)
    Ver 4 - new
    Public key creation time - Sun Oct 26 13:16:43 PDT 2014
    Pub alg - Reserved for ECDSA(pub 19)
    Unknown public key(pub 19)
Old: User ID Packet(tag 13)(41 bytes)
    User ID - Eduardo Vela Nava <sirdarckcat@gmail.com>
Old: Signature Packet(tag 2)(121 bytes)
    Ver 4 - new
    Sig type - Positive certification of a User ID and Public Key packet(0x13).
    Pub alg - Reserved for ECDSA(pub 19)
    Hash alg - SHA512(hash 10)
    Hashed Sub: preferred symmetric algorithms(sub 11)(4 bytes)
        Sym alg - AES with 256-bit key(sym 9)
        Sym alg - AES with 192-bit key(sym 8)
        Sym alg - AES with 128-bit key(sym 7)
        Sym alg - CAST5(sym 3)
    Hashed Sub: preferred hash algorithms(sub 21)(5 bytes)
        Hash alg - SHA512(hash 10)
        Hash alg - SHA384(hash 9)
        Hash alg - SHA224(hash 11)
        Hash alg - SHA256(hash 8)
        Hash alg - RIPEMD160(hash 3)
    Hashed Sub: preferred compression algorithms(sub 22)(3 bytes)
        Comp alg - ZLIB <RFC1950>(comp 2)
        Comp alg - BZip2(comp 3)
        Comp alg - ZIP <RFC1951>(comp 1)
    Hashed Sub: primary User ID(sub 25)(1 bytes)
        Primary - Yes
    Hashed Sub: signature creation time(sub 2)(critical)(4 bytes)
        Time - Sun Oct 26 13:16:44 PDT 2014
    Hashed Sub: features(sub 30)(critical)(1 bytes)
        Flag - Modification detection (packets 18 and 19)
    Hashed Sub: key flags(sub 27)(critical)(1 bytes)
        Flag - This key may be used to certify other keys
        Flag - This key may be used to sign data
        Flag - This key may be used for authentication
    Sub: issuer key ID(sub 16)(8 bytes)
        Key ID - 0x04847D5C35441423
    Hash left 2 bytes - 16 10
    Unknown signature(pub 19)
Old: Public Subkey Packet(tag 14)(86 bytes)
    Ver 4 - new
    Public key creation time - Sun Oct 26 13:16:44 PDT 2014
    Pub alg - Reserved for Elliptic Curve(pub 18)
    Unknown public key(pub 18)
Old: Signature Packet(tag 2)(97 bytes)
    Ver 4 - new
    Sig type - Subkey Binding Signature(0x18).
    Pub alg - Reserved for ECDSA(pub 19)
    Hash alg - SHA512(hash 10)
    Hashed Sub: signature creation time(sub 2)(critical)(4 bytes)
        Time - Sun Oct 26 13:16:44 PDT 2014
    Hashed Sub: key flags(sub 27)(critical)(1 bytes)
        Flag - This key may be used to encrypt communications
        Flag - This key may be used to encrypt storage
    Sub: issuer key ID(sub 16)(8 bytes)
        Key ID - 0x04847D5C35441423
    Hash left 2 bytes - 1e 38
    Unknown signature(pub 19)
koto commented 9 years ago

For this key the subkey binding signature does not verify.

koto commented 9 years ago

OpenKeyChain generates RSA keys by default. I created ECDSA/ECDH keys using OpenKeyChain 3.2. Keys using P-256 curve import into e2e correctly, keys with P-521 don't. Pasting the keys here for investigation.

All keys have password: q

-----BEGIN PGP PUBLIC KEY BLOCK-----

mFIEVYGJkhMIKoZIzj0DAQcCAwSOLG0zDfX/HiNGHKrIGdkKNQrwvReOTioOe/Gz
kWoOndSfutg2Kt2jui33Ntg+O+ryn5gLYDZRGFMZbIbIuQOetBlFY2RzYSA8ZWNk
c2FAZXhhbXBsZS5jb20+iHoEExMIACIFCwkIBwoHFQgKCQsCAwQWAQIDAhkBBYJV
gYmSAp4BApsjAAoJEDn81x6XBFgQ9w4A/j5Vpn6X0ufZ+NVZnS9Etvc7g/+F+7ZO
TFNn3GjeDowkAQDI9sMtdTg/69IO26530V33hDGbm7yfsAPeDh/A3PfFOrhWBFWB
iZISCCqGSM49AwEHAgMERBGoCFTjhWoi3kwGzGSDsCQd1LVkKwP0uiveo0RhvnkH
bJgGLvvfpqPmueSz5kvcljlK8jOxace05oXEFJlhYQMBCAeIYQQYEwgACQWCVYGJ
kgKbDAAKCRA5/NcelwRYEFrCAQCrNob3ocYacl+Ihdn1IzAX+HrP+y0HpQ6oGj+k
loOWmgD/cqnS4j44g/d631O5exK3bw8QSS9mgWI4YAVAKlJ79UY=
=ZmtP
-----END PGP PUBLIC KEY BLOCK-----
-----BEGIN PGP PRIVATE KEY BLOCK-----

lKUEVYGJkhMIKoZIzj0DAQcCAwSOLG0zDfX/HiNGHKrIGdkKNQrwvReOTioOe/Gz
kWoOndSfutg2Kt2jui33Ntg+O+ryn5gLYDZRGFMZbIbIuQOe/gkD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BMTCAAiBQsJCAcKBxUICgkLAgMEFgECAwIZAQWCVYGN
cQKeAQKbIwAKCRByV89NK6d4rYfGAgkB2dKuNuhKPGNqsMTM0fKX32YPoxwTXf1E
exk2GIdFS0M4CU8SV5VJFslgzmpRLoXhgo9bcR/hOHPRbJHj2siPoiMCCKd3W9t6
Gekd4vy5dNWsVlZ6xKsOAcRosaXk15wYF5v20KSShY9+yDzNCW5MrbG4fgVbfdan
bifPBf039Sxf4AgfnQELBFWBjXESBSuBBAAjBCMEAGIXgw5yM16Sk/3yz3RYGJMw
BcLtKO6jjbuneKjaRgyVbwyHEmeMj/LuTll5QHDOdTP5Y/sN36v1WOM4CrRIHYZb
AOCpwjM/Czt5Wz5ANT9UOOhUwR2D3ulMGe6bTVe5X5JcMzYC8FznLe0sHqWvXZfj
gL7Yv3PDDD8kl8YEVVKb9EqyAwEIB/4JAwhPY+JQwboIgJDWPNzkx/L6ZQrbIPYi
wZgilHvRTpzRMsv//8gHMfV1W/8cQ2AB9svKBLhNrdA3shhyHskADk0Ir0zK1Rex
evh4rXV0KZCkC4BhO3ZiUmr9/TxubrC9AE0XYMgWlo5U8a9s9m8d854ciKQEGBMI
AAkFglWBjXECmwwACgkQclfPTSuneK0lpQIJAWL5rveEe/occEE8uzG4eQ4+ATWj
xxW410vdK2CBhGWGHs7xRTR1SwQw/+6Sz0knGr7m+rxBMjlQHoJm9WBN8HsFAgID
u9IDIGsF97QEFbe6E5qaEY/nKk7j+IUTcbOLg8/32mgpjxOuLis8L/37bsOxPWP2
Kh2maqwR1W22ud4D/GNB1g==
=Q87O
-----END PGP PRIVATE KEY BLOCK-----
koto commented 9 years ago

OK, found the underlying issue(s):

  1. Our P_521 implementation is incomplete.
  2. https://github.com/open-keychain/open-keychain/issues/1353 - when verifying signatures. we currently enforce the hash algo based on the curve, instead of reading the signature packet. Fixing this.
Valodim commented 9 years ago

so you're no longer going to enforce this? It's a SHOULD, but if we have the chance here we might want to stick to a stricter policy, to avoid downgrade attacks.

koto commented 9 years ago

If all implementations agree, I'm fine with only allow what's a SHOULD. We just should not be generating wrong keys.

Valodim commented 9 years ago

being liberal in what is accepted is the reason even things like MDC aren't fully deployed. if we have a chance to eliminate a weakest link I'm all for it.

Looking at g10/sign.c:1498, gnupg picks the default algorithm correctly based on curve size (unless instructed otherwise), so keys generated from there shouldn't be a problem.