agl / xmpp-client

An XMPP client with OTR support
BSD 3-Clause "New" or "Revised" License
365 stars 71 forks source link

Add support to importing libotr file containing multiple private keys #91

Open juniorz opened 9 years ago

juniorz commented 9 years ago

libotr supports OTR private key files (otr.private_key) containing multiple accounts/keys[1] but golang.org/x/crypto/otr simply import the first key it finds.

This is the config output after the change:

$ ./xmpp-client
 * (10:55AM) Failed to parse config file: open /Users/user/.xmpp-client: no such file or directory
 * (10:55AM) Enrolling new config file
Account (i.e. user@example.com, enter to quit): foo@bar.com
Enable debug logging to /tmp/xmpp-client-debug.log?
 * (10:55AM) Not enabling debug logging...
Use Tor?: y
 * (10:55AM) Using Tor...
File to import libotr private key from (enter to generate): /Users/user/Desktop/otr.private_key
 * (10:55AM) 2 keys found:
 * (10:55AM) (1) fingerprint: a334e9d5a334e9d5a334e9d5a334e9d5a334e9d5
 * (10:55AM) (2) fingerprint: a7032f1ea7032f1ea7032f1ea7032f1ea7032f1e
Choose one to import (enter to choose another file):
File to import libotr private key from (enter to generate): /Users/user/Desktop/another-otr.private_key
 * (10:55AM) 2 keys found:
 * (10:55AM) (1) fingerprint: 5d0a15585d0a15585d0a15585d0a15585d0a1558
 * (10:55AM) (2) fingerprint: fcf3b648fcf3b648fcf3b648fcf3b648fcf3b648
Choose one to import (enter to choose another file): 2
 * (10:55AM) Importing private key with fingerprint fcf3b648fcf3b648fcf3b648fcf3b648fcf3b648
Proxy (i.e socks5://127.0.0.1:9050, which is the default):
 * (10:56AM) Since you selected a proxy, we need to know the server and port to connect to as a SRV lookup would leak information every time.
Server (i.e. xmpp.example.com, enter to lookup using unproxied DNS): foo.com
Port (enter for 5222):
Password for foo@bar.com (will not be saved to disk):
 * (10:56AM) Making connection to foo.com:5222 via proxy

1 - See test_suite/otr.private_key in git://git.otr.im/libotr.git

agl commented 9 years ago

Rather than import github.com/juniorz/otr-keychain, that code should be merged to go.crypto. Have you signed the CLA (https://golang.org/doc/contribute.html#copyright)? If so I can take care of that.

juniorz commented 9 years ago

I totally agree. I've just signed the individual CLA.