• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

cmake/H03-May-2022-1,2621,058

common/H03-May-2022-1,273975

debian/H17-Dec-2020-162129

doc/H17-Dec-2020-1,3351,034

lib/H03-May-2022-9,9937,088

resources/H17-Dec-2020-832617

tool/H03-May-2022-5,3684,381

tools/H17-Dec-2020-12577

vagrant/development/H17-Dec-2020-7962

ykcs11/H03-May-2022-12,96810,047

COPYINGH A D17-Dec-20201.2 KiB2420

NEWSH A D17-Dec-202010.6 KiB372202

READMEH A D17-Dec-20207.4 KiB195136

README

1== Yubico PIV Tool
2
3=== Introduction
4The Yubico PIV tool is used for interacting with the Personal
5Identity Verification (PIV) application on a https://www.yubico.com[YubiKey].
6
7With it you may generate keys on the device, importing keys and
8certificates, and create certificate requests, and other operations.
9A shared library and a command-line tool is included.
10
11==== Usage guides
12For information and examples on what you can do with a PIV enabled YubiKey,
13see https://developers.yubico.com/PIV/
14
15=== License
16In general the project is covered by the following BSD license.  The
17file ykcs11/pkcs11.h has additional copyright and licensing
18information, please see it for more information.
19
20----
21   Copyright (c) 2014-2020 Yubico AB
22   All rights reserved.
23
24   Redistribution and use in source and binary forms, with or without
25   modification, are permitted provided that the following conditions are
26   met:
27
28     * Redistributions of source code must retain the above copyright
29       notice, this list of conditions and the following disclaimer.
30
31     * Redistributions in binary form must reproduce the above
32       copyright notice, this list of conditions and the following
33       disclaimer in the documentation and/or other materials provided
34       with the distribution.
35
36   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47----
48
49=== Building on POSIX platforms
50Either clone from Git or download and unpackage the tarball, then make
51sure you have the pre-requisites installed and build following the
52steps below from the `yubico-piv-tool` directory.
53
54Please make sure to have recent versions of the following packages
55installed on your system.
56
57  cmake libtool libssl-dev pkg-config check libpcsclite-dev gengetopt help2man
58
59Help2man is used to generate the manpages.
60Gengetopt version 2.22.6 or later is needed for command line parameter
61handling. The
62link:https://github.com/Yubico/yubico-piv-tool/tree/master/vagrant/development[Vagrant
63VM] has all these dependencies preinstalled.
64
65  $ mkdir build; cd build
66  $ cmake ..
67  $ make
68  $ sudo make install
69
70On macos, you might need to point out homebrew openssl version when
71running pkg-config.
72
73  $ PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" cmake ..
74
75To statically link to OpenSSL (the `libcrypto` library), use the cmake
76option `-DOPENSSL_STATIC_LINK=ON`
77
78Don't forget you might need to be root for the last command. On Linux
79it might be needed to update your linked libraries after install
80
81  sudo ldconfig
82
83The backend to use is decided at compile time, see the summary at the
84end of the `cmake` output.  Use `--with-backend=foo` to choose
85backend, replacing `foo` with the backend you want to use.  The backends
86available are "pcsc", "macscard" and "winscard" using the PCSC
87interface, with slightly different shared library linkage and
88header file names: "pcsc" is used under GNU-like systems, "macscard"
89under Mac OS X, and "winscard" is used under Windows.  In most
90situations, running `cmake` should automatically find the proper
91backend to use.
92
93=== Building on Windows
94
95Building on Windows require MSBuild or Visual Studio and the MSVC compiler.
96
97On Windows, `getopt` is needed to read command line arguments. The path to `getopt`
98library and include file need to be specified as a command line argument to `cmake`.
99Also the path to OpenSSL need to be specified either as a command line argument to `cmake`
100or by setting the environment variable `OPENSSL_ROOT_DIR`
101
102The command line examples bellow are for `PowerShell` and the prerequisites
103were installed from source.
104
105    $ env:OPENSSL_ROOT_DIR ="PATH/TO/OPENSSL_DIR"
106    $ mkdir build; cd build
107    $ cmake -A ARCH -DGETOPT_LIB_DIR="PATH/TO/GETOPT_DIR/lib" -DGETOPT_INCLUDE_DIR="PATH/TO/GETOPT_DIR/include ..
108    $ cmake --build .
109
110To run the tests, `check` is used. The path to the `check` directory needs to be
111specified as a command line argument to `cmake`. Also the path to `check` binaries,
112`OpenSSL` binaries, `libykpiv.dll` and `libykcs11.dll` need to be in the `PATH`
113
114    $ env:OPENSSL_ROOT_DIR ="PATH/TO/OPENSSL_DIR"
115    $ mkdir build; cd build
116    $ cmake -A ARCH -DGETOPT_LIB_DIR="PATH/TO/GETOPT_DIR/lib" -DGETOPT_INCLUDE_DIR="PATH/TO/GETOPT_DIR/include -DCHECK_PATH="PATH/TO/CHECK_DIR" ..
117    $ cmake --build .
118    $ $env:Path +=";PATH/TO//CHECK_DIR/bin;PATH/TO/OPENSSL_DIR/bin;PATH/TO/build\lib\Debug;PATH/TO/build\ykcs11\Debug"
119    $ ctest.exe -C Debug
120
121For building on 32 bits system, use `Win32` as ARCH. For building on 64 bits systems,
122use `x64` as ARCH.
123
124==== Coverage
125
126Code coverage is provided courtesy of lcov and https://github.com/RWTH-HPC/CMake-codecov[CMake-codecov]. This currently only works with `make`.
127
128Enable coverage with
129
130 $ cmake -DENABLE_COVERAGE=1 ..
131
132You can then build the project normally and run some executables (for example running the tests with `make test`).
133
134At this point coverage evaluation can be generated with gcov/lcov related targets. For example
135
136 $ make lcov
137
138will generate a single HTML report in `./lcov/html/all_targets/index.html`
139
140=== Portability
141The main development platform is Debian GNU/Linux.
142The project compiles on Windows using MSVC and the PCSC backend.
143It can also be built for Mac OS X, also using the PCSC backend.
144
145=== Example Usage
146For a list of all available options --help can be given. For more information
147on exactly what happens --verbose or --verbose=2 may be added.
148
149Generate a new ECC-P256 key on device in slot 9a, will print the public
150key on stdout:
151
152  $ yubico-piv-tool -s9a -AECCP256 -agenerate
153
154Generate a certificate request with public key from stdin, will print
155the resulting request on stdout:
156
157  $ yubico-piv-tool -s9a -S'/CN=foo/OU=test/O=example.com/' -averify -arequest
158
159Generate a self-signed certificate with public key from stdin, will print
160the certificate, for later import, on stdout:
161
162  $ yubico-piv-tool -s9a -S'/CN=bar/OU=test/O=example.com/' -averify -aselfsign
163
164Import a certificate from stdin:
165
166  $ yubico-piv-tool -s9a -aimport-certificate
167
168Set a random chuid, import a key and import a certificate from a PKCS12
169file, into slot 9c:
170
171  $ yubico-piv-tool -s9c -itest.pfx -KPKCS12 -aset-chuid -aimport-key \
172    -aimport-cert
173
174Change the management key used for administrative authentication:
175
176  $ yubico-piv-tool -aset-mgm-key
177
178Delete a certificate in slot 9a, with management key being asked for:
179
180  $ yubico-piv-tool -adelete-certificate -s9a -k
181
182Show some information on certificates and other data:
183
184  $ yubico-piv-tool -astatus
185
186Read out the certificate from a slot and then run a signature test:
187
188  $ yubico-piv-tool -aread-cert -s9a
189  $ yubico-piv-tool -averify-pin -atest-signature -s9a
190
191Import a key into slot 85 (only available on YubiKey 4 & 5) and set the
192touch policy (also only available on YubiKey 4 & 5):
193
194  $ yubico-piv-tool -aimport-key -s85 --touch-policy=always -ikey.pem
195