lib-agent 1.0.4__tar.gz → 1.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lib-agent-1.0.6/LICENSE +166 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/PKG-INFO +4 -5
- {lib-agent-1.0.4 → lib-agent-1.0.6}/README.md +5 -6
- {lib-agent-1.0.4 → lib-agent-1.0.6}/lib_agent.egg-info/PKG-INFO +4 -5
- {lib-agent-1.0.4 → lib-agent-1.0.6}/lib_agent.egg-info/SOURCES.txt +1 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/age/__init__.py +11 -2
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/jade.py +1 -1
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/keepkey.py +1 -1
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/ledger.py +74 -21
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/onlykey.py +57 -6
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/agent.py +9 -9
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/client.py +2 -1
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/encode.py +2 -2
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/server.py +1 -1
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/signify/__init__.py +31 -12
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/ssh/__init__.py +3 -3
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/ssh/client.py +6 -1
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/ssh/protocol.py +32 -31
- {lib-agent-1.0.4 → lib-agent-1.0.6}/setup.py +2 -2
- {lib-agent-1.0.4 → lib-agent-1.0.6}/lib_agent.egg-info/dependency_links.txt +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/lib_agent.egg-info/requires.txt +7 -7
- {lib-agent-1.0.4 → lib-agent-1.0.6}/lib_agent.egg-info/top_level.txt +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/__init__.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/age/client.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/__init__.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/fake_device.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/interface.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/keepkey_defs.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/onlykey_defs.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/trezor.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/trezor_defs.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/device/ui.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/formats.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/__init__.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/decode.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/keyring.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/gpg/protocol.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/libagent/util.py +0 -0
- {lib-agent-1.0.4 → lib-agent-1.0.6}/setup.cfg +0 -0
lib-agent-1.0.6/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
Metadata-Version:
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: lib-agent
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: Using OnlyKey as hardware SSH and GPG agent
|
|
5
|
-
Home-page:
|
|
5
|
+
Home-page: https://github.com/onlykey/lib-agent
|
|
6
6
|
Author: CryptoTrust
|
|
7
7
|
Author-email: admin@crp.to
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: UNKNOWN
|
|
10
8
|
Platform: POSIX
|
|
11
9
|
Classifier: Environment :: Console
|
|
12
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -21,3 +19,4 @@ Classifier: Topic :: System :: Networking
|
|
|
21
19
|
Classifier: Topic :: Communications
|
|
22
20
|
Classifier: Topic :: Security
|
|
23
21
|
Classifier: Topic :: Utilities
|
|
22
|
+
License-File: LICENSE
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Hardware-based SSH/GPG agent
|
|
1
|
+
# Hardware-based SSH/GPG/age agent
|
|
2
2
|
|
|
3
3
|
[](https://github.com/romanz/trezor-agent/actions)
|
|
4
4
|
[](https://gitter.im/romanz/trezor-agent)
|
|
5
5
|
|
|
6
|
-
This project allows you to use various hardware security devices to operate GPG and
|
|
6
|
+
This project allows you to use various hardware security devices to operate GPG, SSH and age. Instead of keeping your key on your computer and decrypting it with a passphrase when you want to use it, the key is generated and stored on the device and never reaches your computer. Read more about the design [here](doc/DESIGN.md).
|
|
7
7
|
|
|
8
|
-
You can do things like sign your emails, git commits, and software packages, manage your passwords (with [pass](https://www.passwordstore.org/) and [
|
|
8
|
+
You can do things like sign your emails, git commits, and software packages, manage your passwords (with [pass](https://www.passwordstore.org/) and [passage](https://github.com/FiloSottile/passage), among others), authenticate web tunnels and file transfers, and more.
|
|
9
9
|
|
|
10
10
|
See the following blog posts about this tool:
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ This repository contains source code for one library as well as
|
|
|
22
22
|
agents to interact with several different hardware devices:
|
|
23
23
|
|
|
24
24
|
* [`libagent`](https://pypi.org/project/libagent/): shared library
|
|
25
|
-
* [`trezor-agent`](https://pypi.org/project/trezor-agent/): Using Trezor as hardware-based SSH/PGP agent
|
|
25
|
+
* [`trezor-agent`](https://pypi.org/project/trezor-agent/): Using Trezor as hardware-based SSH/PGP/age agent
|
|
26
26
|
* [`ledger_agent`](https://pypi.org/project/ledger_agent/): Using Ledger as hardware-based SSH/PGP agent
|
|
27
27
|
* [`jade_agent`](https://pypi.org/project/jade_agent/): Using Blockstream Jade as hardware-based SSH/PGP agent
|
|
28
28
|
* [`keepkey_agent`](https://pypi.org/project/keepkey_agent/): Using KeepKey as hardware-based SSH/PGP agent
|
|
@@ -37,7 +37,6 @@ releases.
|
|
|
37
37
|
* **Installation** instructions are [here](doc/INSTALL.md)
|
|
38
38
|
* **SSH** instructions and common use cases are [here](doc/README-SSH.md)
|
|
39
39
|
|
|
40
|
-
Note: If you're using Windows, see [trezor-ssh-agent](https://github.com/martin-lizner/trezor-ssh-agent) by Martin Lízner.
|
|
41
|
-
|
|
42
40
|
* **GPG** instructions and common use cases are [here](doc/README-GPG.md)
|
|
41
|
+
* **age** instructions and common use cases are [here](doc/README-age.md)
|
|
43
42
|
* Instructions to configure a Trezor-style **PIN entry** program are [here](doc/README-PINENTRY.md)
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
Metadata-Version:
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: lib-agent
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: Using OnlyKey as hardware SSH and GPG agent
|
|
5
|
-
Home-page:
|
|
5
|
+
Home-page: https://github.com/onlykey/lib-agent
|
|
6
6
|
Author: CryptoTrust
|
|
7
7
|
Author-email: admin@crp.to
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: UNKNOWN
|
|
10
8
|
Platform: POSIX
|
|
11
9
|
Classifier: Environment :: Console
|
|
12
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -21,3 +19,4 @@ Classifier: Topic :: System :: Networking
|
|
|
21
19
|
Classifier: Topic :: Communications
|
|
22
20
|
Classifier: Topic :: Security
|
|
23
21
|
Classifier: Topic :: Utilities
|
|
22
|
+
License-File: LICENSE
|
|
@@ -11,6 +11,7 @@ import argparse
|
|
|
11
11
|
import base64
|
|
12
12
|
import contextlib
|
|
13
13
|
import datetime
|
|
14
|
+
import io
|
|
14
15
|
import logging
|
|
15
16
|
import os
|
|
16
17
|
import sys
|
|
@@ -65,9 +66,16 @@ def base64_decode(encoded: str) -> bytes:
|
|
|
65
66
|
return base64.b64decode(encoded + ("=" * pad))
|
|
66
67
|
|
|
67
68
|
|
|
69
|
+
# https://github.com/FiloSottile/age/blob/v1.1.0-rc.1/internal/format/format.go#L45
|
|
70
|
+
BYTES_PER_LINE = 48
|
|
71
|
+
|
|
72
|
+
|
|
68
73
|
def base64_encode(data: bytes) -> str:
|
|
69
74
|
"""Encode data using Base64 (and remove '=')."""
|
|
70
|
-
|
|
75
|
+
reader = io.BytesIO(data)
|
|
76
|
+
chunks = map(base64.b64encode, iter(lambda: reader.read(BYTES_PER_LINE), b""))
|
|
77
|
+
chunks = (chunk.replace(b"=", b"") for chunk in chunks)
|
|
78
|
+
return b"\n".join(chunks).decode()
|
|
71
79
|
|
|
72
80
|
|
|
73
81
|
def decrypt(key, encrypted):
|
|
@@ -124,9 +132,10 @@ def run_decrypt(device_type, args):
|
|
|
124
132
|
|
|
125
133
|
def _handle_single_file(file_index, stanzas, identities, c):
|
|
126
134
|
d = c.device.__class__.__name__
|
|
127
|
-
msg = base64_encode(f'Please confirm decryption on {d} device...'.encode())
|
|
128
135
|
for peer_pubkey, encrypted in stanzas:
|
|
129
136
|
for identity in identities:
|
|
137
|
+
id_str = identity.to_string()
|
|
138
|
+
msg = base64_encode(f'Please confirm {id_str} decryption on {d} device...'.encode())
|
|
130
139
|
sys.stdout.write(f'-> msg\n{msg}\n')
|
|
131
140
|
sys.stdout.flush()
|
|
132
141
|
|
|
@@ -38,6 +38,24 @@ def _convert_public_key(ecdsa_curve_name, result):
|
|
|
38
38
|
class LedgerNanoS(interface.Device):
|
|
39
39
|
"""Connection to Ledger Nano S device."""
|
|
40
40
|
|
|
41
|
+
LEDGER_APP_NAME = "SSH/PGP Agent"
|
|
42
|
+
ledger_app_version = None
|
|
43
|
+
ledger_app_supports_end_of_frame_byte = True
|
|
44
|
+
|
|
45
|
+
def get_app_name_and_version(self, dongle):
|
|
46
|
+
"""Retrieve currently running Ledger application name and its version string."""
|
|
47
|
+
device_version_answer = dongle.exchange(binascii.unhexlify('B001000000'))
|
|
48
|
+
offset = 1
|
|
49
|
+
app_name_length = struct.unpack_from("B", device_version_answer, offset)[0]
|
|
50
|
+
offset += 1
|
|
51
|
+
app_name = device_version_answer[offset: offset + app_name_length]
|
|
52
|
+
offset += app_name_length
|
|
53
|
+
app_version_length = struct.unpack_from("B", device_version_answer, offset)[0]
|
|
54
|
+
offset += 1
|
|
55
|
+
app_version = device_version_answer[offset: offset + app_version_length]
|
|
56
|
+
log.debug("running app %s, version %s", app_name, app_version)
|
|
57
|
+
return (app_name.decode(), app_version.decode())
|
|
58
|
+
|
|
41
59
|
@classmethod
|
|
42
60
|
def package_name(cls):
|
|
43
61
|
"""Python package name (at PyPI)."""
|
|
@@ -46,10 +64,21 @@ class LedgerNanoS(interface.Device):
|
|
|
46
64
|
def connect(self):
|
|
47
65
|
"""Enumerate and connect to the first USB HID interface."""
|
|
48
66
|
try:
|
|
49
|
-
|
|
67
|
+
dongle = comm.getDongle(debug=True)
|
|
68
|
+
(app_name, self.ledger_app_version) = self.get_app_name_and_version(dongle)
|
|
69
|
+
|
|
70
|
+
version_parts = self.ledger_app_version.split(".")
|
|
71
|
+
if (version_parts[0] == "0" and version_parts[1] == "0" and int(version_parts[2]) <= 7):
|
|
72
|
+
self.ledger_app_supports_end_of_frame_byte = False
|
|
73
|
+
|
|
74
|
+
if app_name != LedgerNanoS.LEDGER_APP_NAME:
|
|
75
|
+
# we could launch the app here if we are in the dashboard
|
|
76
|
+
raise interface.DeviceError(f'{self} is not running {LedgerNanoS.LEDGER_APP_NAME}')
|
|
77
|
+
|
|
78
|
+
return dongle
|
|
50
79
|
except comm.CommException as e:
|
|
51
|
-
raise interface.
|
|
52
|
-
'{}
|
|
80
|
+
raise interface.DeviceError(
|
|
81
|
+
'Error ({}) communicating with {}'.format(e, self))
|
|
53
82
|
|
|
54
83
|
def pubkey(self, identity, ecdh=False):
|
|
55
84
|
"""Get PublicKey object for specified BIP32 address and elliptic curve."""
|
|
@@ -72,24 +101,44 @@ class LedgerNanoS(interface.Device):
|
|
|
72
101
|
|
|
73
102
|
def sign(self, identity, blob):
|
|
74
103
|
"""Sign given blob and return the signature (as bytes)."""
|
|
104
|
+
# pylint: disable=too-many-locals,too-many-branches
|
|
75
105
|
path = _expand_path(identity.get_bip32_address(ecdh=False))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
offset = 0
|
|
107
|
+
result = None
|
|
108
|
+
while offset != len(blob):
|
|
109
|
+
data = bytes()
|
|
110
|
+
if offset == 0:
|
|
111
|
+
data += bytearray([len(path) // 4]) + path
|
|
112
|
+
chunk_size = min(len(blob) - offset, 255 - len(data))
|
|
113
|
+
data += blob[offset:offset + chunk_size]
|
|
114
|
+
|
|
115
|
+
if identity.identity_dict['proto'] == 'ssh':
|
|
116
|
+
ins = '04'
|
|
117
|
+
else:
|
|
118
|
+
ins = '08'
|
|
119
|
+
|
|
120
|
+
if identity.curve_name == 'nist256p1':
|
|
121
|
+
p2 = '81' if identity.identity_dict['proto'] == 'ssh' else '01'
|
|
122
|
+
else:
|
|
123
|
+
p2 = '82' if identity.identity_dict['proto'] == 'ssh' else '02'
|
|
124
|
+
|
|
125
|
+
if offset + chunk_size == len(blob) and self.ledger_app_supports_end_of_frame_byte:
|
|
126
|
+
# mark that we are at the end of the frame
|
|
127
|
+
p1 = "80" if offset == 0 else "81"
|
|
128
|
+
else:
|
|
129
|
+
p1 = "00" if offset == 0 else "01"
|
|
130
|
+
|
|
131
|
+
apdu = binascii.unhexlify('80' + ins + p1 + p2) + len(data).to_bytes(1, 'little') + data
|
|
132
|
+
|
|
133
|
+
log.debug('apdu: %r', apdu)
|
|
134
|
+
try:
|
|
135
|
+
result = bytearray(self.conn.exchange(bytes(apdu)))
|
|
136
|
+
except comm.CommException as e:
|
|
137
|
+
raise interface.DeviceError(
|
|
138
|
+
'Error ({}) communicating with {}'.format(e, self))
|
|
139
|
+
|
|
140
|
+
offset += chunk_size
|
|
141
|
+
|
|
93
142
|
log.debug('result: %r', result)
|
|
94
143
|
if identity.curve_name == 'nist256p1':
|
|
95
144
|
offset = 3
|
|
@@ -120,7 +169,11 @@ class LedgerNanoS(interface.Device):
|
|
|
120
169
|
apdu += bytearray([len(path) // 4]) + path
|
|
121
170
|
apdu += pubkey
|
|
122
171
|
log.debug('apdu: %r', apdu)
|
|
123
|
-
|
|
172
|
+
try:
|
|
173
|
+
result = bytearray(self.conn.exchange(bytes(apdu)))
|
|
174
|
+
except comm.CommException as e:
|
|
175
|
+
raise interface.DeviceError(
|
|
176
|
+
'Error ({}) communicating with {}'.format(e, self))
|
|
124
177
|
log.debug('result: %r', result)
|
|
125
178
|
assert result[0] == 0x04
|
|
126
179
|
return bytes(result)
|
|
@@ -11,6 +11,7 @@ import time
|
|
|
11
11
|
import ecdsa
|
|
12
12
|
import nacl.signing
|
|
13
13
|
import unidecode
|
|
14
|
+
import re
|
|
14
15
|
|
|
15
16
|
from . import interface
|
|
16
17
|
|
|
@@ -71,6 +72,27 @@ class OnlyKey(interface.Device):
|
|
|
71
72
|
# self.import_pubkey_obj, _ = pgpy.PGPKey.from_blob(pubkey)
|
|
72
73
|
# self.import_pubkey_bytes = bytes(self.import_pubkey_obj)
|
|
73
74
|
|
|
75
|
+
def get_key_by_keygrip(self, keygrip):
|
|
76
|
+
if keygrip is None:
|
|
77
|
+
return None
|
|
78
|
+
keygriplong = keygrip
|
|
79
|
+
keygrip = keygrip[:16]
|
|
80
|
+
log.info(keygrip)
|
|
81
|
+
keygrips = {}
|
|
82
|
+
keylabels = self.ok.getkeylabels()
|
|
83
|
+
for i in keylabels:
|
|
84
|
+
if i.number + 72 >= 100:
|
|
85
|
+
keygrips[i.label.replace("ÿ", " ").encode('ascii')] = i.number + 72
|
|
86
|
+
else:
|
|
87
|
+
keygrips[i.label.replace("ÿ", " ").encode('ascii')] = i.number - 24
|
|
88
|
+
if keygrip in keygrips:
|
|
89
|
+
return keygrips[keygrip]
|
|
90
|
+
for i in keylabels:
|
|
91
|
+
if re.search(r'[A-F0-9]{16}', i.label):
|
|
92
|
+
raise KeyError('keygrip %s not found' % keygriplong)
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
74
96
|
def get_sk_dk(self):
|
|
75
97
|
"""Get signing key and decryption key slots from config."""
|
|
76
98
|
fpath = os.path.join(os.environ.get('AGENTHOMEDIR', os.environ.get('GNUPGHOME')), 'run-agent.sh')
|
|
@@ -120,9 +142,17 @@ class OnlyKey(interface.Device):
|
|
|
120
142
|
def pubkey(self, identity, ecdh=False):
|
|
121
143
|
"""Return public key."""
|
|
122
144
|
curve_name = identity.get_curve_name(ecdh=ecdh)
|
|
123
|
-
|
|
145
|
+
keygrip_slot_id = None
|
|
146
|
+
if identity.identity_dict['proto'] != 'ssh' and hasattr(self, 'skeyslot') is False:
|
|
124
147
|
self.get_sk_dk()
|
|
125
|
-
if identity.identity_dict['proto'] != 'ssh'
|
|
148
|
+
if identity.identity_dict['proto'] != 'ssh':
|
|
149
|
+
log.info('Looking for keygrip =%s', identity.identity_dict['keygrip'])
|
|
150
|
+
keygrip = identity.identity_dict['keygrip']
|
|
151
|
+
keygrip_slot_id = self.get_key_by_keygrip(keygrip)
|
|
152
|
+
|
|
153
|
+
if keygrip_slot_id is not None:
|
|
154
|
+
this_slot_id = keygrip_slot_id
|
|
155
|
+
elif identity.identity_dict['proto'] != 'ssh' and self.dkeyslot < 132 and ecdh is True:
|
|
126
156
|
this_slot_id = self.dkeyslot
|
|
127
157
|
log.info('Key Slot =%s', this_slot_id)
|
|
128
158
|
elif self.skeyslot < 132 and ecdh is False:
|
|
@@ -247,8 +277,13 @@ class OnlyKey(interface.Device):
|
|
|
247
277
|
curve_name = identity.get_curve_name(ecdh=False)
|
|
248
278
|
log.debug('"%s" signing %r (%s) on %s',
|
|
249
279
|
identity.to_string(), blob, curve_name, self)
|
|
250
|
-
|
|
280
|
+
keygrip_slot_id = None
|
|
281
|
+
if identity.identity_dict['proto'] != 'ssh' and hasattr(self, 'skeyslot') is False:
|
|
251
282
|
self.get_sk_dk()
|
|
283
|
+
if identity.identity_dict['proto'] != 'ssh':
|
|
284
|
+
log.info('Looking for keygrip =%s', identity.identity_dict['keygrip'])
|
|
285
|
+
keygrip = identity.identity_dict['keygrip']
|
|
286
|
+
keygrip_slot_id = self.get_key_by_keygrip(keygrip)
|
|
252
287
|
# Calculate hash for SSH signing
|
|
253
288
|
if 'rsa' in curve_name:
|
|
254
289
|
if self.sighash == b'rsa-sha2-512':
|
|
@@ -282,7 +317,14 @@ class OnlyKey(interface.Device):
|
|
|
282
317
|
# Determine type of key to derive on OnlyKey for signature
|
|
283
318
|
# Slot 132 used for derived key, slots 101-116 used for stored ecc keys
|
|
284
319
|
# slots 1-4 used for stored RSA keys
|
|
285
|
-
if
|
|
320
|
+
if keygrip_slot_id is not None:
|
|
321
|
+
this_slot_id = keygrip_slot_id
|
|
322
|
+
log.info('Key Slot =%s', this_slot_id)
|
|
323
|
+
if curve_name != 'rsa':
|
|
324
|
+
raw_message = blob
|
|
325
|
+
else:
|
|
326
|
+
raw_message = data
|
|
327
|
+
elif self.skeyslot == 132:
|
|
286
328
|
if curve_name == 'ed25519':
|
|
287
329
|
this_slot_id = 201
|
|
288
330
|
log.info('Key type ed25519')
|
|
@@ -355,7 +397,7 @@ class OnlyKey(interface.Device):
|
|
|
355
397
|
|
|
356
398
|
log.info('received= %s', repr(result))
|
|
357
399
|
return bytes(result)
|
|
358
|
-
raise
|
|
400
|
+
raise interface.Error('failed to sign challenge')
|
|
359
401
|
|
|
360
402
|
def ecdh_with_pubkey(self, identity, pubkey):
|
|
361
403
|
"""Get shared session key using Elliptic Curve Diffie-Hellman & self public key."""
|
|
@@ -389,6 +431,12 @@ class OnlyKey(interface.Device):
|
|
|
389
431
|
# Determine type of key to derive on OnlyKey for ecdh
|
|
390
432
|
# Slot 132 used for derived key, slots 101-116 used for stored ecc keys,
|
|
391
433
|
# slots 1-4 used for stored RSA keys
|
|
434
|
+
keygrip_slot_id = None
|
|
435
|
+
if identity.identity_dict['proto'] != 'ssh':
|
|
436
|
+
log.info('Looking for keygrip =%s', identity.identity_dict['keygrip'])
|
|
437
|
+
keygrip = identity.identity_dict['keygrip']
|
|
438
|
+
keygrip_slot_id = self.get_key_by_keygrip(keygrip)
|
|
439
|
+
|
|
392
440
|
if self.dkeyslot == 132:
|
|
393
441
|
if curve_name == 'curve25519':
|
|
394
442
|
this_slot_id = 204
|
|
@@ -401,7 +449,10 @@ class OnlyKey(interface.Device):
|
|
|
401
449
|
log.info('Key type secp256k1')
|
|
402
450
|
raw_message = pubkey + data
|
|
403
451
|
else:
|
|
404
|
-
|
|
452
|
+
if keygrip_slot_id is not None:
|
|
453
|
+
this_slot_id = keygrip_slot_id
|
|
454
|
+
else:
|
|
455
|
+
this_slot_id = self.dkeyslot
|
|
405
456
|
raw_message = pubkey
|
|
406
457
|
log.info('Key Slot =%s', this_slot_id)
|
|
407
458
|
log.info('data hash =%s', data)
|
|
@@ -193,7 +193,7 @@ class Handler:
|
|
|
193
193
|
if pubkey_dict['algo'] not in {1, 2, 3}:
|
|
194
194
|
curve_name = protocol.get_curve_name_by_oid(pubkey_dict['curve_oid'])
|
|
195
195
|
ecdh = (pubkey_dict['algo'] == protocol.ECDH_ALGO_ID)
|
|
196
|
-
identity = client.create_identity(user_id=user_id, curve_name=curve_name)
|
|
196
|
+
identity = client.create_identity(user_id=user_id, curve_name=curve_name, keygrip=keygrip)
|
|
197
197
|
verifying_key = self.client.pubkey(identity=identity, ecdh=ecdh)
|
|
198
198
|
pubkey = protocol.PublicKey(
|
|
199
199
|
curve_name=curve_name, created=pubkey_dict['created'],
|
|
@@ -201,22 +201,22 @@ class Handler:
|
|
|
201
201
|
assert pubkey.key_id() == pubkey_dict['key_id']
|
|
202
202
|
assert pubkey.keygrip() == keygrip_bytes
|
|
203
203
|
elif len(pubkey_dict['_to_hash']) < 350:
|
|
204
|
-
identity = client.create_identity(user_id=user_id, curve_name='rsa2048')
|
|
204
|
+
identity = client.create_identity(user_id=user_id, curve_name='rsa2048', keygrip=keygrip)
|
|
205
205
|
verifying_key = self.client.pubkey(identity=identity, ecdh=False)
|
|
206
206
|
pubkey = protocol.PublicKey(
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
curve_name='rsa2048', created=pubkey_dict['created'],
|
|
208
|
+
verifying_key=verifying_key, ecdh=False)
|
|
209
209
|
elif len(pubkey_dict['_to_hash']) < 700:
|
|
210
|
-
identity = client.create_identity(user_id=user_id, curve_name='rsa4096')
|
|
210
|
+
identity = client.create_identity(user_id=user_id, curve_name='rsa4096', keygrip=keygrip)
|
|
211
211
|
verifying_key = self.client.pubkey(identity=identity, ecdh=False)
|
|
212
212
|
pubkey = protocol.PublicKey(
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
curve_name='rsa4096', created=pubkey_dict['created'],
|
|
214
|
+
verifying_key=verifying_key, ecdh=False)
|
|
215
215
|
else:
|
|
216
216
|
identity = 'unknown identity type'
|
|
217
217
|
log.error(identity)
|
|
218
|
-
|
|
219
|
-
log.info('IDENTITY(%s)', identity)
|
|
218
|
+
|
|
219
|
+
log.info('IDENTITY(%s)', identity)
|
|
220
220
|
return identity
|
|
221
221
|
|
|
222
222
|
def pksign(self, conn):
|
|
@@ -8,10 +8,11 @@ from ..device import interface
|
|
|
8
8
|
log = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def create_identity(user_id, curve_name):
|
|
11
|
+
def create_identity(user_id, curve_name, keygrip = None):
|
|
12
12
|
"""Create GPG identity for hardware device."""
|
|
13
13
|
result = interface.Identity(identity_str='gpg://', curve_name=curve_name)
|
|
14
14
|
result.identity_dict['host'] = user_id
|
|
15
|
+
result.identity_dict['keygrip'] = keygrip
|
|
15
16
|
return result
|
|
16
17
|
|
|
17
18
|
|
|
@@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
|
|
|
11
11
|
def create_primary(user_id, pubkey, signer_func, secret_bytes=b''):
|
|
12
12
|
"""Export new primary GPG public key, ready for "gpg2 --import"."""
|
|
13
13
|
pubkey_packet = protocol.packet(tag=(5 if secret_bytes else 6),
|
|
14
|
-
blob=
|
|
14
|
+
blob=pubkey.data() + secret_bytes)
|
|
15
15
|
user_id_bytes = user_id.encode('utf-8')
|
|
16
16
|
user_id_packet = protocol.packet(tag=13, blob=user_id_bytes)
|
|
17
17
|
data_to_sign = (pubkey.data_to_hash() + user_id_packet[:1] +
|
|
@@ -51,7 +51,7 @@ def create_primary(user_id, pubkey, signer_func, secret_bytes=b''):
|
|
|
51
51
|
def create_subkey(primary_bytes, subkey, signer_func, secret_bytes=b''):
|
|
52
52
|
"""Export new subkey to GPG primary key."""
|
|
53
53
|
subkey_packet = protocol.packet(tag=(7 if secret_bytes else 14),
|
|
54
|
-
blob=
|
|
54
|
+
blob=subkey.data() + secret_bytes)
|
|
55
55
|
packets = list(decode.parse_packets(io.BytesIO(primary_bytes)))
|
|
56
56
|
primary, user_id, signature = packets[:3]
|
|
57
57
|
|
|
@@ -134,7 +134,7 @@ def server_thread(sock, handle_conn, quit_event):
|
|
|
134
134
|
break
|
|
135
135
|
# Handle connections from SSH concurrently.
|
|
136
136
|
threading.Thread(target=handle_conn,
|
|
137
|
-
kwargs=
|
|
137
|
+
kwargs={'conn': conn}).start()
|
|
138
138
|
log.debug('server thread stopped')
|
|
139
139
|
|
|
140
140
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""TREZOR support for Ed25519 signify signatures."""
|
|
1
|
+
"""TREZOR support for Ed25519 signify/minisign signatures."""
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
4
|
import binascii
|
|
@@ -53,10 +53,14 @@ class Client:
|
|
|
53
53
|
return sig, pubkey[1:]
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
ALG_SIGNIFY = b'Ed'
|
|
57
|
+
ALG_MINISIGN = b'ED' # prehashes the data before signing
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def format_payload(pubkey, data, sig_alg):
|
|
57
61
|
"""See http://www.openbsd.org/papers/bsdcan-signify.html for details."""
|
|
58
62
|
keynum = hashlib.sha256(pubkey).digest()[:8]
|
|
59
|
-
return binascii.b2a_base64(
|
|
63
|
+
return binascii.b2a_base64(sig_alg + keynum + data).decode("ascii")
|
|
60
64
|
|
|
61
65
|
|
|
62
66
|
def run_pubkey(device_type, args):
|
|
@@ -69,20 +73,33 @@ def run_pubkey(device_type, args):
|
|
|
69
73
|
identity = _create_identity(user_id=args.user_id)
|
|
70
74
|
pubkey = Client(device=device_type()).pubkey(identity=identity)
|
|
71
75
|
comment = f'untrusted comment: identity {identity.to_string()}\n'
|
|
72
|
-
|
|
73
|
-
print(
|
|
76
|
+
payload = format_payload(pubkey=pubkey, data=pubkey, sig_alg=ALG_SIGNIFY)
|
|
77
|
+
print(comment + payload, end="")
|
|
74
78
|
|
|
75
79
|
|
|
76
80
|
def run_sign(device_type, args):
|
|
77
|
-
"""
|
|
81
|
+
"""Prehash & sign an input blob using Ed25519."""
|
|
78
82
|
util.setup_logging(verbosity=args.verbose)
|
|
79
83
|
identity = _create_identity(user_id=args.user_id)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
|
|
85
|
+
data_to_sign = sys.stdin.buffer.read()
|
|
86
|
+
sig_alg = ALG_SIGNIFY
|
|
87
|
+
if args.prehash:
|
|
88
|
+
# See https://github.com/jedisct1/minisign/commit/6e1023d20758b6fdb2a4b697213b0bf608ba4020
|
|
89
|
+
# Released in https://github.com/jedisct1/minisign/releases/tag/0.6
|
|
90
|
+
sig_alg = ALG_MINISIGN
|
|
91
|
+
data_to_sign = hashlib.blake2b(data_to_sign).digest()
|
|
92
|
+
|
|
93
|
+
sig, pubkey = Client(device=device_type()).sign_with_pubkey(identity, data_to_sign)
|
|
94
|
+
pubkey_str = format_payload(pubkey=pubkey, data=pubkey, sig_alg=sig_alg)
|
|
95
|
+
sig_str = format_payload(pubkey=pubkey, data=sig, sig_alg=sig_alg)
|
|
96
|
+
untrusted_comment = f'untrusted comment: pubkey {pubkey_str}'
|
|
97
|
+
print(untrusted_comment + sig_str, end="")
|
|
98
|
+
|
|
99
|
+
comment_to_sign = sig + args.comment.encode()
|
|
100
|
+
sig, _ = Client(device=device_type()).sign_with_pubkey(identity, comment_to_sign)
|
|
101
|
+
sig_str = binascii.b2a_base64(sig).decode("ascii")
|
|
102
|
+
print(f'trusted comment: {args.comment}\n' + sig_str, end="")
|
|
86
103
|
|
|
87
104
|
|
|
88
105
|
def main(device_type):
|
|
@@ -100,6 +117,8 @@ def main(device_type):
|
|
|
100
117
|
p = subparsers.add_parser('sign')
|
|
101
118
|
p.add_argument('user_id')
|
|
102
119
|
p.add_argument('-v', '--verbose', default=0, action='count')
|
|
120
|
+
p.add_argument('-c', '--comment', default=time.asctime())
|
|
121
|
+
p.add_argument('-H', '--prehash', default=False, action='store_true')
|
|
103
122
|
p.set_defaults(func=run_sign)
|
|
104
123
|
|
|
105
124
|
args = parser.parse_args()
|
|
@@ -150,9 +150,9 @@ def serve(handler, sock_path, timeout=UNIX_SOCKET_TIMEOUT):
|
|
|
150
150
|
handle_conn = functools.partial(server.handle_connection,
|
|
151
151
|
handler=handler,
|
|
152
152
|
mutex=device_mutex)
|
|
153
|
-
kwargs =
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
kwargs = {'sock': sock,
|
|
154
|
+
'handle_conn': handle_conn,
|
|
155
|
+
'quit_event': quit_event}
|
|
156
156
|
with server.spawn(server.server_thread, kwargs):
|
|
157
157
|
try:
|
|
158
158
|
yield environ
|
|
@@ -33,6 +33,7 @@ class Client:
|
|
|
33
33
|
"""Sign given blob using a private key on the device."""
|
|
34
34
|
log.debug('blob: %r', blob)
|
|
35
35
|
msg = parse_ssh_blob(blob)
|
|
36
|
+
log.debug('parsed blob: %r', msg)
|
|
36
37
|
if msg['sshsig']:
|
|
37
38
|
log.info('please confirm "%s" signature for "%s" using %s...',
|
|
38
39
|
msg['namespace'], identity.to_string(), self.device)
|
|
@@ -68,6 +69,8 @@ def parse_ssh_blob(data):
|
|
|
68
69
|
res['reserved'] = util.read_frame(i)
|
|
69
70
|
res['hashalg'] = util.read_frame(i)
|
|
70
71
|
res['message'] = util.read_frame(i)
|
|
72
|
+
res['user'] = b'SSHSIG' # logging statements in client.py expect this to be there and raise without it
|
|
73
|
+
res['key_type'] = res['hashalg'] # logging statements in client.py expect this to be there and raise without it
|
|
71
74
|
else:
|
|
72
75
|
i = io.BytesIO(data)
|
|
73
76
|
res['sshsig'] = False
|
|
@@ -81,5 +84,7 @@ def parse_ssh_blob(data):
|
|
|
81
84
|
public_key = util.read_frame(i)
|
|
82
85
|
res['public_key'] = formats.parse_pubkey(public_key)
|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
unparsed = i.read()
|
|
88
|
+
if unparsed:
|
|
89
|
+
log.warning('unparsed blob: %r', unparsed)
|
|
85
90
|
return res
|
|
@@ -16,33 +16,33 @@ log = logging.getLogger(__name__)
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
# Taken from https://github.com/openssh/openssh-portable/blob/master/authfd.h
|
|
19
|
-
COMMANDS =
|
|
20
|
-
SSH_AGENTC_REQUEST_RSA_IDENTITIES
|
|
21
|
-
SSH_AGENT_RSA_IDENTITIES_ANSWER
|
|
22
|
-
SSH_AGENTC_RSA_CHALLENGE
|
|
23
|
-
SSH_AGENT_RSA_RESPONSE
|
|
24
|
-
SSH_AGENT_FAILURE
|
|
25
|
-
SSH_AGENT_SUCCESS
|
|
26
|
-
SSH_AGENTC_ADD_RSA_IDENTITY
|
|
27
|
-
SSH_AGENTC_REMOVE_RSA_IDENTITY
|
|
28
|
-
SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES
|
|
29
|
-
SSH2_AGENTC_REQUEST_IDENTITIES
|
|
30
|
-
SSH2_AGENT_IDENTITIES_ANSWER
|
|
31
|
-
SSH2_AGENTC_SIGN_REQUEST
|
|
32
|
-
SSH2_AGENT_SIGN_RESPONSE
|
|
33
|
-
SSH2_AGENTC_ADD_IDENTITY
|
|
34
|
-
SSH2_AGENTC_REMOVE_IDENTITY
|
|
35
|
-
SSH2_AGENTC_REMOVE_ALL_IDENTITIES
|
|
36
|
-
SSH_AGENTC_ADD_SMARTCARD_KEY
|
|
37
|
-
SSH_AGENTC_REMOVE_SMARTCARD_KEY
|
|
38
|
-
SSH_AGENTC_LOCK
|
|
39
|
-
SSH_AGENTC_UNLOCK
|
|
40
|
-
SSH_AGENTC_ADD_RSA_ID_CONSTRAINED
|
|
41
|
-
SSH2_AGENTC_ADD_ID_CONSTRAINED
|
|
42
|
-
SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED
|
|
43
|
-
SSH_AGENTC_EXTENSION
|
|
44
|
-
SSH_AGENT_EXTENSION_FAILURE
|
|
45
|
-
|
|
19
|
+
COMMANDS = {
|
|
20
|
+
"SSH_AGENTC_REQUEST_RSA_IDENTITIES": 1,
|
|
21
|
+
"SSH_AGENT_RSA_IDENTITIES_ANSWER": 2,
|
|
22
|
+
"SSH_AGENTC_RSA_CHALLENGE": 3,
|
|
23
|
+
"SSH_AGENT_RSA_RESPONSE": 4,
|
|
24
|
+
"SSH_AGENT_FAILURE": 5,
|
|
25
|
+
"SSH_AGENT_SUCCESS": 6,
|
|
26
|
+
"SSH_AGENTC_ADD_RSA_IDENTITY": 7,
|
|
27
|
+
"SSH_AGENTC_REMOVE_RSA_IDENTITY": 8,
|
|
28
|
+
"SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES": 9,
|
|
29
|
+
"SSH2_AGENTC_REQUEST_IDENTITIES": 11,
|
|
30
|
+
"SSH2_AGENT_IDENTITIES_ANSWER": 12,
|
|
31
|
+
"SSH2_AGENTC_SIGN_REQUEST": 13,
|
|
32
|
+
"SSH2_AGENT_SIGN_RESPONSE": 14,
|
|
33
|
+
"SSH2_AGENTC_ADD_IDENTITY": 17,
|
|
34
|
+
"SSH2_AGENTC_REMOVE_IDENTITY": 18,
|
|
35
|
+
"SSH2_AGENTC_REMOVE_ALL_IDENTITIES": 19,
|
|
36
|
+
"SSH_AGENTC_ADD_SMARTCARD_KEY": 20,
|
|
37
|
+
"SSH_AGENTC_REMOVE_SMARTCARD_KEY": 21,
|
|
38
|
+
"SSH_AGENTC_LOCK": 22,
|
|
39
|
+
"SSH_AGENTC_UNLOCK": 23,
|
|
40
|
+
"SSH_AGENTC_ADD_RSA_ID_CONSTRAINED": 24,
|
|
41
|
+
"SSH2_AGENTC_ADD_ID_CONSTRAINED": 25,
|
|
42
|
+
"SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED": 26,
|
|
43
|
+
"SSH_AGENTC_EXTENSION": 27,
|
|
44
|
+
"SSH_AGENT_EXTENSION_FAILURE": 28,
|
|
45
|
+
}
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def msg_code(name):
|
|
@@ -88,7 +88,7 @@ class Handler:
|
|
|
88
88
|
msg_code('SSH_AGENTC_REQUEST_RSA_IDENTITIES'): _legacy_pubs,
|
|
89
89
|
msg_code('SSH2_AGENTC_REQUEST_IDENTITIES'): self.list_pubs,
|
|
90
90
|
msg_code('SSH2_AGENTC_SIGN_REQUEST'): self.sign_message,
|
|
91
|
-
msg_code('SSH_AGENTC_EXTENSION'):
|
|
91
|
+
msg_code('SSH_AGENTC_EXTENSION'): _unsupported_extension,
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
def handle(self, msg):
|
|
@@ -173,6 +173,7 @@ class Handler:
|
|
|
173
173
|
code = util.pack('B', msg_code('SSH2_AGENT_SIGN_RESPONSE'))
|
|
174
174
|
return util.frame(code, data)
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
|
|
177
|
+
def _unsupported_extension(buf): # pylint: disable=unused-argument
|
|
178
|
+
code = util.pack('B', msg_code('SSH_AGENT_EXTENSION_FAILURE'))
|
|
179
|
+
return util.frame(code)
|
|
@@ -3,11 +3,11 @@ from setuptools import setup
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name='lib-agent',
|
|
6
|
-
version='1.0.
|
|
6
|
+
version='1.0.6',
|
|
7
7
|
description='Using OnlyKey as hardware SSH and GPG agent',
|
|
8
8
|
author='CryptoTrust',
|
|
9
9
|
author_email='admin@crp.to',
|
|
10
|
-
url='
|
|
10
|
+
url='https://github.com/onlykey/lib-agent',
|
|
11
11
|
packages=[
|
|
12
12
|
'libagent',
|
|
13
13
|
'libagent.age',
|
|
File without changes
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
ConfigArgParse>=0.12.1
|
|
2
|
+
backports.shutil_which>=3.5.1
|
|
1
3
|
bech32>=1.2.0
|
|
2
4
|
cryptography>=3.4.6
|
|
3
|
-
pycryptodome>=3.9.8
|
|
4
5
|
docutils>=0.16
|
|
5
|
-
python-daemon>=2.3.0
|
|
6
|
-
wheel>=0.32.3
|
|
7
|
-
backports.shutil_which>=3.5.1
|
|
8
|
-
ConfigArgParse>=0.12.1
|
|
9
|
-
python-daemon>=2.1.2
|
|
10
6
|
ecdsa>=0.13
|
|
11
|
-
pynacl>=1.4.0
|
|
12
7
|
mnemonic>=0.18
|
|
8
|
+
pycryptodome>=3.9.8
|
|
13
9
|
pymsgbox>=1.0.6
|
|
10
|
+
pynacl>=1.4.0
|
|
11
|
+
python-daemon>=2.1.2
|
|
12
|
+
python-daemon>=2.3.0
|
|
14
13
|
semver>=2.2
|
|
15
14
|
unidecode>=0.4.20
|
|
15
|
+
wheel>=0.32.3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|