pax_global_header00006660000000000000000000000064147156163660014531gustar00rootroot0000000000000052 comment=145d2392be1247b7bab03444f8588d9e9e3f7994 tkey-ssh-agent-1.0.0+ds/000077500000000000000000000000001471561636600147745ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/.editorconfig000066400000000000000000000000411471561636600174440ustar00rootroot00000000000000[*.{go,md}] max_line_length = 70 tkey-ssh-agent-1.0.0+ds/.github/000077500000000000000000000000001471561636600163345ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/.github/workflows/000077500000000000000000000000001471561636600203715ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/.github/workflows/ci.yaml000066400000000000000000000013111471561636600216440ustar00rootroot00000000000000 name: ci on: push: branches: - 'main' pull_request: {} # allow manual runs: workflow_dispatch: {} jobs: build: runs-on: ubuntu-latest container: image: ghcr.io/tillitis/tkey-builder:4 steps: - name: checkout uses: actions/checkout@v4 with: # fetch-depth: 0 persist-credentials: false - name: fix # https://github.com/actions/runner-images/issues/6775 run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: check for SPDX tags run: ./tools/spdx-ensure - name: make run: make tkey-ssh-agent -j - name: make windows run: make windows tkey-ssh-agent-1.0.0+ds/.github/workflows/golangci-lint.yml000066400000000000000000000037011471561636600236440ustar00rootroot00000000000000name: golangci-lint on: push: branches: - main pull_request: permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. # pull-requests: read jobs: golangci: name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: go-version: '1.21' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Require: The version of golangci-lint to use. # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. version: v1.55.2 # Optional: working directory, useful for monorepos # working-directory: somedir # Optional: golangci-lint command line arguments. # # Note: By default, the `.golangci.yml` file should be at the root of the repository. # The location of the configuration file can be changed by using `--config=` # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true # Optional: if set to true, then all caching functionality will be completely disabled, # takes precedence over all other caching options. # skip-cache: true # Optional: if set to true, then the action won't cache or restore ~/go/pkg. # skip-pkg-cache: true # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. # skip-build-cache: true # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. # install-mode: "goinstall" tkey-ssh-agent-1.0.0+ds/.gitignore000066400000000000000000000004411471561636600167630ustar00rootroot00000000000000*.a *.o *.bin *.elf /tkey-ssh-agent /tkey-ssh-agent.exe /cmd/tkey-ssh-agent/rsrc_windows_amd64.syso /tkey-ssh-agent-tray.exe /cmd/tkey-ssh-agent-tray/rsrc_windows_amd64.syso /tkey-runapp /tkey-sign /runsign.sh /runtimer /runrandom /gotools/golangci-lint /gotools/go-winres test/venv /dist tkey-ssh-agent-1.0.0+ds/.golangci.yml000066400000000000000000000010521471561636600173560ustar00rootroot00000000000000linters: presets: # found in: golangci-lint help linters - bugs - comment - complexity - error - format - import - metalinter - module - performance - sql # - style # turned off, can be too much - test - unused disable: - cyclop - funlen - gocognit - nestif - exhaustruct # TODO? annoying for now - goerr113 # TODO enable later - godot - depguard issues: max-issues-per-linter: 0 max-same-issues: 0 linters-settings: govet: enable: - shadow tkey-ssh-agent-1.0.0+ds/.goreleaser.yaml000066400000000000000000000121421471561636600200660ustar00rootroot00000000000000# Make sure to check the documentation at https://goreleaser.com release: draft: true replace_existing_draft: true before: hooks: # You may remove this if you don't use go modules. - go mod tidy # you may remove this if you don't need go generate - go generate ./... builds: - id: linux main: ./cmd/tkey-ssh-agent binary: tkey-ssh-agent env: - GOPROXY=https://proxy.golang.org,direct - GOSUMDB=sum.golang.org - CGO_ENABLED=0 goos: - linux goarch: - amd64 - arm64 flags: - -trimpath - -buildvcs=false # Custom ldflags mostly to avoid setting main.date which for some # reason is default ldflags: -w -X main.version={{ .Version }} -X main.signerAppNoTouch= -buildid= - id: darwin main: ./cmd/tkey-ssh-agent binary: tkey-ssh-agent env: - GOPROXY=https://proxy.golang.org,direct - GOSUMDB=sum.golang.org - CGO_ENABLED=1 goos: - darwin goarch: - amd64 - arm64 flags: - -trimpath - -buildvcs=false # Custom ldflags mostly to avoid setting main.date which for some # reason is default ldflags: -w -X main.version={{ .Version }} -X main.signerAppNoTouch= -buildid= - id: windows main: ./cmd/tkey-ssh-agent binary: tkey-ssh-agent env: - GOPROXY=https://proxy.golang.org,direct - GOSUMDB=sum.golang.org - CGO_ENABLED=0 goos: - windows goarch: - amd64 - arm64 flags: - -trimpath - -buildvcs=false # Custom ldflags mostly to avoid setting main.date which for some # reason is default ldflags: -w -X main.version={{ .Version }} -X main.signerAppNoTouch= -buildid= hooks: pre: sh -c "cd ./cmd/tkey-ssh-agent && go-winres make --arch amd64" - id: windows-tray main: ./cmd/tkey-ssh-agent-tray binary: tkey-ssh-agent-tray env: - GOPROXY=https://proxy.golang.org,direct - GOSUMDB=sum.golang.org - CGO_ENABLED=0 goos: - windows goarch: - amd64 - arm64 flags: - -trimpath - -buildvcs=false # Custom ldflags mostly to avoid setting main.date which for some # reason is default ldflags: -w -H windowsgui -buildid= hooks: pre: sh -c "cd ./cmd/tkey-ssh-agent-tray && go-winres make --arch amd64" universal_binaries: - ids: - darwin replace: true name_template: "tkey-ssh-agent" hooks: post: gon gon.hcl archives: - format: tar.gz allow_different_binary_count: true # this name template makes the OS and Arch compatible with the results of uname. name_template: >- {{ "tkey-ssh-agent" }}_ {{- .Version }}_ {{- title .Os }}_ {{- if eq .Arch "all" }}universal {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} # use zip for windows archives format_overrides: - goos: windows format: zip files: - src: system/tkey-ssh-agent.1 dst: man strip_parent: true nfpms: # note that this is an array of nfpm configs - # # ID of the nfpm config, must be unique. # Name of the package. package_name: tkey-ssh-agent # Your app's vendor. vendor: Tillitis AB # Your app's homepage. homepage: https://tillitis.se/ # Your app's maintainer (probably you). maintainer: Tillitis # Your app's description. description: |- SSH agent backed by Tillitis TKey tkey-ssh-agent is an alternative SSH agent backed by a private ed25519 key residing in the hardware TKey, a USB stick. # Your app's license. license: GPL 2.0 # Formats to be generated. formats: - apk - deb - rpm - archlinux # Since: v1.13 dependencies: - pinentry-gnome3 bindir: /usr/bin release: 1 section: misc # Contents to add to the package. # GoReleaser will automatically add the binaries. contents: - src: system/tkey-ssh-agent.1 dst: /usr/share/man/man1/tkey-ssh-agent.1 file_info: mode: 0644 - src: system/tkey-ssh-agent.service dst: /usr/lib/systemd/user/tkey-ssh-agent.service file_info: mode: 0644 - src: system/60-tkey.rules dst: /usr/lib/udev/rules.d/60-tkey.rules file_info: mode: 0644 - src: system/copyright dst: /usr/share/docs/tkey-ssh-agent/ file_info: mode: 0644 overrides: apk: dependencies: - pinentry-gnome archlinux: dependencies: - pinentry # Scripts to execute during the installation of the package. (overridable) scripts: postinstall: "system/postinst" # Custom configuration applied only to the Deb packager. deb: # Lintian overrides lintian_overrides: - statically-linked-binary - changelog-file-missing-in-native-package checksum: name_template: 'checksums.txt' snapshot: name_template: "{{ incpatch .Version }}-next" changelog: sort: filters: exclude: - '^docs:' - '^test:' tkey-ssh-agent-1.0.0+ds/LICENSE000066400000000000000000000350501471561636600160040ustar00rootroot00000000000000GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. tkey-ssh-agent-1.0.0+ds/Makefile000066400000000000000000000050241471561636600164350ustar00rootroot00000000000000# Check for OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) shasum = shasum -a 512 BUILD_CGO_ENABLED ?= 1 else shasum = sha512sum BUILD_CGO_ENABLED ?= 0 endif .PHONY: all all: tkey-ssh-agent .PHONY: windows windows: tkey-ssh-agent.exe tkey-ssh-agent-tray.exe DESTDIR=/ PREFIX=/usr/local SYSTEMDDIR=/etc/systemd UDEVDIR=/etc/udev destbin=$(DESTDIR)/$(PREFIX)/bin destman1=$(DESTDIR)/$(PREFIX)/share/man/man1 destunit=$(DESTDIR)/$(SYSTEMDDIR)/user destrules=$(DESTDIR)/$(UDEVDIR)/rules.d .PHONY: install install: install -Dm755 tkey-ssh-agent $(destbin)/tkey-ssh-agent strip $(destbin)/tkey-ssh-agent install -Dm644 system/tkey-ssh-agent.1 $(destman1)/tkey-ssh-agent.1 gzip -n9f $(destman1)/tkey-ssh-agent.1 install -Dm644 system/tkey-ssh-agent.service.tmpl $(destunit)/tkey-ssh-agent.service sed -i -e "s,##BINDIR##,$(PREFIX)/bin," $(destunit)/tkey-ssh-agent.service install -Dm644 system/60-tkey.rules $(destrules)/60-tkey.rules .PHONY: uninstall uninstall: rm -f \ $(destbin)/tkey-ssh-agent \ $(destunit)/tkey-ssh-agent.service \ $(destrules)/60-tkey.rules \ $(destman1)/tkey-ssh-agent.1.gz .PHONY: reload-rules reload-rules: udevadm control --reload udevadm trigger .PHONY: podman podman: podman run --rm --mount type=bind,source=$(CURDIR),target=/src -w /src -it ghcr.io/tillitis/tkey-builder:4 make -j .PHONY: check-signer-hash check-signer-hash: cd cmd/tkey-ssh-agent && $(shasum) -c signer.bin.sha512 TKEY_SSH_AGENT_VERSION ?= # .PHONY to let go-build handle deps and rebuilds .PHONY: tkey-ssh-agent tkey-ssh-agent: check-signer-hash CGO_ENABLED=$(BUILD_CGO_ENABLED) go build -ldflags "-X main.version=$(TKEY_SSH_AGENT_VERSION) -X main.signerAppNoTouch=$(TKEY_SIGNER_APP_NO_TOUCH)" -trimpath -buildvcs=false ./cmd/tkey-ssh-agent .PHONY: tkey-ssh-agent.exe tkey-ssh-agent.exe: $(MAKE) -C gotools go-winres cd ./cmd/tkey-ssh-agent && ../../gotools/go-winres make --arch amd64 $(MAKE) GOOS=windows GOARCH=amd64 tkey-ssh-agent # .PHONY to let go-build handle deps and rebuilds .PHONY: tkey-ssh-agent-tray.exe tkey-ssh-agent-tray.exe: $(MAKE) -C gotools go-winres cd ./cmd/tkey-ssh-agent-tray && ../../gotools/go-winres make --arch amd64 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-H windowsgui" -trimpath -buildvcs=false ./cmd/tkey-ssh-agent-tray .PHONY: clean clean: rm -f \ tkey-ssh-agent \ tkey-ssh-agent.exe cmd/tkey-ssh-agent/rsrc_windows_amd64.syso \ tkey-ssh-agent-tray.exe cmd/tkey-ssh-agent-tray/rsrc_windows_amd64.syso .PHONY: lint lint: GOOS=linux golangci-lint run GOOS=windows golangci-lint run tkey-ssh-agent-1.0.0+ds/README.md000066400000000000000000000241261471561636600162600ustar00rootroot00000000000000[![ci](https://github.com/tillitis/tillitis-key1-apps/actions/workflows/ci.yaml/badge.svg?branch=main&event=push)](https://github.com/tillitis/tillitis-key1-apps/actions/workflows/ci.yaml) # TKey SSH Agent `tkey-ssh-agent` is an OpenSSH-compatible agent for use with the [Tillitis](https://tillitis.se/) TKey USB security token. **Warning**: Please use tagged releases for any real use. Development on main might mean we change which version of the [the signer device app](https://github.com/tillitis/tkey-device-signer) we use which would cause the SSH key pair to change! See [Release notes](docs/release_notes.md). ## Installing tkey-ssh-agent might be available in your operating system's package system. If not, see [Tillitis' application page for the agent as well as instructions](https://tillitis.se/app/tkey-ssh-agent/). If there's no official package for your system the easiest way to install is probably to: ``` $ go install github.com/tillitis/tkey-ssh-agent/cmd/tkey-ssh-agent@latest ``` After this the `tkey-ssh-agent` command should be available in your `$GOBIN` directory. Note that installing with `go install` doesn't set the version like building with other methods does. See building the agent below. You will also have to install these manually if you use go install: - Manual page `system/tkey-ssh-agent.1`. - udev rules, see `system/60-tkey.rules` (Linux). - systemd service unit, see `system/tkey-ssh-agent.service.tmpl` and change `##BINDIR##` to where you installed `tkey-ssh-agent` (some Linux dists). If you're building from source (see below) there is a `make install` target that installs the agent and the udev rules. Please see `Makefile` to see that everything ends up where you want to. Typically you will have to do: ``` $ sudo make install $ sudo make reload-rules ``` ## Using tkey-ssh-agent `tkey-ssh-agent` tries to auto-detect the TKey. If more than one is found, or if you're running on QEMU, then you'll need to use the `--port` flag: ``` $ ./tkey-ssh-agent -a ./agent.sock --port /dev/pts/1 ``` This will start the SSH agent and tell it to listen on the specified socket `./agent.sock`. **Nota bene**: If the signer app binary, the USS, or the UDS in the physical USB stick change your key pair will change. If you copy-paste the public key into your `~/.ssh/authorized_keys` you can try to log onto your local computer (if sshd is running there). The socket path set/output above is also needed by SSH in `SSH_AUTH_SOCK`: ``` $ SSH_AUTH_SOCK=/path/to/agent.sock ssh -F /dev/null localhost ``` `-F /dev/null` is used to ignore your ~/.ssh/config which could interfere with this test. The tkey-ssh-agent also supports the `--uss` and `--uss-file` flags to enter a User Supplied Secret. You can use `--show-pubkey` (short flag: `-p`) to only output the pubkey. The pubkey is printed to stdout for easy redirection, but some messages are still present on stderr. ## Building the agent If you have Go and make installed, a simple: ``` $ make ``` or, for a Windows executable, ``` $ make tkey-ssh-agent.exe ``` should build the agent. A pre-compiled signer device app binary is included in the repo and will be automatically embedded. Cross compiling the usual Go way with `GOOS` and `GOARCH` environment variables works for most targets but currently doesn't work for `GOOS=darwin` since the `go.bug.st/serial` package relies on macOS shared libraries for port enumeration. ### Building agent with tkey-builder If you want to use our tkey-builder image and you have `make` you can run: ``` $ podman pull ghcr.io/tillitis/tkey-builder:4 $ make podman ``` or run it directly with Podman: ``` $ podman run --rm --mount type=bind,source=$(CURDIR),target=/src --mount type=bind,source=$(CURDIR)/../tkey-libs,target=/tkey-libs -w /src -it ghcr.io/tillitis/tkey-builder:4 make -j ``` Note that building with Podman like this by default creates a Linux binary. Set `GOOS` and `GOARCH` with `-e` in the call to `podman run` to desired target. Again, this won't work with a macOS target. ### Building with another signer For convenience, and to be able to support `go install`, a precompiled [signer device app](https://github.com/tkey-device-signer) binary is included under `cmd/tkey-ssh-agent`. If you want to replace the signer used by the agent you have to: 1. Compile your own signer and place it in the `cmd/tkey-ssh-agent` directory. 2. Change the path to the embedded signer in `cmd/tkey-ssh-agent/signer.go`. Look for `go:embed...`. 3. Change the `appName` directly under the `go:embed` to whatever your signer is called so the agent reports this correctly with `--version`. 4. Compute a new SHA-512 hash digest for your binary, typically by something like `sha512sum cmd/tkey-ssh-agent/signer.bin-v0.0.7` and put the resulting output in the file `signer.bin.sha512` at the top level. 5. `make` in the top level. ### Disabling touch requirement The [signer device app](https://github.com/tkey-device-signer) normally requires the TKey to be physically touched to make a signature. For special purposes it can be compiled without this requirement by setting the environment variable `TKEY_SIGNER_APP_NO_TOUCH` to some value when building. Example: `make TKEY_SIGNER_APP_NO_TOUCH=yesplease`. *Note well*: You have to do this when building both the signer and the client apps. `tkey-ssh-agent` will also stop displaying notifications about touch if the variable is set. **Warning**: Of course changing the code also changes the signer binary and as a consequence the SSH key pair will also change. ## Building the signer 1. See [the Devoloper Handbook](https://dev.tillitis.se/) for setup of development tools. We recommend you use tkey-builder. 2. See the instructions in the [tkey-device-signer repo](https://github.com/tillitis/tkey-device-signer). 3. Copy its `signer/app.bin` to `cmd/tkey-sign/signer.bin-${signer_version}` and run `make`. To help prevent unpleasant surprises we keep a digest of the signer in `cmd/tkey-ssh-agent/signer.bin.sha512`. The compilation will fail if this is not the expected binary. If you really intended to build with another signer, see [Building with another signer](#building-with-another-signer) above. ## Windows support `tkey-ssh-agent` can be built for Windows. The Makefile has a `windows` target that produces `tkey-ssh-agent.exe` and `tkey-ssh-agent-tray.exe`. The former is a regular command-line application, suitable for use in environments like PowerShell. The latter is a small application built for the `windowsgui` subsystem, meaning it operates without a console. Its primary function is to create a tray icon and initiate `tkey-ssh-agent.exe` with the identical arguments it received. They are assumed to be located in the same directory. For automatically starting the SSH agent when logging onto the computer, a shortcut to `tkey-ssh-agent-tray.exe`, with the required arguments, can be added in your user's `Startup` folder. When using the `--uss` option the Windows build by default uses the pinentry program from Gpg4win for requesting the User-Supplied Secret. This package can be installed using: `winget install GnuPG.Gpg4win`. The SSH Agent supports being used by the native OpenSSH client `ssh.exe` (part of Windows Optional Features and installable using `winget`). The environment variable `SSH_AUTH_SOCK` should be set to the complete path of the Named Pipe that tkey-ssh-agent listens on. For example, if it is started using `./tkey-ssh-agent.exe -a tkey-ssh-agent` the environment variable could be set for the current PowerShell like this: ```powershell $env:SSH_AUTH_SOCK = '\\.\pipe\tkey-ssh-agent' ``` Setting this environment variable persistently, for future PowerShell terminals, Visual Studio Code, and other programs can be done through the System Control Panel. Or using PowerShell: ```powershell [Environment]::SetEnvironmentVariable('SSH_AUTH_SOCK', '\\.\pipe\tkey-ssh-agent', 'User') ``` You can learn more about environment variables on Windows in [Microsoft's article](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables). The SSH Agent can also be used with the Git-for-Windows client (`winget install Git.Git`). By default, it uses its own bundled ssh-client. Run the following PowerShell commands to make `git.exe` use the system's native ssh.exe: ``` $sshpath = (get-command ssh.exe).path -replace '\\','/' git config --global core.sshCommand $sshpath git config --global --get core.sshCommand ``` The last command should output something like `C:/Windows/System32/OpenSSH/ssh.exe`. For details on how we package and build an MSI installer, see [system/windows/README.md](system/windows/README.md). ## Licenses and SPDX tags Unless otherwise noted, the project sources are licensed under the terms and conditions of the "GNU General Public License v2.0 only": > Copyright Tillitis AB. > > These programs are free software: you can redistribute it and/or > modify it under the terms of the GNU General Public License as > published by the Free Software Foundation, version 2 only. > > These programs are distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > General Public License for more details. > You should have received a copy of the GNU General Public License > along with this program. If not, see: > > https://www.gnu.org/licenses See [LICENSE](LICENSE) for the full GPLv2-only license text. External source code we have imported are isolated in their own directories. They may be released under other licenses. This is noted with a similar `LICENSE` file in every directory containing imported sources. The project uses single-line references to Unique License Identifiers as defined by the Linux Foundation's [SPDX project](https://spdx.org/) on its own source files, but not necessarily imported files. The line in each individual source file identifies the license applicable to that file. The current set of valid, predefined SPDX identifiers can be found on the SPDX License List at: https://spdx.org/licenses/ All contributors must adhere to the [Developer Certificate of Origin](dco.md). tkey-ssh-agent-1.0.0+ds/cmd/000077500000000000000000000000001471561636600155375ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/000077500000000000000000000000001471561636600213575ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/main.go000066400000000000000000000071751471561636600226440ustar00rootroot00000000000000// Copyright (C) 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only //go:build windows package main import ( _ "embed" "fmt" "log" "os" "os/exec" "path/filepath" "runtime" "strings" "syscall" "github.com/apenwarr/fixconsole" "github.com/getlantern/systray" "github.com/tawesoft/golib/v2/dialog" "github.com/tillitis/tkeyutil" ) var le = log.New(os.Stderr, "", 0) const ( progname = "tkey-ssh-agent-tray" // Expected to be found next to ourselves mainExe = "tkey-ssh-agent.exe" ) var notify = func(msg string) { tkeyutil.Notify(progname, msg) } func main() { if runtime.GOOS != "windows" { le.Printf("Only implemented for windows\n") os.Exit(1) } // We're not supposed to be run in a console , but if we still are // then try to get our output into it if err := fixconsole.FixConsoleIfNeeded(); err != nil { le.Printf("FixConsole: %d\n", err) } le = log.New(os.Stderr, "", 0) ourExePath, err := os.Executable() if err != nil { notify("Could not find our own executable") le.Printf("os.Executable: %d\n", err) os.Exit(1) } mainExePath := filepath.Join(filepath.Dir(ourExePath), mainExe) args := os.Args[1:] if !contains(args, "-a") && !contains(args, "--agent-path") { notify("To get tkey-ssh-agent started, the tray-program should be passed at least the -a argument to set the name of the listening pipe.") os.Exit(2) } fmt.Printf("Starting \"%s\" with args %v\n", mainExePath, args) cmd := exec.Command(mainExePath, args...) // mainExe is built as a "console binary" (without `-H // windowsgui`), so when run without a console, windows will open // up a console for it unless we do this: cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} if err = cmd.Start(); err != nil { notify(fmt.Sprintf("Could not start \"%s\":\n%s", mainExe, err)) le.Printf("Failed to start: %s\n", err) os.Exit(1) } le.Printf("Started with PID: %d\n", cmd.Process.Pid) mainCmdLine := fmt.Sprintf("%s %s", mainExe, strings.Join(args, " ")) go tray(mainCmdLine, func() { if err = cmd.Process.Kill(); err != nil { le.Printf("Failed to stop %s on Quit: %s\n", mainExe, err) } os.Exit(0) }) state, err := cmd.Process.Wait() if err != nil { notify(fmt.Sprintf("Failed to wait for %s:\n%s", mainExe, err)) le.Printf("Failed to wait for %s: %s\n", mainExe, err) os.Exit(1) } if !state.Success() { notify(fmt.Sprintf("%s stopped with code %d.\n%s will exit.", mainExe, state.ExitCode(), progname)) } le.Printf("%s stopped with code: %d\n", mainExe, state.ExitCode()) le.Printf("%s is exiting\n", progname) os.Exit(state.ExitCode()) } //go:embed trayicon.ico var trayIconICO []byte func tray(mainCmdLine string, onExit func()) { onReady := func() { le.Printf("Added icon to system tray\n") systray.SetTemplateIcon(trayIconICO, trayIconICO) systray.SetTitle(mainCmdLine) // only on linux, macos systray.SetTooltip(mainCmdLine) // only on macos, windows // no menuitem tooltip on windows about := systray.AddMenuItem("About", "") go func() { for range about.ClickedCh { _ = dialog.Info(fmt.Sprintf(`TKey SSH Agent Copyright (C) Tillitis AB Source code is licensed under GNU General Public License v2.0 only unless otherwise noted in the source code. Source repository: https://github.com/tillitis/tillitis-key1-apps Tillitis: https://www.tillitis.se Running: %s`, mainCmdLine)) } }() quit := systray.AddMenuItem("Quit", "") go func() { <-quit.ClickedCh le.Printf("Quit from trayicon menu\n") systray.Quit() }() } systray.Run(onReady, onExit) } func contains(ss []string, e string) bool { for _, s := range ss { if s == e { return true } } return false } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/trayicon.ico000066400000000000000000000302511471561636600237040ustar00rootroot00000000000000 0PNG  IHDR?1orNTϢw0MIDATxwT߷VX@)" (41ƒhM$j_{Io,5&&_{AT)*Uβ}{;+{w9׾^0ys'H$m$l" k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^l@8yN})atKR#%(di(-.$Lh* g`5Z \J6AV7fIH `ѫ3]ѥ]o"ztdd(l9 p CӲ}"#`p.C)ʶ5l"\gUi?p(!ffdx*6 Xya)&QA{AG @xqLG]bw@^P!pg{XK/(pc!$C q{F r)gH@Й< 2 H)βL+U5u :w">-#`ST0})#ܞCу-;%f 4Z|ؠI^(LddD~'7sS ռ g4D3(AB] `~5꣼0%O}kqЙ}t R^(eTRZdJ8e$ϽFƇy϶1XAe]K5 i"pqA'CD#2Q8/h,1S"1t-[(&m9u$ԵDgWZlA6~Ϝ_Fcszm#V.!W7vĬH:J/ 7,u`Pq<-,]4B!NK>Z?_/( 'bS^P^lS TӢk zrCZϿd: yxJL9b  wxi!ֆh,Ý$/l:ˀ'\eni%nhPt UWz%y\xYဳv."i] #gQ4&Ƭvߝ.Ă,m0 IK 19D"P ݎ~6xЉaE,^Ói5#Ĝ(TVBh1Oqo+N534&TnC՝x I2N p-XbpNDU1r&JGU&pM(%(r\wM#RN>xW.MM%cx?YurZF,Ug3nu#j*,l,дi<%acEn rIB pFO\Eğ"bл9%pΏ1Ĭ(LK .9L. 9:Ȑyw 8ҟ-xzl-|ltܓ!)GLg c?/] %6f?nFͦ);\X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ix kx8o9) z(Dt^\ьNQ Zk$'% ҸxAMn Fqư=NQ\]Y@8ă3kqFaW'ڟ2Rwе$6*Զpr]8~vg]ޱ]8[c /t :iDrڳH)J«9[( :s1&9KP X9_r5O kjWћb 1',/h5Fh%H?msl0t"y}^8ȅfxA3Ƙr( 1W>{}2Ş-G J;!%kݮs j OYG& x+c9 YjK"`:DcMl9ꔣ3$Wlb&C0;/Ȫb'df Psu/5@;m ꇐZ P 2&m/B&0Sj IhlzT^KI.nd(W͙5ii!}BeMԲ ذ5QYXb#ѱZ-:ݏ`&&m];#Krq˦0D4!>6ɋmi_Ϲim(a&+A*jAfG!lЭۦ(ˋkhn#m.h 7Jkx QCI.43mt%Y+m^q]Pb\qXv[IU0NJ$ " k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k?GFd~PIENDB`tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/winres/000077500000000000000000000000001471561636600226665ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/winres/icon.png000066400000000000000000000276611471561636600243400ustar00rootroot00000000000000PNG  IHDR?1{iCCPicc(}=H@_HE""]TıVBЪɥ_Ф!Iqq\ ~,V\uupW'E)IExwq7L5 @,#J Bc39QLs|׻8>S &|qEA~weӜ|Ӓ)ؖvW+_? ?',Qҗh,Mђe+6,SJr8|0\$$QU0!h_ƂYʨsV7`QJG9^d֥" 4j qX)D< ao1M1}(&XM$)KB1'U+uPP(#r/\0+͞E:]DES o)вhibW-P.+ au$@Dhs)" 5r-~O> jF@H2$RZeyV* 9KPX 0^zǁKM5lr/C^U[NCSȎ[ N5caE+2AŵPuM{nʿnD.0,ć"xŸ=> YUK>@oI:$3& c .vp02ʡKi- {3pD=Htl Wa4p&0 z 4PwO?nzVQD4 ȲKQ׀md> kv9O7=\ @BʯB{WQB= *ϋ9G]QH:٧ꗦBn;KdtuE1[\ʬS<]Z@h͙+=F|_sV}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RABtbϽ [=͝% 'ĂQ4ugApYXǂ mdF#^ϟi,h7,0PxV… Dv) 3qCq\o sn) zMP1 ~0dnNYG'Mw7%io+7)ް zH $+W_'LX&rκgAٞ ‚L=]պcAyƂl @} f>{񮨚d: 3YPO#: |58eZg9 _daA?9z (U*MgКuZQК9Qz6 6D+dkcR=Z%^/{45o *F77@W6gkU5@%B 3Y 2`<>7xXv "Lvhxٓ)UHmGaW7ɔZ)wM[/Lx"}&2|9$l5%^]h 75yAҎ>Ի4o^AI nxI->mt4/op)4&`aa0X+0XX,,  `aa0XX,,  `aa0XX,,  `aa0XX,,  ?^n|Z[eXIfII* xx(1 2i``GIMP 2.10.342023:04:05 10:24:30%tEXtdate:create2023-04-05T08:26:33+00:00%tEXtdate:modify2023-04-05T08:24:30+00:00Rn(tEXtdate:timestamp2023-04-05T08:26:43+00:00:NtEXtexif:BitsPerSample8, 8, 8>'tEXtexif:ColorSpace1I!tEXtexif:DateTime2023:04:05 10:24:30v RtEXtexif:ExifOffset190LtEXtexif:ImageLength1400[tEXtexif:ImageWidth1400tEXtexif:SoftwareGIMP 2.10.34fstEXticc:copyrightPublic Domain1["tEXticc:descriptionGIMP built-in sRGBLgAtEXticc:manufacturerGIMPLtEXticc:modelsRGB[`ICIENDB`tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/winres/icon16.png000066400000000000000000000066171471561636600245050ustar00rootroot00000000000000PNG  IHDR(-S{iCCPicc(}=H@_HE""]TıVBЪɥ_Ф!Iqq\ ~,V\uupW'E)IExwq7L5 @,#J Bc39QLs|׻8>S &|qEApr/C,BD7k@q IBTa3>5AC?"[VX H;GsMqaW&]"t Ky~u|$\^02gnw4F~weӜ|Ӓ)ؖvW+_? ?',Qҗh,Mђe+6,SJr8|0\$$QU0!h_ƂYʨsV7`QJG9^d֥" 4j qX)D< ao1M1}(&XM$)KB1'U+uPP(#r/\0+͞E:]DES o)вhibW-P.+ au$@Dhs)" 5r-~O> jF@H2$RZeyV* 9KPX 0^zǁKM5lr/C^U[NCSȎ[ N5caE+2AŵPuM{nʿnD.0,ć"xŸ=> YUK>@oI:$3& c .vp02ʡKi- {3pD=Htl Wa4p&0 z 4PwO?nzVQD4 ȲKQ׀md> kv9O7=\ @BʯB{WQB= *ϋ9G]QH:٧ꗦBn;KdtuE1[\ʬS<]Z@h͙+=F|_sV}'.|G۪5w:@#4Nau:hҵg l{A[2pKѝWģ=&jx) mނXν74%0NؓR|snt^nCݴ`]^k=61rx ֚+[--N}KN85ݬ;2'}v{d>d>ګdLj7_#z#W.(jΩ{ǽ!z#ua=7=wهQ{evOCj%= z#г|?wPnrym6J[|\|orNTϢwIDATc``dbfad@V6vvNV7/? \@@PHXDTFKB@RJZFFA, + '̡ªRʩ&͡ìǬ k`hdlbjfncietP#?;\f 3i e9Cä#"cbYAVI'$&%g]bǝ ̬@6Z.eXIfII* xx(1 2i``GIMP 2.10.342023:04:05 10:24:30%tEXtdate:create2023-04-05T08:26:33+00:00%tEXtdate:modify2023-04-05T08:24:30+00:00Rn(tEXtdate:timestamp2023-04-05T08:31:23+00:00sAtEXtexif:BitsPerSample8, 8, 8>'tEXtexif:ColorSpace1I!tEXtexif:DateTime2023:04:05 10:24:30v RtEXtexif:ExifOffset190LtEXtexif:ImageLength1400[tEXtexif:ImageWidth1400tEXtexif:SoftwareGIMP 2.10.34fstEXticc:copyrightPublic Domain1["tEXticc:descriptionGIMP built-in sRGBLgAtEXticc:manufacturerGIMPLtEXticc:modelsRGB[`ICIENDB`tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent-tray/winres/winres.json000066400000000000000000000026431471561636600250750ustar00rootroot00000000000000{ "RT_GROUP_ICON": { "APP": { "0000": [ "icon.png", "icon16.png" ] } }, "RT_MANIFEST": { "#1": { "0409": { "identity": { "name": "", "version": "" }, "description": "", "minimum-os": "win7", "execution-level": "as invoker", "ui-access": false, "auto-elevate": false, "dpi-awareness": "system", "disable-theming": false, "disable-window-filtering": false, "high-resolution-scrolling-aware": false, "ultra-high-resolution-scrolling-aware": false, "long-path-aware": false, "printer-driver-isolation": false, "gdi-scaling": false, "segment-heap": false, "use-common-controls-v6": false } } }, "RT_VERSION": { "#1": { "0000": { "fixed": { "file_version": "0.0.0.0", "product_version": "0.0.0.0" }, "info": { "0409": { "Comments": "", "CompanyName": "Tillitis AB", "FileDescription": "", "FileVersion": "", "InternalName": "", "LegalCopyright": "", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", "ProductName": "", "ProductVersion": "", "SpecialBuild": "" } } } } } } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/000077500000000000000000000000001471561636600204025ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/listen_unix.go000066400000000000000000000005251471561636600232740ustar00rootroot00000000000000// Copyright (C) 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only //go:build unix package main import ( "fmt" "net" "syscall" ) func nativeListen(path string) (net.Listener, error) { syscall.Umask(0o077) l, err := net.Listen("unix", path) if err != nil { return nil, fmt.Errorf("Listen: %w", err) } return l, nil } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/listen_windows.go000066400000000000000000000013521471561636600240020ustar00rootroot00000000000000// Copyright (C) 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only //go:build windows package main import ( "fmt" "net" "os/user" "github.com/Microsoft/go-winio" ) func nativeListen(path string) (net.Listener, error) { // Create a SecurityDescriptor that makes the named pipe created // by ListenPipe accessible only by the current user currentUser, err := user.Current() if err != nil { return nil, fmt.Errorf("user.Current: %w", err) } pipeConf := &winio.PipeConfig{ SecurityDescriptor: "D:(A;;FA;;;" + currentUser.Uid + ")", InputBufferSize: 4096, OutputBufferSize: 4096, } l, err := winio.ListenPipe(path, pipeConf) if err != nil { return nil, fmt.Errorf("ListenPipe: %w", err) } return l, nil } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/main.go000066400000000000000000000144201471561636600216560ustar00rootroot00000000000000// Copyright (C) 2022, 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only package main import ( "errors" "fmt" "log" "os" "path/filepath" "runtime" "runtime/debug" "strings" "github.com/spf13/pflag" "github.com/tillitis/tkeyclient" ) // Use when printing err/diag msgs var le = log.New(os.Stderr, "", 0) const progname = "tkey-ssh-agent" var version string const windowsPipePrefix = `\\.\pipe\` func main() { exit := func(code int) { os.Exit(code) } if version == "" { version = readBuildInfo() } var agentPath, devPath, fileUSS, pinentry string var speed int var enterUSS, showPubkeyOnly, listPortsOnly, versionOnly, helpOnly bool pflag.CommandLine.SetOutput(os.Stderr) pflag.CommandLine.SortFlags = false pflag.CommandLine.SetNormalizeFunc(func(_ *pflag.FlagSet, name string) pflag.NormalizedName { // Make old name agent-socket an alias for the new name if name == "agent-socket" { name = "agent-path" } return pflag.NormalizedName(name) }) pflag.StringVarP(&agentPath, "agent-path", "a", "", fmt.Sprintf("Start the agent, setting the `PATH` to the UNIX-domain socket that it should listen on. On Windows, a Named Pipe at '%s\\PATH' will be used.", windowsPipePrefix)) pflag.BoolVarP(&showPubkeyOnly, "show-pubkey", "p", false, "Don't start the agent, only output the ssh-ed25519 public key.") pflag.BoolVarP(&listPortsOnly, "list-ports", "L", false, "List possible serial ports to use with --port.") pflag.StringVar(&devPath, "port", "", "Set serial port device `PATH`. If this is not passed, auto-detection will be attempted.") pflag.IntVar(&speed, "speed", tkeyclient.SerialSpeed, "Set serial port speed in `BPS` (bits per second).") pflag.BoolVar(&enterUSS, "uss", false, "Enable typing of a phrase to be hashed as the User Supplied Secret. The USS is loaded onto the TKey along with the app itself. A different USS results in different SSH public/private keys, meaning a different identity.") pflag.StringVar(&fileUSS, "uss-file", "", "Read `FILE` and hash its contents as the USS. Use '-' (dash) to read from stdin. The full contents are hashed unmodified (e.g. newlines are not stripped).") pflag.StringVar(&pinentry, "pinentry", "", "Pinentry `PROGRAM` for use by --uss. The default is found by looking in your gpg-agent.conf for pinentry-program, or 'pinentry' if not found there. On Windows, an attempt is made to find Gpg4win's pinentry program to use as default.") pflag.BoolVar(&versionOnly, "version", false, "Output version information.") pflag.BoolVar(&helpOnly, "help", false, "Output this help.") pflag.Usage = func() { desc := fmt.Sprintf(`Usage: %[1]s -a|-p|-L [flags...] %[1]s is an alternative SSH agent that communicates with a Tillitis TKey USB stick. This stick holds private key and signing functionality for public key authentication. When the environment variable SSH_AUTH_SOCK is set to contain the agent-path, programs like ssh(1) and ssh-keygen(1) can find and use this agent, e.g. for authentication when accessing other machines. To make the TKey provide this functionality, the %[1]s contains a compiled signer app binary which it loads onto the stick and starts. The LED on the stick is a steady blue when the signer app is running and waiting for a command. It will flash green when the stick must be touched to complete a signature.`, progname) le.Printf("%s\n\n%s", desc, pflag.CommandLine.FlagUsagesWrapped(86)) } pflag.Parse() if pflag.NArg() > 0 { le.Printf("Unexpected argument: %s\n\n", strings.Join(pflag.Args(), " ")) pflag.Usage() exit(2) } if signerAppNoTouch != "" { le.Printf("WARNING! This tkey-ssh-agent and signer app is built with the touch requirement removed\n") } if helpOnly { pflag.Usage() exit(0) } if versionOnly { fmt.Printf("%s %s\n\n", progname, version) fmt.Printf("Embedded device app:\n%s\nSHA512: %s\n", GetEmbeddedAppName(), GetEmbeddedAppDigest()) exit(0) } exclusive := 0 if agentPath != "" { exclusive++ } if showPubkeyOnly { exclusive++ } if listPortsOnly { exclusive++ } if exclusive > 1 { le.Printf("Pass only one of -a, -p, or -L.\n\n") pflag.Usage() exit(2) } if listPortsOnly { n, err := printPorts() if err != nil { le.Printf("%v\n", err) exit(1) } else if n == 0 { exit(1) } // Successful only if we found some port exit(0) } if !showPubkeyOnly && agentPath == "" { le.Printf("Please pass at least -a or -p.\n\n") pflag.Usage() exit(2) } if enterUSS && fileUSS != "" { le.Printf("Pass only one of --uss or --uss-file.\n\n") pflag.Usage() exit(2) } prevExitFunc := exit exit = func(code int) { _ = os.Remove(agentPath) prevExitFunc(code) } signer := NewSigner(devPath, speed, enterUSS, fileUSS, pinentry, exit) if showPubkeyOnly { if !signer.connect() { le.Printf("Connect failed") prevExitFunc(1) } signer.printAuthorizedKey() signer.closeNow() prevExitFunc(0) } if runtime.GOOS == "windows" { agentPath = filepath.Join(windowsPipePrefix, agentPath) } else { var err error agentPath, err = filepath.Abs(agentPath) if err != nil { le.Printf("Failed to resolve socket path: %s", err) prevExitFunc(1) } } _, err := os.Stat(agentPath) if err == nil || !errors.Is(err, os.ErrNotExist) { msg := fmt.Sprintf("Is an agent already running? Path %s exists.", agentPath) notify(msg) le.Printf("%s\n", msg) // Don't remove the socket for the agent running. prevExitFunc(1) } agent := NewSSHAgent(signer) if err := agent.Serve(agentPath); err != nil { le.Printf("%s\n", err) exit(1) } exit(0) } func readBuildInfo() string { version := "devel without BuildInfo" if info, ok := debug.ReadBuildInfo(); ok { sb := strings.Builder{} sb.WriteString("devel") for _, setting := range info.Settings { if strings.HasPrefix(setting.Key, "vcs") { sb.WriteString(fmt.Sprintf(" %s=%s", setting.Key, setting.Value)) } } version = sb.String() } return version } func printPorts() (int, error) { ports, err := tkeyclient.GetSerialPorts() if err != nil { return 0, fmt.Errorf("Failed to list ports: %w", err) } if len(ports) == 0 { le.Printf("No TKey serial ports found.\n") } else { le.Printf("TKey serial ports (on stdout):\n") for _, p := range ports { fmt.Fprintf(os.Stdout, "%s serialNumber:%s\n", p.DevPath, p.SerialNumber) } } return len(ports), nil } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/pinentry.go000066400000000000000000000057161471561636600226120ustar00rootroot00000000000000// Copyright (C) 2022, 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only package main import ( "fmt" "os" "os/exec" "path/filepath" "runtime" "github.com/twpayne/go-pinentry-minimal/pinentry" ) func getSecret(udi string, pinentryProgram string) ([]byte, error) { // Displaying the Unique Device Identifier (UDI) so the user will // know which stick they have plugged in. desc := fmt.Sprintf("%s needs a User Supplied Secret\n"+ "(USS) for your TKey with number:\n"+ "%v", progname, udi) // The default pinentry program (binaryName) in the client is // "pinentry". opts := []pinentry.ClientOption{ // Try to get pinentry program from gpg-agent.conf pinentry.WithBinaryNameFromGnuPGAgentConf(), pinentry.WithGPGTTY(), pinentry.WithDesc(desc), // pinentry-gnome3 uses Prompt as a title so we don't use the // USS abbreviation, and skip trailing ":". pinentry.WithPrompt("User Supplied Secret"), // Title is not displayed by all pinentry programs (or // displayed obscurely in window title). pinentry.WithTitle(progname), } // If argument is passed, add option to override the pinentry program if pinentryProgram != "" { opts = append(opts, pinentry.WithBinaryName(pinentryProgram)) } else if runtime.GOOS == "windows" { found := findWindowsPinentry() if found != "" { le.Printf("Found gpgconf and got pinentry program: %s\n", found) opts = append(opts, pinentry.WithBinaryName(found)) } } client, err := pinentry.NewClient(opts...) if err != nil { return nil, fmt.Errorf("pinentry.NewClient: %w", err) } defer client.Close() pin, _, err := client.GetPIN() if err != nil { return nil, fmt.Errorf("pinentry GetPin: %w", err) } return []byte(pin), nil } func findWindowsPinentry() string { // When Gpg4win is installed using winget, the path to gpgconf // (and other gpg programs) is added to PATH (it is something like // `C:\Program Files (x86)\GnuPG\bin`). Given that, we try to find // Gpg4win's pinentry program. Inspired by how gpg-agent does it // on Windows, see --pinentry-program on // https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html var found string knownProg, err := exec.LookPath("gpgconf.exe") if err != nil { le.Printf("LookPath: %s\n", err) return "" } // Dropping final "gpgconf.exe" gpgDir := filepath.Dir(knownProg) // Drop final "bin" if present if filepath.Base(gpgDir) == "bin" { gpgDir = filepath.Dir(gpgDir) } relExes := []string{`..\Gpg4win\bin\pinentry.exe`, `..\Gpg4win\pinentry.exe`} for _, relExe := range relExes { candidate := filepath.Join(gpgDir, relExe) _, err = os.Stat(candidate) if err != nil { le.Printf("Tried %s got: %s\n", candidate, err) continue } found = candidate break } if found == "" { for _, exe := range []string{`pinentry.exe`, `pinentry-basic.exe`} { candidate, err := exec.LookPath(exe) if err != nil { le.Printf("LookPath: %s\n", err) continue } found = candidate break } } return found } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/signer.bin.sha512000066400000000000000000000002241471561636600233630ustar00rootroot00000000000000fe4458e4125966885d9b745a25422948d76e60371165b97729fce1b423f22b87929c684b4381f2220aa0c94266ba035730d5f08a6e6e0aab7d7bf15165d2fff6 signer.bin-v1.0.0 tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/signer.go000066400000000000000000000164021471561636600222230ustar00rootroot00000000000000// Copyright (C) 2022, 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only package main import ( "crypto" "crypto/ed25519" "crypto/sha512" _ "embed" "encoding/hex" "errors" "fmt" "io" "os" "os/signal" "sync" "syscall" "time" "github.com/tillitis/tkeyclient" "github.com/tillitis/tkeysign" "github.com/tillitis/tkeyutil" "golang.org/x/crypto/ssh" ) // nolint:typecheck // Avoid lint error when the embedding file is missing. // Makefile copies the built app here ./app.bin // //go:embed signer.bin-v1.0.0 var appBinary []byte const appName string = "tkey-device-signer 1.0.0" var notify = func(msg string) { tkeyutil.Notify(progname, msg) } const ( idleDisconnect = 3 * time.Second // 4 chars each. wantFWName0 = "tk1 " wantFWName1 = "mkdf" wantAppName0 = "tk1 " wantAppName1 = "sign" ) type Signer struct { tk *tkeyclient.TillitisKey tkSigner *tkeysign.Signer devPath string speed int enterUSS bool fileUSS string pinentry string mu sync.Mutex connected bool disconnectTimer *time.Timer } func NewSigner(devPathArg string, speedArg int, enterUSS bool, fileUSS string, pinentry string, exitFunc func(int)) *Signer { var signer Signer tkeyclient.SilenceLogging() tk := tkeyclient.New() tkSigner := tkeysign.New(tk) signer = Signer{ tk: tk, tkSigner: &tkSigner, devPath: devPathArg, speed: speedArg, enterUSS: enterUSS, fileUSS: fileUSS, pinentry: pinentry, } // Do nothing on HUP, in case old udev rule is still in effect handleSignals(func() {}, syscall.SIGHUP) // Start handling signals here to catch abort during USS entering handleSignals(func() { signer.closeNow() exitFunc(1) }, os.Interrupt, syscall.SIGTERM) return &signer } func (s *Signer) connect() bool { s.mu.Lock() defer s.mu.Unlock() if s.disconnectTimer != nil { s.disconnectTimer.Stop() s.disconnectTimer = nil } if s.connected { return true } devPath := s.devPath if devPath == "" { var err error devPath, err = tkeyclient.DetectSerialPort(false) if err != nil { switch { case errors.Is(err, tkeyclient.ErrNoDevice): notify("Could not find any TKey plugged in.") case errors.Is(err, tkeyclient.ErrManyDevices): notify("Cannot work with more than 1 TKey plugged in.") default: notify(fmt.Sprintf("TKey detection failed: %s\n", err)) } le.Printf("Failed to detect port: %v\n", err) return false } le.Printf("Auto-detected serial port %s\n", devPath) } le.Printf("Connecting to TKey on serial port %s\n", devPath) if err := s.tk.Connect(devPath, tkeyclient.WithSpeed(s.speed)); err != nil { notify(fmt.Sprintf("Could not connect to a TKey on port %v.", devPath)) le.Printf("Failed to connect: %v", err) return false } if s.isFirmwareMode() { le.Printf("TKey is in firmware mode.\n") if err := s.loadApp(); err != nil { le.Printf("Failed to load app: %v\n", err) s.closeNow() return false } } if !s.isWantedApp() { // Notifying because we're kinda stuck if we end up here notify("Please remove and plug in your TKey again\n— it might be running the wrong app.") le.Printf("No TKey on the serial port, or it's running wrong app (and is not in firmware mode)") s.closeNow() return false } // We nowadays disconnect from the TKey when idling, so the // signer-app that's running may have been loaded by somebody // else. Therefore we can never be sure it has USS according to // the flags that tkey-ssh-agent was started with. So we no longer // say anything about that. s.connected = true return true } func (s *Signer) isFirmwareMode() bool { nameVer, err := s.tk.GetNameVersion() if err != nil { return false } // not caring about nameVer.Version return nameVer.Name0 == wantFWName0 && nameVer.Name1 == wantFWName1 } func (s *Signer) isWantedApp() bool { nameVer, err := s.tkSigner.GetAppNameVersion() if err != nil { if !errors.Is(err, io.EOF) { le.Printf("GetAppNameVersion: %s\n", err) } return false } // not caring about nameVer.Version return nameVer.Name0 == wantAppName0 && nameVer.Name1 == wantAppName1 } func (s *Signer) loadApp() error { var secret []byte if s.enterUSS { udi, err := s.tk.GetUDI() if err != nil { return fmt.Errorf("Failed to get UDI: %w", err) } secret, err = getSecret(udi.String(), s.pinentry) if err != nil { notify(fmt.Sprintf("Could not show USS prompt: %s", errors.Unwrap(err))) return fmt.Errorf("Failed to get USS: %w", err) } } else if s.fileUSS != "" { var err error secret, err = tkeyutil.ReadUSS(s.fileUSS) if err != nil { notify(fmt.Sprintf("Could not read USS file: %s", err)) return fmt.Errorf("Failed to read uss-file %s: %w", s.fileUSS, err) } } le.Printf("Loading signer app...\n") if err := s.tk.LoadApp(appBinary, secret); err != nil { return fmt.Errorf("LoadApp: %w", err) } le.Printf("Signer app loaded.\n") return nil } func (s *Signer) printAuthorizedKey() { if !s.connect() { le.Printf("Connect failed") return } defer s.disconnect() pub, err := s.tkSigner.GetPubkey() if err != nil { le.Printf("GetPubkey failed: %s\n", err) return } sshPub, err := ssh.NewPublicKey(ed25519.PublicKey(pub)) if err != nil { le.Printf("NewPublicKey failed: %s\n", err) return } le.Printf("Your SSH public key (on stdout):\n") fmt.Fprintf(os.Stdout, "%s", ssh.MarshalAuthorizedKey(sshPub)) } func (s *Signer) disconnect() { if s.tkSigner == nil { return } s.mu.Lock() defer s.mu.Unlock() if !s.connected { return } if s.disconnectTimer != nil { s.disconnectTimer.Stop() s.disconnectTimer = nil } s.disconnectTimer = time.AfterFunc(idleDisconnect, func() { s.mu.Lock() defer s.mu.Unlock() s.closeNow() s.connected = false s.disconnectTimer = nil le.Printf("Disconnected from TKey\n") }) } func (s *Signer) closeNow() { if s.tkSigner == nil { return } if err := s.tkSigner.Close(); err != nil { le.Printf("Close failed: %s\n", err) } } // implementing crypto.Signer below func (s *Signer) Public() crypto.PublicKey { if !s.connect() { return nil } defer s.disconnect() pub, err := s.tkSigner.GetPubkey() if err != nil { le.Printf("GetPubkey failed: %s\n", err) return nil } return ed25519.PublicKey(pub) } func (s *Signer) Sign(_ io.Reader, message []byte, opts crypto.SignerOpts) ([]byte, error) { if !s.connect() { return nil, fmt.Errorf("Connect failed") } defer s.disconnect() // The Ed25519 signature must be made over unhashed message. See: // https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/crypto/ed25519/ed25519.go;l=80 if opts.HashFunc() != crypto.Hash(0) { return nil, errors.New("message must not be hashed") } signature, err := s.tkSigner.Sign(message) if err != nil { return nil, fmt.Errorf("Sign: %w", err) } return signature, nil } func handleSignals(action func(), sig ...os.Signal) { ch := make(chan os.Signal, 1) signal.Notify(ch, sig...) go func() { for { <-ch action() } }() } // GetEmbeddedAppName returns the name of the embedded device app. func GetEmbeddedAppName() string { return appName } // GetEmbeddedAppDigest returns a string of the SHA512 digest for the embedded // device app func GetEmbeddedAppDigest() string { digest := sha512.Sum512(appBinary) return hex.EncodeToString(digest[:]) } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/sshagent.go000066400000000000000000000072471471561636600225570ustar00rootroot00000000000000// Copyright (C) 2022, 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only package main import ( "bytes" "crypto/rand" "errors" "fmt" "io" "net" "sync" "time" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) // May be set to non-empty at build time to indicate that the signer // app has been compiled with touch requirement removed. var signerAppNoTouch string type SSHAgent struct { signer *Signer operationMu sync.Mutex // only handling 1 agent op at a time } func NewSSHAgent(signer *Signer) *SSHAgent { return &SSHAgent{signer: signer} } func (s *SSHAgent) Serve(absSockPath string) error { path := absSockPath listener, err := nativeListen(path) if err != nil { notify(fmt.Sprintf("Could not create listener: %s", err)) return fmt.Errorf("%w", err) } le.Printf("Listening on %s\n", listener.Addr()) for { conn, err := listener.Accept() if err != nil { return fmt.Errorf("Accept: %w", err) } le.Printf("Handling a client connection\n") go s.handleConn(conn) } } func (s *SSHAgent) handleConn(c net.Conn) { if err := agent.ServeAgent(s, c); !errors.Is(io.EOF, err) { le.Printf("Agent client connection ended with error: %s\n", err) } } // implementing agent.ExtendedAgent below var ErrNotImplemented = errors.New("not implemented") func (s *SSHAgent) List() ([]*agent.Key, error) { s.operationMu.Lock() defer s.operationMu.Unlock() // Connect early to be able to return empty list if that fails if !s.signer.connect() { le.Printf("List: connect failed, returning empty list\n") return []*agent.Key{}, nil } pub := s.signer.Public() if pub == nil { return nil, fmt.Errorf("pubkey is nil") } sshPub, err := ssh.NewPublicKey(pub) if err != nil { return nil, fmt.Errorf("NewPublicKey: %w", err) } return []*agent.Key{{ Format: sshPub.Type(), Blob: sshPub.Marshal(), Comment: "TKey", }}, nil } func (s *SSHAgent) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) { s.operationMu.Lock() defer s.operationMu.Unlock() // This does s.signer.Public() sshSigner, err := ssh.NewSignerFromSigner(s.signer) if err != nil { return nil, fmt.Errorf("NewSignerFromSigner: %w", err) } if !bytes.Equal(key.Marshal(), sshSigner.PublicKey().Marshal()) { return nil, fmt.Errorf("pubkey mismatch") } if signerAppNoTouch == "" { timer := time.AfterFunc(4*time.Second, func() { notify("Touch your TKey to confirm SSH login.") }) defer timer.Stop() le.Printf("Sign: user will have to touch the TKey\n") } else { le.Printf("Sign: WARNING! This tkey-ssh-agent and signer app is built with the touch requirement removed\n") } signature, err := sshSigner.Sign(rand.Reader, data) if err != nil { return nil, fmt.Errorf("Signer.Sign: %w", err) } return signature, nil } func (s *SSHAgent) SignWithFlags(key ssh.PublicKey, data []byte, _ agent.SignatureFlags) (*ssh.Signature, error) { // we only do ed25519, so no need to care about flags return s.Sign(key, data) } func (s *SSHAgent) Extension(_ string, _ []byte) ([]byte, error) { // there is a new extensionType session-bind@openssh.com, but // implementation still seems optional // https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.agent return nil, agent.ErrExtensionUnsupported } func (s *SSHAgent) Add(_ agent.AddedKey) error { return ErrNotImplemented } func (s *SSHAgent) Remove(_ ssh.PublicKey) error { return ErrNotImplemented } func (s *SSHAgent) RemoveAll() error { return ErrNotImplemented } func (s *SSHAgent) Lock(_ []byte) error { return ErrNotImplemented } func (s *SSHAgent) Unlock(_ []byte) error { return ErrNotImplemented } func (s *SSHAgent) Signers() ([]ssh.Signer, error) { return nil, ErrNotImplemented } tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/winres/000077500000000000000000000000001471561636600217115ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/winres/icon.png000066400000000000000000000276611471561636600233630ustar00rootroot00000000000000PNG  IHDR?1{iCCPicc(}=H@_HE""]TıVBЪɥ_Ф!Iqq\ ~,V\uupW'E)IExwq7L5 @,#J Bc39QLs|׻8>S &|qEA~weӜ|Ӓ)ؖvW+_? ?',Qҗh,Mђe+6,SJr8|0\$$QU0!h_ƂYʨsV7`QJG9^d֥" 4j qX)D< ao1M1}(&XM$)KB1'U+uPP(#r/\0+͞E:]DES o)вhibW-P.+ au$@Dhs)" 5r-~O> jF@H2$RZeyV* 9KPX 0^zǁKM5lr/C^U[NCSȎ[ N5caE+2AŵPuM{nʿnD.0,ć"xŸ=> YUK>@oI:$3& c .vp02ʡKi- {3pD=Htl Wa4p&0 z 4PwO?nzVQD4 ȲKQ׀md> kv9O7=\ @BʯB{WQB= *ϋ9G]QH:٧ꗦBn;KdtuE1[\ʬS<]Z@h͙+=F|_sV}'.|G۪5w:@#4Nau:hҵg l{A[2pKѝWģ=&jx) mނXν74%0NؓR|snt^nCݴ`]^k=61rx ֚+[--N}KN85ݬ;2'}v{d>d>ګdLj7_#z#W.(jΩ{ǽ!z#ua=7=wهQ{evOCj%= z#г|?wPnrym6J[|\|orNTϢwbKGDC]4 $VIDATx]T®McQawg{Ă+(" bC,D,XPؐb"BUt)R첻=wv}s)}ۏo͝ywZ KJ `aa0XX,,  `aa0XX,,  `aa0XX,,  `aa0XX,, x@@LoRqo"(f0%5r`۰q+,[_K\qUK쫀c:2 bhHZk |.QÙ1Tʴ zsdc;ZQҬ-js{|Tm'~H|B8<ر;QYP!bH !c}L-DdA @ȅQ{ك,]̂"J qC~-DD'fA N[xEeA}P@r^v1Y IXб1Ыł)f0/ X1 łY NSzȔnjWfA d ,op$ XP2ʀ}aӤ3v#@^o| &?B(BN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if:BitsPerSample8, 8, 8>'tEXtexif:ColorSpace1I!tEXtexif:DateTime2023:04:05 10:24:30v RtEXtexif:ExifOffset190LtEXtexif:ImageLength1400[tEXtexif:ImageWidth1400tEXtexif:SoftwareGIMP 2.10.34fstEXticc:copyrightPublic Domain1["tEXticc:descriptionGIMP built-in sRGBLgAtEXticc:manufacturerGIMPLtEXticc:modelsRGB[`ICIENDB`tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/winres/icon16.png000066400000000000000000000066171471561636600235300ustar00rootroot00000000000000PNG  IHDR(-S{iCCPicc(}=H@_HE""]TıVBЪɥ_Ф!Iqq\ ~,V\uupW'E)IExwq7L5 @,#J Bc39QLs|׻8>S &|qEApr/C,BD7k@q IBTa3>5AC?"[VX H;GsMqaW&]"t Ky~u|$\^02gnw4F~weӜ|Ӓ)ؖvW+_? ?',Qҗh,Mђe+6,SJr8|0\$$QU0!h_ƂYʨsV7`QJG9^d֥" 4j qX)D< ao1M1}(&XM$)KB1'U+uPP(#r/\0+͞E:]DES o)вhibW-P.+ au$@Dhs)" 5r-~O> jF@H2$RZeyV* 9KPX 0^zǁKM5lr/C^U[NCSȎ[ N5caE+2AŵPuM{nʿnD.0,ć"xŸ=> YUK>@oI:$3& c .vp02ʡKi- {3pD=Htl Wa4p&0 z 4PwO?nzVQD4 ȲKQ׀md> kv9O7=\ @BʯB{WQB= *ϋ9G]QH:٧ꗦBn;KdtuE1[\ʬS<]Z@h͙+=F|_sV}'.|G۪5w:@#4Nau:hҵg l{A[2pKѝWģ=&jx) mނXν74%0NؓR|snt^nCݴ`]^k=61rx ֚+[--N}KN85ݬ;2'}v{d>d>ګdLj7_#z#W.(jΩ{ǽ!z#ua=7=wهQ{evOCj%= z#г|?wPnrym6J[|\|orNTϢwIDATc``dbfad@V6vvNV7/? \@@PHXDTFKB@RJZFFA, + '̡ªRʩ&͡ìǬ k`hdlbjfncietP#?;\f 3i e9Cä#"cbYAVI'$&%g]bǝ ̬@6Z.eXIfII* xx(1 2i``GIMP 2.10.342023:04:05 10:24:30%tEXtdate:create2023-04-05T08:26:33+00:00%tEXtdate:modify2023-04-05T08:24:30+00:00Rn(tEXtdate:timestamp2023-04-05T08:31:23+00:00sAtEXtexif:BitsPerSample8, 8, 8>'tEXtexif:ColorSpace1I!tEXtexif:DateTime2023:04:05 10:24:30v RtEXtexif:ExifOffset190LtEXtexif:ImageLength1400[tEXtexif:ImageWidth1400tEXtexif:SoftwareGIMP 2.10.34fstEXticc:copyrightPublic Domain1["tEXticc:descriptionGIMP built-in sRGBLgAtEXticc:manufacturerGIMPLtEXticc:modelsRGB[`ICIENDB`tkey-ssh-agent-1.0.0+ds/cmd/tkey-ssh-agent/winres/winres.json000066400000000000000000000026431471561636600241200ustar00rootroot00000000000000{ "RT_GROUP_ICON": { "APP": { "0000": [ "icon.png", "icon16.png" ] } }, "RT_MANIFEST": { "#1": { "0409": { "identity": { "name": "", "version": "" }, "description": "", "minimum-os": "win7", "execution-level": "as invoker", "ui-access": false, "auto-elevate": false, "dpi-awareness": "system", "disable-theming": false, "disable-window-filtering": false, "high-resolution-scrolling-aware": false, "ultra-high-resolution-scrolling-aware": false, "long-path-aware": false, "printer-driver-isolation": false, "gdi-scaling": false, "segment-heap": false, "use-common-controls-v6": false } } }, "RT_VERSION": { "#1": { "0000": { "fixed": { "file_version": "0.0.0.0", "product_version": "0.0.0.0" }, "info": { "0409": { "Comments": "", "CompanyName": "Tillitis AB", "FileDescription": "", "FileVersion": "", "InternalName": "", "LegalCopyright": "", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", "ProductName": "", "ProductVersion": "", "SpecialBuild": "" } } } } } } tkey-ssh-agent-1.0.0+ds/dco.md000066400000000000000000000025261471561636600160700ustar00rootroot00000000000000Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. tkey-ssh-agent-1.0.0+ds/docs/000077500000000000000000000000001471561636600157245ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/docs/release_notes.md000066400000000000000000000065651471561636600211120ustar00rootroot00000000000000# Release notes ## v1.0.0 - All other apps, libraries, and packages have moved to their own repos. - Bug fix for Windows: Complain and quit cleanly when agent socket already exists. - Embed binary signer in repo. This enables `go install` as install method. - `--version` now also outputs version of embedded device app. - Builds releases and OS packages with [goreleaser](https://goreleaser.com/). - [tkey-device-signer](https://github.com/tillitis/tkey-device-signer) has been updated to v1.0.0. WARNING: Breaks CDI! Generates new key pair. - [tkeyclient](https://github.com/tillitis/tkeyclient) has been updated to v1.0.0. - [tkeysign](https://github.com/tillitis/tkeysign) has been updated to v1.0.0. Full [changelog](https://github.com/tillitis/tkey-ssh-agent/compare/v0.0.6...v1.0.0). ## v0.0.6 - Change maximum frame length back to 128 bytes. ## v0.0.5 - Update largest frame size to follow change in firmware - breaks CDI! - Firmware now loads app at the start of RAM, so we adjust our linker script and C runtime to init the stack to begin just below the end of RAM. - This breaks CDI, changing app hash of all apps! - Make apps use a steady LED color when waiting for a command, flashing only to draw attention (currently only when signer-app requires touching). - breaking CDI of signer app (changing hash of modified apps) - Let apps respond with status Not OK in header if they receive a command meant for firmware - breaks CDI! ## v0.0.4 - tkey-ssh-agent now connects to the TKey for each SSH agent operation (and disconnects afterwards with a delay). The serial port is thus left accessible to others. The udev rule that sent SIGHUP to tkey-ssh-agent upon insert/remove of TKey is no longer needed, and tkey-ssh-agent does nothing upon receiving a SIGHUP. ## v0.0.3 - Update tk1_mem.h and timer app to the revised timer MMIO API ## v0.0.2 We forgot to add the release here when tagging for https://github.com/tillitis/tillitis-key1-apps/releases/tag/v0.0.2 Notable changes: - Make monocypher a library - breaks CDI! - Remove GET_UDI from signer app, and the use of it - breaks CDI! ## v0.0.1 Since we haven't tagged any release before this we list some recent significant and/or breaking changes. ### Revised SSH Agent Introduces a revised Tillitis TKey SSH Agent, `tkey-ssh-agent`. The new agent: - runs as a daemon all the time (as `systemd` user unit, if you want). - autodetects TKey removal and insertion with the help of `udev` rules (or just send it a `SIGHUP` yourself to make it look for a TKey again). - spawns a graphical `pinentry` program to enter the User-Supplied Secret. The first iteration of this revision of the SSH agent is focused on Linux distributions and has a Ubuntu/Debian package available. ### Simplified firmware protocol The firmware protocol for loading a TKey app has changed. We now combine starting to load an app by setting size and loading USS into a single request. The firmware automatically returns the app digest and start the app when the last chunk of the binary has been received. `GetNameVersion` also now expects an ASCII array for `NAME0` and `NAME1` both from the firmware and from TKey apps. This also means the `signerapp` has a new digest and hence a new identity. ### Division no longer available We now build the TKey apps with the RV32 Zmmul extension since we removed support for division on the PicoRV32 CPU. tkey-ssh-agent-1.0.0+ds/go.mod000066400000000000000000000035431471561636600161070ustar00rootroot00000000000000module github.com/tillitis/tkey-ssh-agent go 1.19 require ( github.com/Microsoft/go-winio v0.6.1 github.com/apenwarr/fixconsole v0.0.0-20191012055117-5a9f6489cc29 github.com/getlantern/systray v1.2.1 github.com/spf13/pflag v1.0.5 github.com/tawesoft/golib/v2 v2.9.0 github.com/tillitis/tkeyclient v1.0.0 github.com/tillitis/tkeysign v1.0.0 github.com/tillitis/tkeyutil v0.0.7 github.com/twpayne/go-pinentry-minimal v0.0.0-20220113210447-2a5dc4396c2a golang.org/x/crypto v0.22.0 ) require ( github.com/alessio/shellescape v1.4.1 // indirect github.com/apenwarr/w32 v0.0.0-20190407065021-aa00fece76ab // indirect github.com/creack/goselect v0.1.2 // indirect github.com/gen2brain/beeep v0.0.0-20230907135156-1a38885a97fc // indirect github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect github.com/go-stack/stack v1.8.0 // indirect github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect go.bug.st/serial v1.6.2 // indirect golang.org/x/exp v0.0.0-20221208152030-732eee02a75a // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.16.0 // indirect ) tkey-ssh-agent-1.0.0+ds/go.sum000066400000000000000000000164371471561636600161420ustar00rootroot00000000000000github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/apenwarr/fixconsole v0.0.0-20191012055117-5a9f6489cc29 h1:muXWUcay7DDy1/hEQWrYlBy+g0EuwT70sBHg65SeUc4= github.com/apenwarr/fixconsole v0.0.0-20191012055117-5a9f6489cc29/go.mod h1:JYWahgHer+Z2xbsgHPtaDYVWzeHDminu+YIBWkxpCAY= github.com/apenwarr/w32 v0.0.0-20190407065021-aa00fece76ab h1:CMGzRRCjnD50RjUFSArBLuCxiDvdp7b8YPAcikBEQ+k= github.com/apenwarr/w32 v0.0.0-20190407065021-aa00fece76ab/go.mod h1:nfFtvHn2Hgs9G1u0/J6LHQv//EksNC+7G8vXmd1VTJ8= github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0= github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/gen2brain/beeep v0.0.0-20230907135156-1a38885a97fc h1:NNgdMgPX3j33uEAoVVxNxillDPnxT0xbGv8uh4CKIAo= github.com/gen2brain/beeep v0.0.0-20230907135156-1a38885a97fc/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4= github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4= github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY= github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So= github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A= github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 h1:guBYzEaLz0Vfc/jv0czrr2z7qyzTOGC9hiQ0VC+hKjk= github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7/go.mod h1:zx/1xUUeYPy3Pcmet8OSXLbF47l+3y6hIPpyLWoR9oc= github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0= github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o= github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc= github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA= github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA= github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= github.com/getlantern/systray v1.2.1 h1:udsC2k98v2hN359VTFShuQW6GGprRprw6kD6539JikI= github.com/getlantern/systray v1.2.1/go.mod h1:AecygODWIsBquJCJFop8MEQcJbWFfw/1yWbVabNgpCM= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= github.com/tawesoft/golib/v2 v2.9.0 h1:R84RNHs+A8UYuRVlLKVpb3Xzp1bvyP2qgAAZQ/ZRXfA= github.com/tawesoft/golib/v2 v2.9.0/go.mod h1:jGw0nDuOLpji2TW5QfSQLcWnZ4WtS4TizzRuXu3hZ/Y= github.com/tillitis/tkeyclient v1.0.0 h1:Ox9mEwxon9SRUconYZXrcqrm0YxpMCblMZLPXzPtKro= github.com/tillitis/tkeyclient v1.0.0/go.mod h1:dg2fyhB6szX7n1QIf19WcWtl/ueBPQYVlTCjY/kG5pM= github.com/tillitis/tkeysign v1.0.0 h1:qB4UZQzIRsEsQg1hLZE1bhQmk37O4c2qTStn5CAuhlg= github.com/tillitis/tkeysign v1.0.0/go.mod h1:7byJbKOEwCjCcUT9lw8WARl+0xO1fFrq+QMJc4MYiqA= github.com/tillitis/tkeyutil v0.0.7 h1:+QE4hvthUextFDiLt8Ssxffyn0FPNwDcloahS0sPSQU= github.com/tillitis/tkeyutil v0.0.7/go.mod h1:KI+trqptqoe+7hQaryBxgRENZPb24NrPlLexIFd/dFU= github.com/twpayne/go-pinentry-minimal v0.0.0-20220113210447-2a5dc4396c2a h1:a1bRrtgkiv0tytmDVXU5Dqse/WOTws7JvsY2WxPMZ6M= github.com/twpayne/go-pinentry-minimal v0.0.0-20220113210447-2a5dc4396c2a/go.mod h1:ARJJXqNuaxVS84jX6ST52hQh0TtuQZWABhTe95a6BI4= go.bug.st/serial v1.6.2 h1:kn9LRX3sdm+WxWKufMlIRndwGfPWsH1/9lCWXQCasq8= go.bug.st/serial v1.6.2/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20221208152030-732eee02a75a h1:4iLhBPcpqFmylhnkbY3W0ONLUYYkDAW9xMFLfxgsvCw= golang.org/x/exp v0.0.0-20221208152030-732eee02a75a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= tkey-ssh-agent-1.0.0+ds/gon.hcl000066400000000000000000000004451471561636600162520ustar00rootroot00000000000000 source = ["dist/tkey-ssh-agent_darwin_all/tkey-ssh-agent"] bundle_id = "com.tillitis.tkey-ssh-agent" apple_id { username = "[email protected]" password = "@keychain:[email protected]" provider = "34722S433A" } sign { application_identity = "Developer ID Application: Tillitis AB" } tkey-ssh-agent-1.0.0+ds/gotools/000077500000000000000000000000001471561636600164625ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/gotools/Makefile000066400000000000000000000002571471561636600201260ustar00rootroot00000000000000# .PHONY to let go-build handle deps and rebuilds .PHONY: go-winres go-winres: go mod download github.com/tc-hib/go-winres go mod tidy go build github.com/tc-hib/go-winres tkey-ssh-agent-1.0.0+ds/gotools/go.mod000066400000000000000000000006411471561636600175710ustar00rootroot00000000000000module gotools go 1.20 require github.com/tc-hib/go-winres v0.3.1 require ( github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/tc-hib/winres v0.1.6 // indirect github.com/urfave/cli/v2 v2.3.0 // indirect golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect ) tkey-ssh-agent-1.0.0+ds/gotools/go.sum000066400000000000000000000042141471561636600176160ustar00rootroot00000000000000github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/tc-hib/go-winres v0.3.1 h1:9r67V7Ep34yyx8SL716BzcKePRvEBOjan47SmMnxEdE= github.com/tc-hib/go-winres v0.3.1/go.mod h1:lTPf0MW3eu6rmvMyLrPXSy6xsSz4t5dRxB7dc5YFP6k= github.com/tc-hib/winres v0.1.6 h1:qgsYHze+BxQPEYilxIz/KCQGaClvI2+yLBAZs+3+0B8= github.com/tc-hib/winres v0.1.6/go.mod h1:pe6dOR40VOrGz8PkzreVKNvEKnlE8t4yR8A8naL+t7A= github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk= golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= tkey-ssh-agent-1.0.0+ds/gotools/gotools.go000066400000000000000000000002511471561636600204750ustar00rootroot00000000000000// Copyright (C) 2022, 2023 - Tillitis AB // SPDX-License-Identifier: GPL-2.0-only package gotools import ( // Import tools we use _ "github.com/tc-hib/go-winres" ) tkey-ssh-agent-1.0.0+ds/system/000077500000000000000000000000001471561636600163205ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/system/60-tkey.rules000066400000000000000000000004501471561636600205720ustar00rootroot00000000000000# Mark Tillitis TKey as a security token. /usr/lib/udev/rules.d/70-uaccess.rules # will add TAG "uaccess", which will result in file ACLs so that local user # (see loginctl) can read/write to the serial port in /dev. ATTRS{idVendor}=="1207", ATTRS{idProduct}=="8887",\ ENV{ID_SECURITY_TOKEN}="1" tkey-ssh-agent-1.0.0+ds/system/copyright000066400000000000000000000002001471561636600202430ustar00rootroot00000000000000Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * Copyright: 2024 Tillitis AB License: GPL-2 tkey-ssh-agent-1.0.0+ds/system/postinst000077500000000000000000000003501471561636600201270ustar00rootroot00000000000000#!/bin/sh set -e case "$1" in configure) if udevadm --version >/dev/null; then udevadm control --reload || true udevadm trigger --action=add --subsystem-match=tty || true fi ;; esac tkey-ssh-agent-1.0.0+ds/system/tkey-ssh-agent.1000066400000000000000000000143241471561636600212510ustar00rootroot00000000000000.Dd $Mdocdate$ .Dt tkey-ssh-agent 1 .Os .Sh NAME .Nm tkey-ssh-agent .Nd An SSH agent backed by Tillitis TKey .\" .Sh LIBRARY .\" For sections 2, 3, and 9 only. .Sh SYNOPSIS .Nm .Op Fl L | -list-ports .Op Fl a | -agent-path Ar path .Op Fl -help .Op Fl p | -show-pubkey .Op Fl -pinentry Ar command .Op Fl -port Ar path .Op Fl -speed Ar bit_speed .Op Fl -uss .Op Fl -uss-file Ar path .Op Fl -version .Sh DESCRIPTION .Nm is an alternative SSH agent backed by an Ed25519 signer device-app which it uploads to the Tillitis TKey, a small computer in the form of a USB stick. .Pp It works as an OpenSSH-compatible agent for all SSH programs, supporting a necessary subset of the OpenSSH agent protocol. You can use it to login to other systems or to sign Git commits, for example. Your ephemeral private key never leaves the TKey. .Pp The act of uploading the signer app, with an optional User Supplied Secret, creates a new unique, stable but ephemeral identity for that specific combination of TKey, signer app binary, and USS. .Pp The options are as follows: .Bl -tag -width Ds .It Fl L | -list-ports List possible serial ports to use with .Fl -port and exit. .It Fl a | -agent-path Ar path Bind the agent to the .Ux Ns -domain socket at path. .It Fl -help Output help text and exit. .It Fl p | -show-pubkey Extract the ssh-ed25519 public key from the TKey and exit. .It Fl -pinentry Ar command Specify pinentry command for use by .Fl -uss . The default is found by looking in your gpg-agent.conf for pinentry-program. If this is not found, the .Xr pinentry 1 command is used. .It Fl -port Ar path Set serial port device path. If this is not set, auto-detection will be attempted. .It Fl -speed Ar bit_speed Set serial port speed in bits per second. Default is 62500 b/s. .It Fl -uss Interactively ask for a secret to be hashed as the User Supplied Secret. The USS is loaded onto the TKey along with the signer. A different USS results in a different pair of SSH public/private keys. .It Fl -uss-file Ar path Read a secret from a file path and hash its contents as the User Supplied Secret to be mixed into the TKey identity. Use '-' (dash) to read from stdin. The full contents are hashed unmodified (i.e. newlines are not stripped). .It Fl -version Output version information. .El .Ss User Supplied Secret .Pp You are encouraged to run .Nm with .Fl -uss , meaning that when the signer app is loaded onto the TKey, a User Supplied Secret (USS) is loaded as well. In short, changing the USS results in a different SSH ed25519 key, a new identity. The USS is input interactively using a .Xr pinentry 1 command, see the .Fl -uss option for more information. If not run with .Fl -uss , the TKey/signer combination will have a single identity. .Ss systemd-based systems With the source code we provide a systemd unit file that can be used to automatically start the .Nm when a user logs in. If this unit file is installed (for instance with a package for your operating system) you can run the following (as your own user) to start the agent right now and enable it for future logins: .Bd -literal $ systemctl --user enable --now tkey-ssh-agent .Ed .\" .Sh CONTEXT .\" For section 9 functions only. .\" .Sh IMPLEMENTATION NOTES .\" .Sh RETURN VALUES .\" For sections 2, 3, and 9 function return values only. .Sh ENVIRONMENT .\" For sections 1, 6, 7, and 8 only. To make .Xr ssh 1 , .Xr ssh-add 1 and other tools use .Nm you must set the .Sy SSH_AUTH_SOCK environment variable for them, so they can find and communicate with the SSH agent. For your current shell this can be done like this (bash/zsh): .Bd -literal export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/tkey-ssh-agent/sock" .Ed .Pp This line can also be added to the startup file for your shell, e.g. in .Sy .bashrc. This would make all tools that honour .Sy SSH_AUTH_SOCK use .Nm . .Pp With .Sy SSH_AUTH_SOCK correctly set you can see the current SSH ed25519 public key by running: .Bd -literal $ ssh-add -L .Ed .Sh FILES .Nm does not have a configuration file. .Pp You might, however, want to configure ssh(1) to use a specific SSH agent ("IdentityAgent") depending on the host you want to access. Add the following to .Sy ~/.ssh/config to make it use .Nm when connecting to "example.com": .Bd -literal Host example.com IdentityAgent ${XDG_RUNTIME_DIR}/tkey-ssh-agent/sock .Ed .Pp Or use .Nm for all hosts except "example.com": .Bd -literal Host example.com IdentityAgent $SSH_AUTH_SOCK Host * IdentityAgent ${XDG_RUNTIME_DIR}/tkey-ssh-agent/sock .Ed .\" .Sh EXIT STATUS .\" For sections 1, 6, and 8 only. .Sh EXAMPLES .Pp Running manually against a TKey with automatic port detection and interatively ask for the User Supplied Secret: .Bd -literal $ tkey-ssh-agent -a ./agent.sock --uss .Ed .Pp Running manually against qemu (look when qemu is starting what device it uses) and interactively ask for the User Supplied Secret: .Bd -literal $ tkey-ssh-agent -a ./agent.sock --port /dev/pts/1 --uss .Ed .Pp Ask the agent about the TKey public key: .Bd -literal $ SSH_AUTH_SOCK=./agent.sock ssh-add -L .Ed .Pp Login to .Sy localhost using the agent (copy the public key to ~/.ssh/authorized_key first): .Bd -literal $ SSH_AUTH_SOCK=./agent.sock ssh -F /dev/null localhost .Ed .\" .Sh DIAGNOSTICS .\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only. .\" .Sh ERRORS .\" For sections 2, 3, 4, and 9 errno settings only. .Sh SEE ALSO .Xr ssh 1 .Xr ssh-add 1 .Xr ssh-agent 1 .Sh STANDARDS .Nm attempts to follow a subset of the OpenSSH Agent protocol. It doesn't do anything on calls to add/remove keys, or to lock/unlock it with a passphrase. .\" .Sh HISTORY .Sh AUTHORS Tillitis AB, https://tillitis.se/ .Sh CAVEATS .Pp The .Nm only connects to the TKey when an SSH agent operation is requested (e.g. when you attempt to log in somewhere or request the public key) and disconnects soon afterwards. If the signer app is not already running on the TKey it is first uploaded to the TKey and started. .Pp This means that it will only ask for the User Supplied Secret (if started using the .Fl -uss flag) when the agent is actually requested to do something for the first time, not when the TKey is inserted, as the user perhaps expected. The reason is that the .Nm shouldn't hog the device and let other client apps also be able to speak to it. .\" .Sh BUGS .\" .Sh SECURITY CONSIDERATIONS tkey-ssh-agent-1.0.0+ds/system/tkey-ssh-agent.service000066400000000000000000000012501471561636600225430ustar00rootroot00000000000000[Unit] Description=An SSH agent backed by Tillitis TKey Documentation=https://github.com/tillitis/tkey-ssh-agent [Service] ExecStart=/usr/bin/tkey-ssh-agent --uss --agent-path /%t/tkey-ssh-agent/sock ExecReload=/usr/bin/kill -HUP $MAINPID NoNewPrivileges=yes KeyringMode=private UMask=0177 ProtectSystem=strict RuntimeDirectory=tkey-ssh-agent RuntimeDirectoryMode=0700 ReadWritePaths=/dev /run RestrictAddressFamilies=AF_UNIX RestrictNamespaces=yes RestrictRealtime=yes RestrictSUIDSGID=yes LockPersonality=yes SystemCallFilter=@system-service SystemCallFilter=~@privileged @resources SystemCallErrorNumber=EPERM SystemCallArchitectures=native [Install] WantedBy=default.target tkey-ssh-agent-1.0.0+ds/system/tkey-ssh-agent.service.tmpl000066400000000000000000000012561471561636600235240ustar00rootroot00000000000000[Unit] Description=An SSH agent backed by Tillitis TKey Documentation=https://github.com/tillitis/tillitis-key1-apps [Service] ExecStart=##BINDIR##/tkey-ssh-agent --uss --agent-path /%t/tkey-ssh-agent/sock ExecReload=/usr/bin/kill -HUP $MAINPID NoNewPrivileges=yes KeyringMode=private UMask=0177 ProtectSystem=strict RuntimeDirectory=tkey-ssh-agent RuntimeDirectoryMode=0700 ReadWritePaths=/dev /run RestrictAddressFamilies=AF_UNIX RestrictNamespaces=yes RestrictRealtime=yes RestrictSUIDSGID=yes LockPersonality=yes SystemCallFilter=@system-service SystemCallFilter=~@privileged @resources SystemCallErrorNumber=EPERM SystemCallArchitectures=native [Install] WantedBy=default.target tkey-ssh-agent-1.0.0+ds/system/windows/000077500000000000000000000000001471561636600200125ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/system/windows/Dockerfile000066400000000000000000000023351471561636600220070ustar00rootroot00000000000000FROM docker.io/library/ubuntu:22.10 ENV WINEARCH=win32 RUN DEBIAN_FRONTEND=noninteractive \ dpkg --add-architecture i386 \ && apt-get update && apt-get install --no-install-recommends -y \ ca-certificates \ apt-transport-https \ lsb-release \ curl \ unzip \ && mkdir -p /etc/apt/keyrings \ && curl -L -o /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key \ && curl -L --output-dir /etc/apt/sources.list.d/ -O "https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -cs)/winehq-$(lsb_release -cs).sources" \ && apt-get update && apt-get install --no-install-recommends -y \ winehq-stable \ && rm -rf /var/lib/apt/lists/* RUN curl -L --output-dir / -O https://github.com/Winetricks/winetricks/archive/refs/tags/20230212.tar.gz \ && tar xa -C / -f 20230212.tar.gz \ && cp -af /winetricks-20230212/src/winetricks /usr/local/bin/ RUN curl -L -o /wix.zip https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip \ && unzip -d /usr/local/wix /wix.zip \ && rm -f /wix.zip RUN /usr/local/bin/winetricks --unattended dotnet40 \ && rm -rf /tmp/.wine-* /tmp/winetricks* COPY build-msi.sh /usr/local/bin/ tkey-ssh-agent-1.0.0+ds/system/windows/LICENSE.rtf000066400000000000000000000377651471561636600216330ustar00rootroot00000000000000{\rtf1\ansi\deff0\nouicompat\deflang8192\deflangfe8192{\fonttbl{\f0\fmodern\fprq1\fcharset0 Courier New;}} {\*\generator Riched20 10.0.22000}{\*\mmathPr\mnaryLim0\mdispDef1\mwrapIndent1440 }\viewkind4\uc1 \pard\widctlpar\kerning2\f0\fs21\lang1033 GNU GENERAL PUBLIC LICENSE\par \par Version 2, June 1991 \par \par \par Copyright (C) 1989, 1991 Free Software Foundation, Inc. \par 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\par \par Everyone is permitted to copy and distribute verbatim copies\par of this license document, but changing it is not allowed.\par \par \par Preamble\par \par The licenses for most software are designed to take away your freedom to share and\par change it. By contrast, the GNU General Public License is intended to guarantee your\par freedom to share and change free software--to make sure the software is free for all\par its users. This General Public License applies to most of the Free Software\par Foundation's software and to any other program whose authors commit to using it.\par (Some other Free Software Foundation software is covered by the GNU Lesser General\par Public License instead.) You can apply it to your programs, too. \par \par When we speak of free software, we are referring to freedom, not price. Our General\par Public Licenses are designed to make sure that you have the freedom to distribute\par copies of free software (and charge for this service if you wish), that you receive\par source code or can get it if you want it, that you can change the software or use\par pieces of it in new free programs; and that you know you can do these things. \par \par To protect your rights, we need to make restrictions that forbid anyone to deny you\par these rights or to ask you to surrender the rights. These restrictions translate to\par certain responsibilities for you if you distribute copies of the software, or if you\par modify it. \par \par For example, if you distribute copies of such a program, whether gratis or for a\par fee, you must give the recipients all the rights that you have. You must make sure\par that they, too, receive or can get the source code. And you must show them these\par terms so they know their rights. \par \par We protect your rights with two steps: (1) copyright the software, and (2) offer you\par this license which gives you legal permission to copy, distribute and/or modify the\par software. \par \par Also, for each author's protection and ours, we want to make certain that everyone\par understands that there is no warranty for this free software. If the software is\par modified by someone else and passed on, we want its recipients to know that what\par they have is not the original, so that any problems introduced by others will not\par reflect on the original authors' reputations. \par \par Finally, any free program is threatened constantly by software patents. We wish to\par avoid the danger that redistributors of a free program will individually obtain\par patent licenses, in effect making the program proprietary. To prevent this, we have\par made it clear that any patent must be licensed for everyone's free use or not\par licensed at all. \par \par The precise terms and conditions for copying, distribution and modification follow. \par \par TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\par \par 0. This License applies to any program or other work which contains a notice placed\par by the copyright holder saying it may be distributed under the terms of this General\par Public License. The "Program", below, refers to any such program or work, and a\par "work based on the Program" means either the Program or any derivative work under\par copyright law: that is to say, a work containing the Program or a portion of it,\par either verbatim or with modifications and/or translated into another language.\par (Hereinafter, translation is included without limitation in the term\par "modification".) Each licensee is addressed as "you". \par \par Activities other than copying, distribution and modification are not covered by this\par License; they are outside its scope. The act of running the Program is not\par restricted, and the output from the Program is covered only if its contents\par constitute a work based on the Program (independent of having been made by running\par the Program). Whether that is true depends on what the Program does. \par \par 1. You may copy and distribute verbatim copies of the Program's source code as you\par receive it, in any medium, provided that you conspicuously and appropriately publish\par on each copy an appropriate copyright notice and disclaimer of warranty; keep intact\par all the notices that refer to this License and to the absence of any warranty; and\par give any other recipients of the Program a copy of this License along with the\par Program. \par \par You may charge a fee for the physical act of transferring a copy, and you may at\par your option offer warranty protection in exchange for a fee. \par \par 2. You may modify your copy or copies of the Program or any portion of it, thus\par forming a work based on the Program, and copy and distribute such modifications or\par work under the terms of Section 1 above, provided that you also meet all of these\par conditions: \par \par a) You must cause the modified files to carry prominent notices stating that you\par changed the files and the date of any change. \par b) You must cause any work that you distribute or publish, that in whole or in\par part contains or is derived from the Program or any part thereof, to be licensed\par as a whole at no charge to all third parties under the terms of this License. \par c) If the modified program normally reads commands interactively when run, you\par must cause it, when started running for such interactive use in the most\par ordinary way, to print or display an announcement including an appropriate\par copyright notice and a notice that there is no warranty (or else, saying that\par you provide a warranty) and that users may redistribute the program under these\par conditions, and telling the user how to view a copy of this License. (Exception:\par if the Program itself is interactive but does not normally print such an\par announcement, your work based on the Program is not required to print an\par announcement.) \par \par These requirements apply to the modified work as a whole. If identifiable sections\par of that work are not derived from the Program, and can be reasonably considered\par independent and separate works in themselves, then this License, and its terms, do\par not apply to those sections when you distribute them as separate works. But when you\par distribute the same sections as part of a whole which is a work based on the\par Program, the distribution of the whole must be on the terms of this License, whose\par permissions for other licensees extend to the entire whole, and thus to each and\par every part regardless of who wrote it. \par \par Thus, it is not the intent of this section to claim rights or contest your rights to\par work written entirely by you; rather, the intent is to exercise the right to control\par the distribution of derivative or collective works based on the Program. \par \par In addition, mere aggregation of another work not based on the Program with the\par Program (or with a work based on the Program) on a volume of a storage or\par distribution medium does not bring the other work under the scope of this License. \par \par 3. You may copy and distribute the Program (or a work based on it, under Section 2)\par in object code or executable form under the terms of Sections 1 and 2 above provided\par that you also do one of the following: \par \par a) Accompany it with the complete corresponding machine-readable source code,\par which must be distributed under the terms of Sections 1 and 2 above on a medium\par customarily used for software interchange; or, \par b) Accompany it with a written offer, valid for at least three years, to give\par any third party, for a charge no more than your cost of physically performing\par source distribution, a complete machine-readable copy of the corresponding\par source code, to be distributed under the terms of Sections 1 and 2 above on a\par medium customarily used for software interchange; or, \par c) Accompany it with the information you received as to the offer to distribute\par corresponding source code. (This alternative is allowed only for noncommercial\par distribution and only if you received the program in object code or executable\par form with such an offer, in accord with Subsection b above.) \par \par The source code for a work means the preferred form of the work for making\par modifications to it. For an executable work, complete source code means all the\par source code for all modules it contains, plus any associated interface definition\par files, plus the scripts used to control compilation and installation of the\par executable. However, as a special exception, the source code distributed need not\par include anything that is normally distributed (in either source or binary form) with\par the major components (compiler, kernel, and so on) of the operating system on which\par the executable runs, unless that component itself accompanies the executable. \par \par If distribution of executable or object code is made by offering access to copy from\par a designated place, then offering equivalent access to copy the source code from the\par same place counts as distribution of the source code, even though third parties are\par not compelled to copy the source along with the object code. \par \par 4. You may not copy, modify, sublicense, or distribute the Program except as\par expressly provided under this License. Any attempt otherwise to copy, modify,\par sublicense or distribute the Program is void, and will automatically terminate your\par rights under this License. However, parties who have received copies, or rights,\par from you under this License will not have their licenses terminated so long as such\par parties remain in full compliance. \par \par 5. You are not required to accept this License, since you have not signed it.\par However, nothing else grants you permission to modify or distribute the Program or\par its derivative works. These actions are prohibited by law if you do not accept this\par License. Therefore, by modifying or distributing the Program (or any work based on\par the Program), you indicate your acceptance of this License to do so, and all its\par terms and conditions for copying, distributing or modifying the Program or works\par based on it. \par \par 6. Each time you redistribute the Program (or any work based on the Program), the\par recipient automatically receives a license from the original licensor to copy,\par distribute or modify the Program subject to these terms and conditions. You may not\par impose any further restrictions on the recipients' exercise of the rights granted\par herein. You are not responsible for enforcing compliance by third parties to this\par License. \par \par 7. If, as a consequence of a court judgment or allegation of patent infringement or\par for any other reason (not limited to patent issues), conditions are imposed on you\par (whether by court order, agreement or otherwise) that contradict the conditions of\par this License, they do not excuse you from the conditions of this License. If you\par cannot distribute so as to satisfy simultaneously your obligations under this\par License and any other pertinent obligations, then as a consequence you may not\par distribute the Program at all. For example, if a patent license would not permit\par royalty-free redistribution of the Program by all those who receive copies directly\par or indirectly through you, then the only way you could satisfy both it and this\par License would be to refrain entirely from distribution of the Program. \par \par If any portion of this section is held invalid or unenforceable under any particular\par circumstance, the balance of the section is intended to apply and the section as a\par whole is intended to apply in other circumstances. \par \par It is not the purpose of this section to induce you to infringe any patents or other\par property right claims or to contest validity of any such claims; this section has\par the sole purpose of protecting the integrity of the free software distribution\par system, which is implemented by public license practices. Many people have made\par generous contributions to the wide range of software distributed through that system\par in reliance on consistent application of that system; it is up to the author/donor\par to decide if he or she is willing to distribute software through any other system\par and a licensee cannot impose that choice. \par \par This section is intended to make thoroughly clear what is believed to be a\par consequence of the rest of this License. \par \par 8. If the distribution and/or use of the Program is restricted in certain countries\par either by patents or by copyrighted interfaces, the original copyright holder who\par places the Program under this License may add an explicit geographical distribution\par limitation excluding those countries, so that distribution is permitted only in or\par among countries not thus excluded. In such case, this License incorporates the\par limitation as if written in the body of this License. \par \par 9. The Free Software Foundation may publish revised and/or new versions of the\par General Public License from time to time. Such new versions will be similar in\par spirit to the present version, but may differ in detail to address new problems or\par concerns. \par \par Each version is given a distinguishing version number. If the Program specifies a\par version number of this License which applies to it and "any later version", you have\par the option of following the terms and conditions either of that version or of any\par later version published by the Free Software Foundation. If the Program does not\par specify a version number of this License, you may choose any version ever published\par by the Free Software Foundation. \par \par 10. If you wish to incorporate parts of the Program into other free programs whose\par distribution conditions are different, write to the author to ask for permission.\par For software which is copyrighted by the Free Software Foundation, write to the Free\par Software Foundation; we sometimes make exceptions for this. Our decision will be\par guided by the two goals of preserving the free status of all derivatives of our free\par software and of promoting the sharing and reuse of software generally. \par \par NO WARRANTY\par \par 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE\par PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN\par WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"\par WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT\par LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\par PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH\par YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY\par SERVICING, REPAIR OR CORRECTION. \par \par 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY\par COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM\par AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,\par INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\par PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE\par OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE\par WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\par POSSIBILITY OF SUCH DAMAGES. \par \par } tkey-ssh-agent-1.0.0+ds/system/windows/Makefile000066400000000000000000000010601471561636600214470ustar00rootroot00000000000000 .PHONY: msi msi: @[ -n "$$SEMVER" ] || { printf "Run like: make SEMVER=0.0.6 msi\n"; false; } podman run --rm -it --mount type=bind,source=$$(pwd),target=/build -w /build \ ghcr.io/tillitis/msi-builder:1 \ build-msi.sh "$$SEMVER" tkey-ssh-agent.wxs ls -l *.msi .PHONY: exes exes: make -C ../../ windows cp -af ../../tkey-ssh-agent{,-tray}.exe . .PHONY: build-msi-builder build-msi-builder: podman build -f Dockerfile -t msi-builder .PHONY: clean clean: rm -f tkey-ssh-agent{,-tray}.exe \ tkey-ssh-agent-*.{msi,wixpdb} tkey-ssh-agent.wixobj tkey-ssh-agent-1.0.0+ds/system/windows/README.md000066400000000000000000000054171471561636600213000ustar00rootroot00000000000000 # Using Wix on Windows to build the MSI package The following might be missing something, please revise. - You probably want to be on a tagged version of the apps repo. - In the root of the apps repo, build the windows exes and place the resulting exes in this directory. I guess this currently only works on Linux. ``` make windows ``` The [Makefile](Makefile) in this directory has a target `exes` that does the build and copying. - Install Wix 3: - Install the required .NET 3.5: - Go to `Control Panel » Programs and Features » Turn Windows features on or off` - Tick `.NET Framework 3.5 …` (and the sub headings), and let it install. - Download and install: https://github.com/wixtoolset/wix3/releases/tag/wix3112rtm - Open a terminal in this directory. We have a script that builds the msi using Wix candle & light tools. The script takes the version number of the package that it should produce. We shall pass the typical tagged version, and a 4th digit (0) will be added, per windows convention. ``` ./build-msi.bat 0.0.6 ``` - You can try installing the msi with: ``` msiexec /i tkey-ssh-agent-0.0.6.0.msi` ``` # Running Wix using Wine in a container on Linux You can first build the windows exes and copy them here, and then build the msi with a specific version like this: ``` make exes make SEMVER=0.0.6 msi ``` This uses the `ghcr.io/tillitis/msi-builder:1` image, which can be built locally using the Makefile's `build-msi-builder` target. # Notes We do not enable the agent to run automatically at startup, leaving this to the decision of the user. But we do install a shortcut in the folder for "All Users Start Menu Programs", so it ends up on the user's Start Menu (in `TKey SSH Agent\TKey SSH Agent`). Running this shortcut starts the tray executable with our default arguments `--uss -a tkey-ssh-agent`. User can copy this shortcut to their "Startup" folder, as described in [this article](https://support.microsoft.com/en-us/windows/add-an-app-to-run-automatically-at-startup-in-windows-10-150da165-dcd9-7230-517b-cf3c295d89dd). Or by running the following PowerShell commands: ```PowerShell $w = new-object -comobject wscript.shell $prgs = $w.specialfolders('allusersprograms') $startup = $w.specialfolders('startup') copy "$prgs\TKey SSH Agent\TKey SSH Agent.lnk" "$startup\" ``` Also, the default configuration relies on finding a `pinentry` program from the Gpg4win package. It can be installed by running `winget install GnuPG.Gpg4win` manually. Note that winget does not have support for dependencies that are pulled in automatically. But since the msi package will also be available as a winget package, this dependency seems fine. tkey-ssh-agent-1.0.0+ds/system/windows/build-msi.bat000066400000000000000000000010001471561636600223560ustar00rootroot00000000000000@echo off set "SEMVER=%~1" if "%SEMVER%"=="" ( echo Please pass a version number to build as, like: 0.0.6 echo This is our typical tagged version. We will make the echo actual version 0.0.6.0 per windows convention. exit ) set SEMVER=%SEMVER%.0 echo Going to build: %SEMVER% set WIXPATH="C:\Program Files (x86)\WiX Toolset v3.11\bin" %WIXPATH%\candle.exe tkey-ssh-agent.wxs %WIXPATH%\light.exe -ext WixUIExtension ^ -o tkey-ssh-agent-%SEMVER%.msi ^ tkey-ssh-agent.wixobj tkey-ssh-agent-1.0.0+ds/system/windows/build-msi.sh000077500000000000000000000010341471561636600222340ustar00rootroot00000000000000#!/bin/bash set -e SEMVER="${1:-}" if [[ ! "$SEMVER" =~ ^(([1-9][0-9]*|0)\.){2}([1-9][0-9]*|0)$ ]]; then printf "Expected a semver in 1st arg, like: 0.0.6\n" exit 1 fi shift wxsf="${1:-}" if [[ ! -e "$wxsf" ]] || [[ ! "$wxsf" =~ \.wxs ]]; then printf "Expected a .wxs file in 2nd arg\n" exit 1 fi shift export SEMVER="$SEMVER.0" base="${wxsf%.wxs}" printf "Going to build: %s\n" "$SEMVER" wine /usr/local/wix/candle.exe "$wxsf" wine /usr/local/wix/light.exe -sval -ext WixUIExtension \ -o "$base-$SEMVER.msi" "$base.wixobj" tkey-ssh-agent-1.0.0+ds/system/windows/tillitis-ant.ico000066400000000000000000000302511471561636600231240ustar00rootroot00000000000000 0PNG  IHDR?1orNTϢw0MIDATxwT߷VX@)" (41ƒhM$j_{Io,5&&_{AT)*Uβ}{;+{w9׾^0ys'H$m$l" k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^l@8yN})atKR#%(di(-.$Lh* g`5Z \J6AV7fIH `ѫ3]ѥ]o"ztdd(l9 p CӲ}"#`p.C)ʶ5l"\gUi?p(!ffdx*6 Xya)&QA{AG @xqLG]bw@^P!pg{XK/(pc!$C q{F r)gH@Й< 2 H)βL+U5u :w">-#`ST0})#ܞCу-;%f 4Z|ؠI^(LddD~'7sS ռ g4D3(AB] `~5꣼0%O}kqЙ}t R^(eTRZdJ8e$ϽFƇy϶1X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#3[/hFO^fA|z%!j^P 1;C`%0|N).^I# zc ҂²/>,/u #ecٺ+_Fpx0ض!ӄ4i+/H|crV*"L]wC(]"%y;&_w4}zO2LM 5Ē EI>O;^w{Ab>onY^PK; /1b=;0zv O0M4L GC8٪ANȎهʈĒyAZU_^cpƘ| @4 =^1#hPӎ#H޵<,ٳa6f=Kv /8g ^EnY A܉3O{x#l*L./hmƒzf&U!G&u~m?qvcD,̉Ni4X]7gV'4\?5'\8N]*&ϽzA>%uܥxAM`ZJ^c&%LjWQxAo/m&hڸ6KצiA^Pgxy!$ +1Oor5O ΞlU%  \񂎣ysvi]Pi=?o.PzTAv tކ|N}ӈ[>{+ ue.xt{AJ 3Ƃkgglڌ\1yI8q8$mNY^RO?^ix kx8o9) z(Dt^\ьNQ Zk$'% ҸxAMn Fqư=NQ\]Y@8ă3kqFaW'ڟ2Rwе$6*Զpr]8~vg]ޱ]8[c /t :iDrڳH)J«9[( :s1&9KP X9_r5O kjWћb 1',/h5Fh%H?msl0t"y}^8ȅfxA3Ƙr( 1W>{}2Ş-G J;!%kݮs j OYG& x+c9 YjK"`:DcMl9ꔣ3$Wlb&C0;/Ȫb'df Psu/5@;m ꇐZ P 2&m/B&0Sj IhlzT^KI.nd(W͙5ii!}BeMԲ ذ5QYXb#ѱZ-:ݏ`&&m];#Krq˦0D4!>6ɋmi_Ϲim(a&+A*jAfG!lЭۦ(ˋkhn#m.h 7Jkx QCI.43mt%Y+m^q]Pb\qXv[IU0NJ$ " k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k$y$5RF @HH)I^# k?GFd~PIENDB`tkey-ssh-agent-1.0.0+ds/system/windows/tkey-ssh-agent.wxs000066400000000000000000000072761471561636600234340ustar00rootroot00000000000000 tkey-ssh-agent-1.0.0+ds/test/000077500000000000000000000000001471561636600157535ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/test/attic/000077500000000000000000000000001471561636600170575ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/test/attic/test-loop.sh000077500000000000000000000027711471561636600213530ustar00rootroot00000000000000#!/bin/bash set -eu # This script uses tkey-runapp to load a signer app which has been built with # the touch requirement removed. Then it runs tkey-sign forever, signing 512 # bytes of new random data on every iteration. # # The script expects that the TKey is in firmware mode, so it can load the # correct signer app. # # Arguments to this script will be passed to tkey-runapp and tkey-sign, so # --port and --speed can be used. # # If the environment variable USB_DEVICE is set, --port $USB_DEVICE is passed # to these programs. cd "${0%/*}/.." if [[ -e tkey-sign ]]; then if ! go version -m tkey-sign | grep -q main.signerAppNoTouch=indeed; then printf "We need to build with the touch requirement removed.\n" printf "Please first do: make -C ../ clean\n" exit 1 fi fi make TKEY_SIGNER_APP_NO_TOUCH=indeed -C apps make TKEY_SIGNER_APP_NO_TOUCH=indeed tkey-runapp tkey-sign if [[ -n "${USB_DEVICE:-}" ]]; then # Passing this last to make it override set -- "$@" --port "$USB_DEVICE" fi # We expect to load the app ourselves, exiting if we couldn't if ! ./tkey-runapp "$@" apps/signer/app.bin; then exit 1 fi msgf=$(mktemp) cleanup() { rm -f "$msgf" } trap cleanup EXIT c=0 start=$(date +%s) while true; do # 512 bytes becomes 1 msg with 511 bytes and 1 msg with 1 byte dd 2>/dev/null if=/dev/urandom of="$msgf" bs=512 count=1 if ! ./tkey-sign "$@" "$msgf"; then exit 1 fi c=$(( c+1 )) now=$(date +%s) printf "loop count: %d, seconds passed: %d\n" "$c" "$((now - start))" done tkey-ssh-agent-1.0.0+ds/test/requirements.txt000066400000000000000000000000161471561636600212340ustar00rootroot00000000000000pyserial==3.5 tkey-ssh-agent-1.0.0+ds/test/run000077500000000000000000000012471471561636600165110ustar00rootroot00000000000000#!/bin/sh set -eu cd "${0%/*}/.." if [ -e tkey-sign ]; then if ! go version -m tkey-sign | grep -q main.signerAppNoTouch=indeed; then printf "We need to build with the touch requirement removed.\n" printf "Please first do: make -C ../ clean\n" exit 1 fi fi if [ ! -e tkey-runapp ] || [ ! -e apps/signer/app.bin ] || [ ! -e tkey-sign ]; then make TKEY_SIGNER_APP_NO_TOUCH=indeed -C apps make TKEY_SIGNER_APP_NO_TOUCH=indeed tkey-runapp tkey-sign fi cd "test" if [ ! -e venv ]; then if ! python3 -m venv venv; then rm -rf venv exit 1 fi . ./venv/bin/activate pip3 install -r requirements.txt else . ./venv/bin/activate fi ./test-loop.py tkey-ssh-agent-1.0.0+ds/test/test-loop.py000077500000000000000000000076661471561636600202750ustar00rootroot00000000000000#!/usr/bin/env python3 import struct import serial import subprocess from random import randbytes from tempfile import NamedTemporaryFile from time import sleep class TK1: def __init__(self, port="/dev/ttyACM0"): self.dev = serial.Serial(port, 62500, timeout=0.1) # Bootloader command def getNameVersion(self): """Request the name and version information from the bootloader""" cmd = bytearray([0x50, 0x01]) # print(' '.join(['{:02x}'.format(i) for i in cmd])) self.dev.write(cmd) rsp = self.dev.read(1 + 32) # print(' '.join(['{:02x}'.format(i) for i in rsp])) assert rsp[0] == 0x52 assert rsp[1] == 0x02 response = {} response["name0"] = "".join([chr(i) for i in rsp[2:6]]) response["name1"] = "".join([chr(i) for i in rsp[6:10]]) response["version"] = int(rsp[10]) return response # Signer app def getPubKey(self): cmd = bytearray([0x58, 0x01]) # print(' '.join(['{:02x}'.format(i) for i in cmd])) self.dev.write(cmd) rsp = self.dev.read(1 + 128) # print(' '.join(['{:02x}'.format(i) for i in rsp])) assert rsp[0] == 0x5B assert rsp[1] == 0x02 return rsp[2:34] def inSignerApp(self): for i in range(0, 2): try: self.dev.write(bytes(128)) key = self.getPubKey() # print(','.join(['0x{:02x}'.format(i) for i in key])) # assert(key == bytearray([ # 0x67,0xb1,0x46,0x4a,0xa2,0x4f,0x65,0x93, # 0xfe,0x67,0x1e,0xc1,0x00,0xf3,0x0e,0x85, # 0x8c,0xdf,0x7f,0xbb,0x0b,0x46,0x86,0xbd, # 0xf9,0xca,0x47,0xb5,0xc6,0x48,0xba,0x0f # ])) return True except Exception: pass return False def inBootloader(self): for i in range(0, 2): try: response = self.getNameVersion() print(response, len(response['name1'])) assert(response['name0'] == 'tk1 ') assert(response['name1'] == 'mkdf') assert(response['version'] == 5) return True except Exception: pass return False def probe_state(): """Probe the TK1 to determine if it is running the bootloader or signer""" try: key = TK1() # First, probe for firmware with a getnameversion, then try to # read the public key If this is successful we assume the # signer app is loaded if key.inBootloader(): return "bootloader" if key.inSignerApp(): return "signer" except Exception: pass return "unknown" def load_signer_app(): try: result = subprocess.run( ["../tkey-runapp", "--port", "/dev/ttyACM0", "../apps/signer/app.bin"], timeout=10, ) except subprocess.TimeoutExpired: print("loader process timeout") def do_signature(): msgf = NamedTemporaryFile() msgf.write(randbytes(512)) msgf.flush() try: result = subprocess.run( ["../tkey-sign", "--port", "/dev/ttyACM0", msgf.name], timeout=1 ) except subprocess.TimeoutExpired: print("signature process timeout") def main(): stats = {"restarts": 0, "signatures": 0, "disconnects": 0} while True: state = probe_state() print("Detected key in state: " + state) if state == "bootloader": load_signer_app() sleep(2) # Give time for the app to start stats["restarts"] += 1 elif state == "signer": do_signature() stats["signatures"] += 1 else: print("Device in unknown state: reconnecting") stats["disconnects"] += 1 sleep(1) print(stats) if __name__ == "__main__": main() tkey-ssh-agent-1.0.0+ds/tillitis-ant.png000066400000000000000000000511161471561636600201230ustar00rootroot00000000000000PNG  IHDRxxi"`zTXtRaw profile type exifxmPQ ;*ǮmC]'uc䪥iҨ[䉪zW +EvAǴqa-#}݅&IFQ #&Rt; Ng(.l0јY%29A;d9 ߜZUariCCPICC profilex}=H@_HE""]TıVBЪɥ_Ф!Iqq\ ~,V\uupW'E)IExwq7L5 @,#J Bc39QLs|׻8>S &|qEA bSbKGDC]4 pHYsodtIMEs# IDATx]N[2: H@  XF -ONyjX082h/0._ tʼn9@K `;@/S@ 0)(|V (:f `R~h 0)'` Rvn2@ 0.3!<7co5hF$e}XQ& tG^V3'4ANF7` 0qͷ|`Zd_HN4@ |+W}pP/)h́mcx{ӯ̉87`ON4w2z\qXijhQnBc|N9b:*C._'vgjlB22gG`Lٵ!a SK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3(ǽ'sh`d@'|oO.;I 'sh`ē3 u"40u܁F `@;#1m<-P܄2wu F1B oO`;p[W#4 Fh{LW"4 Fh^ s#4 ,s8`{xYLv(;s"7Kv2w 6WeTdll#4ǫ]5~W`oB]-_AEޚ&4xzJh|+;6wKqBm bN1Ym{ ;؜2w:ONpOIDAT )>kIENDB`tkey-ssh-agent-1.0.0+ds/tools/000077500000000000000000000000001471561636600161345ustar00rootroot00000000000000tkey-ssh-agent-1.0.0+ds/tools/spdx-ensure000077500000000000000000000042101471561636600203340ustar00rootroot00000000000000#!/bin/bash set -eu # Check for the SPDX tag in all files in the repo. Exit with a non-zero code if # some is missing. The missingok arrays below contain files and directories # with files where the the tag is not required. cd "${0%/*}" cd .. tag="SPDX-License-Identifier:" missingok_dirs=( .github/workflows/ cmd/tkey-ssh-agent-tray/winres/ cmd/tkey-ssh-agent/winres/ docs/ system/windows/ ) missingok_files=( .editorconfig .gitignore .golangci.yml .goreleaser.yaml LICENSE Makefile README.md cmd/tkey-ssh-agent/signer.bin.sha512 cmd/tkey-ssh-agent/signer.bin-v1.0.0 cmd/tkey-ssh-agent-tray/trayicon.ico dco.md go.mod go.sum gon.hcl gotools/Makefile gotools/go.mod gotools/go.sum system/60-tkey.rules system/copyright system/postinst system/tkey-ssh-agent.1 system/tkey-ssh-agent.service system/tkey-ssh-agent.service.tmpl test/attic/test-loop.sh test/requirements.txt test/run test/test-loop.py tillitis-ant.png ) is_missingok() { item="$1" # ok for empty files [[ -f "$item" ]] && [[ ! -s "$item" ]] && return 0 for fileok in "${missingok_files[@]}"; do [[ "$item" = "$fileok" ]] && return 0 done for dirok in "${missingok_dirs[@]}"; do [[ "$item" =~ ^$dirok ]] && return 0 done return 1 } printf "* Checking for SPDX tags in %s\n" "$PWD" mapfile -t repofiles < <(git ls-files || true) if [[ -z "${repofiles[*]}" ]]; then printf "* No files in the repo?!\n" exit 1 fi failed=0 printed=0 for fileok in "${missingok_files[@]}"; do [[ -f "$fileok" ]] && continue if (( !printed )); then printf "* Some files in missingok_files are themselves missing:\n" printed=1 failed=1 fi printf "%s\n" "$fileok" done printed=0 for dirok in "${missingok_dirs[@]}"; do [[ -d "$dirok" ]] && continue if (( !printed )); then printf "* Some dirs in missingok_dirs are themselves missing:\n" printed=1 failed=1 fi printf "%s\n" "$dirok" done printed=0 for file in "${repofiles[@]}"; do is_missingok "$file" && continue if ! grep -q "$tag" "$file"; then if (( !printed )); then printf "* Files missing the SPDX tag:\n" printed=1 failed=1 fi printf "%s\n" "$file" fi done exit "$failed"