gnu: Add python-yubikey-manager and python2-yubikey-manager.
[jackhill/guix/guix.git] / gnu / packages / security-token.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016 Mike Gerwitz <mtg@gnu.org>
5 ;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
7 ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
9 ;;; Copyright © 2018, 2019 Chris Marusich <cmmarusich@gmail.com>
10 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages security-token)
28 #:use-module (gnu packages)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix gexp)
33 #:use-module (guix git-download)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system glib-or-gtk)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages autotools)
38 #:use-module (gnu packages curl)
39 #:use-module (gnu packages check)
40 #:use-module (gnu packages docbook)
41 #:use-module (gnu packages documentation)
42 #:use-module (gnu packages dns)
43 #:use-module (gnu packages gettext)
44 #:use-module (gnu packages graphviz)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages libusb)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages man)
49 #:use-module (gnu packages networking)
50 #:use-module (gnu packages cyrus-sasl)
51 #:use-module (gnu packages popt)
52 #:use-module (gnu packages readline)
53 #:use-module (gnu packages tls)
54 #:use-module (gnu packages tex)
55 #:use-module (gnu packages perl)
56 #:use-module (gnu packages pkg-config)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages python-crypto)
59 #:use-module (gnu packages python-xyz)
60 #:use-module (gnu packages swig)
61 #:use-module (gnu packages web)
62 #:use-module (gnu packages xml))
63
64 (define-public ccid
65 (package
66 (name "ccid")
67 (version "1.4.30")
68 (source (origin
69 (method url-fetch)
70 (uri (string-append
71 "https://ccid.apdu.fr/files/"
72 name "-" version ".tar.bz2"))
73 (sha256
74 (base32
75 "0z7zafdg75fr1adlv2x0zz34s07gljcjg2lsz76s1048w1xhh5xc"))))
76 (build-system gnu-build-system)
77 (arguments
78 `(#:configure-flags (list (string-append "--enable-usbdropdir=" %output
79 "/pcsc/drivers"))
80 #:phases
81 (modify-phases %standard-phases
82 (add-after 'unpack 'patch-Makefile
83 (lambda _
84 (substitute* "src/Makefile.in"
85 (("/bin/echo") (which "echo")))
86 #t)))))
87 (native-inputs
88 `(("pcsc-lite" ,pcsc-lite) ; only required for headers
89 ("perl" ,perl)
90 ("pkg-config" ,pkg-config)))
91 (inputs
92 `(("libusb" ,libusb)))
93 (home-page "https://ccid.apdu.fr/")
94 (synopsis "PC/SC driver for USB smart card devices")
95 (description
96 "This package provides a PC/SC IFD handler implementation for devices
97 compliant with the CCID and ICCD protocols. It supports a wide range of
98 readers and is needed to communicate with such devices through the
99 @command{pcscd} resource manager.")
100 (license license:lgpl2.1+)))
101
102 (define-public eid-mw
103 (package
104 (name "eid-mw")
105 (version "4.4.16")
106 (source
107 (origin
108 (method git-fetch)
109 (uri (git-reference
110 (url "https://github.com/Fedict/eid-mw")
111 (commit (string-append "v" version))))
112 (sha256
113 (base32 "1q82fw63xzrnrgh1wyh457hal6vfdl6swqfq7l6kviywiwlzx7kd"))))
114 (build-system glib-or-gtk-build-system)
115 (native-inputs
116 `(("autoconf" ,autoconf)
117 ("automake" ,automake)
118 ("gettext" ,gnu-gettext)
119 ("libtool" ,libtool)
120 ("pkg-config" ,pkg-config)
121 ("perl" ,perl)))
122 (inputs
123 `(("curl" ,curl)
124 ("openssl" ,openssl)
125 ("gtk+" ,gtk+)
126 ("pcsc-lite" ,pcsc-lite)
127 ("p11-kit" ,p11-kit)
128 ("libproxy" ,libproxy)
129 ("libxml2" ,libxml2)
130 ("cyrus-sasl" ,cyrus-sasl)))
131 (arguments
132 `(#:phases
133 (modify-phases %standard-phases
134 (add-after 'unpack 'bootstrap
135 (lambda _
136 ;; configure.ac relies on ‘git --describe’ to get the version.
137 ;; Patch it to just return the real version number directly.
138 (substitute* "scripts/build-aux/genver.sh"
139 (("/bin/sh") (which "sh"))
140 (("^(GITDESC=).*" match) (string-append match ,version "\n")))
141 (invoke "sh" "./bootstrap.sh"))))))
142 (synopsis "Belgian eID Middleware")
143 (description "The Belgian eID Middleware is required to authenticate with
144 online services using the Belgian electronic identity card.")
145 (home-page "https://github.com/Fedict/eid-mw")
146 (license license:lgpl3)))
147
148 (define-public libyubikey
149 (package
150 (name "libyubikey")
151 (version "1.13")
152 (source (origin
153 (method url-fetch)
154 (uri (string-append
155 "https://developers.yubico.com/yubico-c/Releases/"
156 name "-" version ".tar.gz"))
157 (sha256
158 (base32
159 "009l3k2zyn06dbrlja2d4p2vfnzjhlcqxi88v02mlrnb17mx1v84"))))
160 (build-system gnu-build-system)
161 (synopsis "Development kit for the YubiKey authentication device")
162 (description
163 "This package contains a C library and command-line tools that make up
164 the low-level development kit for the Yubico YubiKey authentication device.")
165 (home-page "https://developers.yubico.com/yubico-c/")
166 (license license:bsd-2)))
167
168 (define-public pcsc-lite
169 (package
170 (name "pcsc-lite")
171 (version "1.8.25")
172 (source (origin
173 (method url-fetch)
174 (uri (string-append
175 "https://pcsclite.apdu.fr/files/"
176 name "-" version ".tar.bz2"))
177 (sha256
178 (base32
179 "14l7irs1nsh8b036ag4cfy8wryyysch78scz5dw6xxqwqgnpjvfp"))))
180 (build-system gnu-build-system)
181 (arguments
182 `(#:configure-flags '("--enable-usbdropdir=/var/lib/pcsc/drivers"
183 "--disable-libsystemd")))
184 (native-inputs
185 `(("perl" ,perl) ; for pod2man
186 ("pkg-config" ,pkg-config)))
187 (inputs
188 `(("libudev" ,eudev)))
189 (home-page "https://pcsclite.apdu.fr/")
190 (synopsis "Middleware to access a smart card using PC/SC")
191 (description
192 "pcsc-lite provides an interface to communicate with smartcards and
193 readers using the SCard API. pcsc-lite is used to connect to the PC/SC daemon
194 from a client application and provide access to the desired reader.")
195 (license (list license:bsd-3 ; pcsc-lite
196 license:isc ; src/strlcat.c src/strlcpy.c
197 license:gpl3+)))) ; src/spy/*
198
199 (define-public ykclient
200 (package
201 (name "ykclient")
202 (version "2.15")
203 (source (origin
204 (method url-fetch)
205 (uri (string-append
206 "https://developers.yubico.com/yubico-c-client/Releases/"
207 name "-" version ".tar.gz"))
208 (sha256
209 (base32
210 "05jhx9waj3pl120ddnwap1v3bjrnbfhvf3lxs2xmhpcmwzpwsqgl"))))
211 (build-system gnu-build-system)
212
213 ;; There's just one test, and it requires network access to access
214 ;; yubico.com, so skip it.
215 (arguments '(#:tests? #f))
216
217 (native-inputs `(("pkg-config" ,pkg-config)
218 ("help2man" ,help2man)))
219 (inputs `(("curl" ,curl)))
220 (synopsis "C library to validate one-time-password YubiKeys")
221 (description
222 "YubiKey C Client Library (libykclient) is a C library used to validate a
223 one-time-password (OTP) YubiKey against Yubico’s servers. See the Yubico
224 website for more information about Yubico and the YubiKey.")
225 (home-page "https://developers.yubico.com/yubico-c-client/")
226 (license license:bsd-2)))
227
228 (define-public opensc
229 (package
230 (name "opensc")
231 (version "0.19.0")
232 (source (origin
233 (method url-fetch)
234 (uri (string-append
235 "https://github.com/OpenSC/OpenSC/releases/download/"
236 version "/opensc-" version ".tar.gz"))
237 (sha256
238 (base32
239 "09jqzl18z5qfrf4vf2nvbpdm3mphpgfkl3ww1clkaxh2z56hwnic"))))
240 (build-system gnu-build-system)
241 (arguments
242 `(#:phases
243 (modify-phases %standard-phases
244 ;; By setting an absolute path here, we arrange for OpenSC to
245 ;; successfully dlopen libpcsclite.so.1 by default. The user can
246 ;; still override this if they want to, by specifying a custom OpenSC
247 ;; configuration file at runtime.
248 (add-after 'unpack 'set-default-libpcsclite.so.1-path
249 (lambda* (#:key inputs #:allow-other-keys)
250 (let ((libpcsclite (string-append (assoc-ref inputs "pcsc-lite")
251 "/lib/libpcsclite.so.1")))
252 (substitute* "configure"
253 (("DEFAULT_PCSC_PROVIDER=\"libpcsclite\\.so\\.1\"")
254 (string-append
255 "DEFAULT_PCSC_PROVIDER=\"" libpcsclite "\"")))
256 #t)))
257 (add-before 'check 'disable-broken-test
258 (lambda _
259 ;; XXX: This test is fixed in git, remove this phase for >= 0.19.
260 (substitute* "doc/tools/Makefile"
261 (("TESTS = test-manpage.sh") "TESTS = "))
262 #t)))))
263 (inputs
264 `(("readline" ,readline)
265 ("openssl" ,openssl)
266 ("pcsc-lite" ,pcsc-lite)
267 ("ccid" ,ccid)))
268 (native-inputs
269 `(("libxslt" ,libxslt)
270 ("docbook-xsl" ,docbook-xsl)
271 ("pkg-config" ,pkg-config)))
272 (home-page "https://github.com/OpenSC/OpenSC/wiki")
273 (synopsis "Tools and libraries related to smart cards")
274 (description
275 "OpenSC is a set of software tools and libraries to work with smart
276 cards, with the focus on smart cards with cryptographic capabilities. OpenSC
277 facilitate the use of smart cards in security applications such as
278 authentication, encryption and digital signatures. OpenSC implements the PKCS
279 #15 standard and the PKCS #11 API.")
280 (license license:lgpl2.1+)))
281
282 (define-public yubico-piv-tool
283 (package
284 (name "yubico-piv-tool")
285 (version "1.6.1")
286 (source (origin
287 (method url-fetch)
288 (uri (string-append
289 "https://developers.yubico.com/yubico-piv-tool/Releases/"
290 name "-" version ".tar.gz"))
291 (sha256
292 (base32
293 "10xgdc51xvszkxmsvqnbjs8ixxz7rfnfahh3wn8glllynmszbhwi"))))
294 (build-system gnu-build-system)
295 (inputs
296 `(("gengetopt" ,gengetopt)
297 ("perl" ,perl)
298 ("pcsc-lite" ,pcsc-lite)
299 ("openssl" ,openssl)))
300 (native-inputs
301 `(("doxygen" ,doxygen)
302 ("graphviz" ,graphviz)
303 ("help2man" ,help2man)
304 ("check" ,check)
305 ("texlive-bin" ,texlive-bin)
306 ("pkg-config" ,pkg-config)))
307 (home-page "https://developers.yubico.com/yubico-piv-tool/")
308 (synopsis "Interact with the PIV application on a YubiKey")
309 (description
310 "The Yubico PIV tool is used for interacting with the Privilege and
311 Identification Card (PIV) application on a YubiKey. With it you may generate
312 keys on the device, import keys and certificates, create certificate requests,
313 and other operations. It includes a library and a command-line tool.")
314 ;; The file ykcs11/pkcs11.h also declares an additional, very short free
315 ;; license for that one file. Please see it for details. The vast
316 ;; majority of files are licensed under bsd-2.
317 (license license:bsd-2)))
318
319 (define-public yubikey-personalization
320 (package
321 (name "yubikey-personalization")
322 (version "1.19.3")
323 (source (origin
324 (method url-fetch)
325 (uri (string-append
326 "https://developers.yubico.com/" name
327 "/Releases/ykpers-" version ".tar.gz"))
328 (sha256
329 (base32
330 "0jhvnavjrpwzmmjcw486df5s48j53njqgyz36yz3dskbaz3kwlfr"))))
331 (build-system gnu-build-system)
332 (arguments
333 '(#:configure-flags (list (string-append "--with-udevrulesdir="
334 (assoc-ref %outputs "out")
335 "/lib/udev/rules.d"))))
336 (inputs
337 `(("json-c" ,json-c)
338 ("libusb" ,libusb)
339 ;; The library "libyubikey" is also known as "yubico-c".
340 ("libyubikey" ,libyubikey)))
341 (native-inputs
342 `(("pkg-config" ,pkg-config)
343 ("eudev" ,eudev)))
344 (home-page "https://developers.yubico.com/yubikey-personalization/")
345 (synopsis "Library and tools to personalize YubiKeys")
346 (description
347 "The YubiKey Personalization package contains a C library and command
348 line tools for personalizing YubiKeys. You can use these to set an AES key,
349 retrieve a YubiKey's serial number, and so forth.")
350 (license license:bsd-2)))
351
352 (define-public python-pyscard
353 (package
354 (name "python-pyscard")
355 (version "1.9.8")
356 (source (origin
357 (method url-fetch)
358 ;; The maintainer publishes releases on various sites, but
359 ;; SourceForge is apparently the only one with a signed release.
360 (uri (string-append
361 "mirror://sourceforge/pyscard/pyscard/pyscard%20"
362 version "/pyscard-" version ".tar.gz"))
363 (sha256
364 (base32
365 "15fh00z1an6r5j7hrz3jlq0rb3jygwf3x4jcwsa008bv8vpcg7gm"))))
366 (build-system python-build-system)
367 (arguments
368 `(#:phases
369 (modify-phases %standard-phases
370 ;; Tell pyscard where to find the PCSC include directory.
371 (add-after 'unpack 'patch-platform-include-dirs
372 (lambda* (#:key inputs #:allow-other-keys)
373 (let ((pcsc-include-dir (string-append
374 (assoc-ref inputs "pcsc-lite")
375 "/include/PCSC")))
376 (substitute* "setup.py"
377 (("platform_include_dirs = \\[.*?\\]")
378 (string-append
379 "platform_include_dirs = ['" pcsc-include-dir "']")))
380 #t)))
381 ;; pyscard wants to dlopen libpcsclite, so tell it where it is.
382 (add-after 'unpack 'patch-dlopen
383 (lambda* (#:key inputs #:allow-other-keys)
384 (substitute* "smartcard/scard/winscarddll.c"
385 (("lib = \"libpcsclite\\.so\\.1\";")
386 (simple-format #f
387 "lib = \"~a\";"
388 (string-append (assoc-ref inputs "pcsc-lite")
389 "/lib/libpcsclite.so.1"))))
390 #t)))))
391 (inputs
392 `(("pcsc-lite" ,pcsc-lite)))
393 (native-inputs
394 `(("swig" ,swig)))
395 (home-page "https://github.com/LudovicRousseau/pyscard")
396 (synopsis "Smart card library for Python")
397 (description
398 "The pyscard smart card library is a framework for building smart card
399 aware applications in Python. The smart card module is built on top of the
400 PCSC API Python wrapper module.")
401 (license license:lgpl2.1+)))
402
403 (define-public python2-pyscard
404 (package-with-python2 python-pyscard))
405
406 (define-public libu2f-host
407 (package
408 (name "libu2f-host")
409 (version "1.1.9")
410 (source (origin
411 (method url-fetch)
412 (uri
413 (string-append
414 "https://developers.yubico.com"
415 "/libu2f-host/Releases/libu2f-host-" version ".tar.xz"))
416 (sha256
417 (base32
418 "1hnh3f4scx07v9jfkr1nnxasmydk1cmivn0nijcp2p75bc1fznip"))))
419 (build-system gnu-build-system)
420 (arguments
421 `(#:configure-flags
422 (list "--enable-gtk-doc"
423 (string-append "--with-udevrulesdir="
424 (assoc-ref %outputs "out")
425 "/lib/udev/rules.d"))
426 #:phases
427 (modify-phases %standard-phases
428 (add-after 'unpack 'patch-docbook-xml
429 (lambda* (#:key inputs #:allow-other-keys)
430 ;; Avoid a network connection attempt during the build.
431 (substitute* "gtk-doc/u2f-host-docs.xml"
432 (("http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd")
433 (string-append (assoc-ref inputs "docbook-xml")
434 "/xml/dtd/docbook/docbookx.dtd")))
435 #t)))))
436 (inputs
437 `(("json-c" ,json-c)
438 ("hidapi" ,hidapi)))
439 (native-inputs
440 `(("help2man" ,help2man)
441 ("gengetopt" ,gengetopt)
442 ("pkg-config" ,pkg-config)
443 ("gtk-doc" ,gtk-doc)
444 ("docbook-xml" ,docbook-xml-4.3)
445 ("eudev" ,eudev)))
446 (home-page "https://developers.yubico.com/libu2f-host/")
447 ;; TRANSLATORS: The U2F protocol has a "server side" and a "host side".
448 (synopsis "U2F host-side C library and tool")
449 (description
450 "Libu2f-host provides a C library and command-line tool that implements
451 the host-side of the Universal 2nd Factor (U2F) protocol. There are APIs to
452 talk to a U2F device and perform the U2F Register and U2F Authenticate
453 operations.")
454 ;; Most files are LGPLv2.1+, but some files are GPLv3+.
455 (license (list license:lgpl2.1+ license:gpl3+))))
456
457 (define-public python-fido2
458 (package
459 (name "python-fido2")
460 (version "0.5.0")
461 (source (origin
462 (method url-fetch)
463 (uri
464 (string-append
465 "https://github.com/Yubico/python-fido2/releases/download/"
466 version "/fido2-" version ".tar.gz"))
467 (sha256
468 (base32
469 "1pl8d2pr6jzqj4y9qiaddhjgnl92kikjxy0bgzm2jshkzzic8mp3"))
470 (snippet
471 ;; Remove bundled dependency.
472 #~(delete-file "fido2/public_suffix_list.dat"))))
473 (build-system python-build-system)
474 (arguments
475 `(#:phases
476 (modify-phases %standard-phases
477 (add-after 'unpack 'install-public-suffix-list
478 (lambda* (#:key inputs #:allow-other-keys)
479 (copy-file
480 (string-append (assoc-ref inputs "public-suffix-list")
481 "/share/public-suffix-list-"
482 ,(package-version public-suffix-list)
483 "/public_suffix_list.dat")
484 "fido2/public_suffix_list.dat")
485 #t)))))
486 (propagated-inputs
487 `(("python-cryptography" ,python-cryptography)
488 ("python-six" ,python-six)))
489 (native-inputs
490 `(("python-mock" ,python-mock)
491 ("python-pyfakefs" ,python-pyfakefs)
492 ("public-suffix-list" ,public-suffix-list)))
493 (home-page "https://github.com/Yubico/python-fido2")
494 (synopsis "Python library for communicating with FIDO devices over USB")
495 (description
496 "This Python library provides functionality for communicating with a Fast
497 IDentity Online (FIDO) device over Universal Serial Bus (USB) as well as
498 verifying attestation and assertion signatures. It aims to support the FIDO
499 Universal 2nd Factor (U2F) and FIDO 2.0 protocols for communicating with a USB
500 authenticator via the Client-to-Authenticator Protocol (CTAP 1 and 2). In
501 addition to this low-level device access, classes defined in the
502 @code{fido2.client} and @code{fido2.server} modules implement higher level
503 operations which are useful when interfacing with an Authenticator, or when
504 implementing a Relying Party.")
505 ;; python-fido2 contains some derivative files originally from pyu2f
506 ;; (https://github.com/google/pyu2f). These files are licensed under the
507 ;; Apache License, version 2.0. The maintainers have customized these
508 ;; files for internal use, so they are not really a bundled dependency.
509 (license (list license:bsd-2 license:asl2.0))))
510
511 (define-public python2-fido2
512 (package-with-python2 python-fido2))
513
514 (define-public python-yubikey-manager
515 (package
516 (name "python-yubikey-manager")
517 (version "2.1.0")
518 (source (origin
519 (method url-fetch)
520 (uri (string-append
521 "https://developers.yubico.com/yubikey-manager/Releases"
522 "/yubikey-manager-" version ".tar.gz"))
523 (sha256
524 (base32
525 "11rsmcaj60k3y5m5gdhr2nbbz0w5dm3m04klyxz0fh5hnpcmr7fm"))))
526 (build-system python-build-system)
527 (propagated-inputs
528 `(("python-six" ,python-six)
529 ("python-pyscard" ,python-pyscard)
530 ("python-pyusb" ,python-pyusb)
531 ("python-click" ,python-click)
532 ("python-cryptography" ,python-cryptography)
533 ("python-pyopenssl" ,python-pyopenssl)
534 ("python-fido2" ,python-fido2)))
535 (inputs
536 `(("yubikey-personalization" ,yubikey-personalization)
537 ("pcsc-lite" ,pcsc-lite)
538 ("libusb" ,libusb)))
539 (native-inputs
540 `(("swig" ,swig)
541 ("python-mock" ,python-mock)))
542 (home-page "https://developers.yubico.com/yubikey-manager/")
543 (synopsis "Command line tool and library for configuring a YubiKey")
544 (description
545 "Python library and command line tool for configuring a YubiKey. Note
546 that after installing this package, you might still need to add appropriate
547 udev rules to your system configuration to be able to configure the YubiKey as
548 an unprivileged user.")
549 (license license:bsd-2)))
550
551 (define-public python2-yubikey-manager
552 (package-with-python2 python-yubikey-manager))