Merge pull request #31 from romanz/master

Update ledger branch with the latest changes from master branch
nistp521
Roman Zeyde 8 years ago committed by GitHub
commit 57e09248db

@ -15,7 +15,7 @@ Update you TREZOR firmware to the latest version (at least [c720614](https://git
Install latest `trezor-agent` package from [gpg-agent](https://github.com/romanz/trezor-agent/commits/gpg-agent) branch:
```
$ pip install --user git+https://github.com/romanz/trezor-agent.git@gpg-agent
$ pip install --user git+https://github.com/romanz/trezor-agent.git
```
Define your GPG user ID as an environment variable:

@ -5,7 +5,6 @@
[![Package Version](https://img.shields.io/pypi/v/trezor_agent.svg)](https://pypi.python.org/pypi/trezor_agent/)
[![Development Status](https://img.shields.io/pypi/status/trezor_agent.svg)](https://pypi.python.org/pypi/trezor_agent/)
[![Downloads](https://img.shields.io/pypi/dm/trezor_agent.svg)](https://pypi.python.org/pypi/trezor_agent/)
[![Chat](https://badges.gitter.im/romanz/trezor-agent.svg)](https://gitter.im/romanz/trezor-agent)
See SatoshiLabs' blog posts about this feature:
@ -15,3 +14,5 @@ See SatoshiLabs' blog posts about this feature:
For usage with SSH, see the [following instructions](README-SSH.md).
For usage with GPG, see the [following instructions](README-GPG.md).
Questions, suggestions and discussions are welcome: [![Chat](https://badges.gitter.im/romanz/trezor-agent.svg)](https://gitter.im/romanz/trezor-agent)

@ -56,7 +56,7 @@ def _load_trezor():
hid_transport=HidTransport,
passphrase_ack=PassphraseAck,
identity_type=IdentityType,
required_version='>=1.3.4',
required_version='>=1.4.0',
call_exception=CallException)
except ImportError:
log.exception('Missing module: install via "pip install trezor"')

@ -16,6 +16,9 @@ log = logging.getLogger(__name__)
def run_create(args):
"""Generate a new pubkey for a new/existing GPG identity."""
user_id = os.environ['TREZOR_GPG_USER_ID']
log.warning('NOTE: in order to re-generate the exact same GPG key later, '
'run this command with "--time=%d" commandline flag (to set '
'the timestamp of the GPG key manually).', args.time)
conn = encode.HardwareSigner(user_id=user_id,
curve_name=args.ecdsa_curve)
verifying_key = conn.pubkey(ecdh=False)
@ -57,9 +60,9 @@ def run_create(args):
sys.stdout.write(protocol.armor(result, 'PUBLIC KEY BLOCK'))
def run_agent(args):
def run_agent(args): # pylint: disable=unused-argument
"""Run a simple GPG-agent server."""
sock_path = os.path.expanduser(args.sock_path)
sock_path = keyring.get_agent_sock_path()
with server.unix_domain_socket_server(sock_path) as sock:
for conn in agent.yield_connections(sock):
with contextlib.closing(conn):
@ -81,7 +84,6 @@ def main():
create_cmd.set_defaults(run=run_create)
agent_cmd = subparsers.add_parser('agent')
agent_cmd.add_argument('-s', '--sock-path', default='~/.gnupg/S.gpg-agent')
agent_cmd.set_defaults(run=run_agent)
args = p.parse_args()

@ -25,10 +25,17 @@ def parse_subpackets(s):
while True:
try:
subpacket_len = s.readfmt('B')
first = s.readfmt('B')
except EOFError:
break
if first < 192:
subpacket_len = first
elif first < 255:
subpacket_len = ((first - 192) << 8) + s.readfmt('B') + 192
else: # first == 255
subpacket_len = s.readfmt('>L')
subpackets.append(s.read(subpacket_len))
return subpackets

@ -13,9 +13,16 @@ from .. import util
log = logging.getLogger(__name__)
def connect_to_agent(sock_path='~/.gnupg/S.gpg-agent', sp=subprocess):
def get_agent_sock_path(sp=subprocess):
"""Parse gpgconf output to find out GPG agent UNIX socket path."""
lines = sp.check_output(['gpgconf', '--list-dirs']).strip().split('\n')
dirs = dict(line.split(':', 1) for line in lines)
return dirs['agent-socket']
def connect_to_agent(sp=subprocess):
"""Connect to GPG agent's UNIX socket."""
sock_path = os.path.expanduser(sock_path)
sock_path = get_agent_sock_path(sp=sp)
sp.check_call(['gpg-connect-agent', '/bye'])
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(sock_path)

Loading…
Cancel
Save