Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / crypto.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox>
6 ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
8 ;;; Copyright © 2016, 2017 Eric Bavier <bavier@member.fsf.org>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages crypto)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages admin)
28 #:use-module (gnu packages aidc)
29 #:use-module (gnu packages attr)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages boost)
32 #:use-module (gnu packages cryptsetup)
33 #:use-module (gnu packages gettext)
34 #:use-module (gnu packages gnupg)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages libbsd)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages nettle)
40 #:use-module (gnu packages password-utils)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages readline)
43 #:use-module (gnu packages search)
44 #:use-module (gnu packages serialization)
45 #:use-module (gnu packages shells)
46 #:use-module (gnu packages tcl)
47 #:use-module (gnu packages tls)
48 #:use-module (gnu packages xml)
49 #:use-module ((guix licenses) #:prefix license:)
50 #:use-module (guix packages)
51 #:use-module (guix download)
52 #:use-module (guix git-download)
53 #:use-module (guix build-system cmake)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system perl)
56 #:use-module (guix build-system python))
57
58 (define-public libsodium
59 (package
60 (name "libsodium")
61 (version "1.0.13")
62 (source (origin
63 (method url-fetch)
64 (uri (list (string-append
65 "http://download.libsodium.org/libsodium/"
66 "releases/libsodium-" version ".tar.gz")
67 (string-append
68 "https://download.libsodium.org/libsodium/"
69 "releases/old/libsodium-" version ".tar.gz")))
70 (sha256
71 (base32
72 "1z93wfg4k5svg8yck6cgdr6ysj91kbpn03nyzwxanncy3b5sq4ww"))))
73 (build-system gnu-build-system)
74 (synopsis "Portable NaCl-based crypto library")
75 (description
76 "Sodium is a new easy-to-use high-speed software library for network
77 communication, encryption, decryption, signatures, etc.")
78 (license license:isc)
79 (home-page "http://libsodium.org")))
80
81 (define-public signify
82 (package
83 (name "signify")
84 (version "22")
85 (source (origin
86 (method url-fetch)
87 (uri (string-append "https://github.com/aperezdc/signify/"
88 "archive/v" version ".tar.gz"))
89 (file-name (string-append name "-" version ".tar.gz"))
90 (sha256
91 (base32
92 "0iv5bjaas70ymqchxasapin4c32c41kqzkfhc3kcjzd7rxy78msy"))))
93 (build-system gnu-build-system)
94 ;; TODO Build with libwaive (described in README.md), to implement something
95 ;; like OpenBSD's pledge().
96 (arguments
97 `(#:tests? #f ; no test suite
98 #:make-flags
99 (list "CC=gcc"
100 (string-append "PREFIX=" (assoc-ref %outputs "out")))
101 #:phases
102 (modify-phases %standard-phases
103 (delete 'configure))))
104 (native-inputs
105 `(("pkg-config" ,pkg-config)))
106 (inputs
107 `(("libbsd" ,libbsd)))
108 (synopsis "Create and verify cryptographic signatures")
109 (description "The signify utility creates and verifies cryptographic
110 signatures using the elliptic curve Ed25519. This is a Linux port of the
111 OpenBSD tool of the same name.")
112 (home-page "https://github.com/aperezdc/signify")
113 ;; This package includes third-party code that was originally released under
114 ;; various non-copyleft licenses. See the source files for clarification.
115 (license (list license:bsd-3 license:bsd-4 license:expat license:isc
116 license:public-domain (license:non-copyleft
117 "file://base64.c"
118 "See base64.c in the distribution for
119 the license from IBM.")))))
120
121
122 (define-public opendht
123 (package
124 (name "opendht")
125 (version "0.6.1")
126 (source
127 (origin
128 (method url-fetch)
129 (uri
130 (string-append
131 "https://github.com/savoirfairelinux/" name
132 "/archive/" version ".tar.gz"))
133 (file-name (string-append name "-" version ".tar.gz"))
134 (modules '((guix build utils)))
135 (snippet
136 '(begin
137 (delete-file-recursively "src/argon2")
138 (substitute* "src/Makefile.am"
139 (("./argon2/libargon2.la") "")
140 (("SUBDIRS = argon2") ""))
141 (substitute* "src/crypto.cpp"
142 (("argon2/argon2.h") "argon2.h"))
143 (substitute* "configure.ac"
144 (("src/argon2/Makefile") ""))))
145 (sha256
146 (base32
147 "09yvkmbqbym3b5md4n96qc1s9sf2n8ji404hagih45rmsj49599x"))))
148 (build-system gnu-build-system)
149 (inputs
150 `(("gnutls" ,gnutls)
151 ("nettle" ,nettle)
152 ("readline" ,readline)
153 ("argon2" ,argon2)))
154 (propagated-inputs
155 `(("msgpack" ,msgpack))) ;included in several installed headers
156 (native-inputs
157 `(("autoconf" ,autoconf)
158 ("pkg-config" ,pkg-config)
159 ("automake" ,automake)
160 ("libtool" ,libtool)))
161 (arguments
162 `(#:configure-flags '("--disable-tools" "--disable-python")
163 #:phases (modify-phases %standard-phases
164 (add-before 'configure 'autoconf
165 (lambda _
166 (zero? (system* "autoreconf" "-vfi")))))))
167 (home-page "https://github.com/savoirfairelinux/opendht/")
168 (synopsis "Distributed Hash Table (DHT) library")
169 (description "OpenDHT is a Distributed Hash Table (DHT) library. It may
170 be used to manage peer-to-peer network connections as needed for real time
171 communication.")
172 (license license:gpl3)))
173
174 (define-public encfs
175 (package
176 (name "encfs")
177 (version "1.9.1")
178 (source
179 (origin
180 (method url-fetch)
181 (uri
182 (string-append "https://github.com/vgough/encfs/releases/download/v"
183 version "/encfs-" version ".tar.gz"))
184 (sha256
185 (base32
186 "1906254dg5hwljh0h4gyrw09ms3b57dlhjfzhfzffv50yzpkl837"))
187 (modules '((guix build utils)))
188 ;; Remove bundled dependencies in favour of proper inputs.
189 (snippet '(for-each delete-file-recursively
190 (find-files "internal" "^tinyxml2-[0-9]"
191 #:directories? #t)))))
192 (build-system cmake-build-system)
193 (native-inputs
194 `(("gettext" ,gettext-minimal)
195
196 ;; Test dependencies.
197 ("expect" ,expect)
198 ("perl" ,perl)))
199 (inputs
200 `(("attr" ,attr)
201 ("fuse" ,fuse)
202 ("openssl" ,openssl)
203 ("tinyxml2" ,tinyxml2)))
204 (arguments
205 `(#:configure-flags (list "-DUSE_INTERNAL_TINYXML=OFF")))
206 (home-page "https://vgough.github.io/encfs")
207 (synopsis "Encrypted virtual file system")
208 (description
209 "EncFS creates a virtual encrypted file system in user-space. Each file
210 created under an EncFS mount point is stored as a separate encrypted file on
211 the underlying file system. Like most encrypted file systems, EncFS is meant
212 to provide security against off-line attacks, such as a drive falling into
213 the wrong hands.")
214 (license (list license:expat ; internal/easylogging++.h
215 license:lgpl3+ ; encfs library
216 license:gpl3+)))) ; command-line tools
217
218 (define-public keyutils
219 (package
220 (name "keyutils")
221 (version "1.5.9")
222 (source
223 (origin
224 (method url-fetch)
225 (uri
226 (string-append "https://people.redhat.com/dhowells/keyutils/keyutils-"
227 version ".tar.bz2"))
228 (sha256
229 (base32
230 "1bl3w03ygxhc0hz69klfdlwqn33jvzxl1zfl2jmnb2v85iawb8jd"))
231 (modules '((guix build utils)))
232 ;; Create relative symbolic links instead of absolute ones to /lib/*
233 (snippet '(substitute* "Makefile" (("\\$\\(LNS\\) \\$\\(LIBDIR\\)/")
234 "$(LNS) ")))))
235 (build-system gnu-build-system)
236 (arguments
237 `(#:phases (modify-phases %standard-phases
238 (delete 'configure)) ; no configure script
239 #:make-flags (list "CC=gcc"
240 "RPATH=-Wl,-rpath,$(DESTDIR)$(LIBDIR)"
241 (string-append "DESTDIR="
242 (assoc-ref %outputs "out"))
243 "INCLUDEDIR=/include"
244 "LIBDIR=/lib"
245 "MANDIR=/share/man"
246 "SHAREDIR=/share/keyutils")
247 #:test-target "test"))
248 (home-page "https://people.redhat.com/dhowells/keyutils/")
249 (synopsis "Linux key management utilities")
250 (description
251 "Keyutils is a set of utilities for managing the key retention facility in
252 the Linux kernel, which can be used by file systems, block devices, and more to
253 gain and retain the authorization and encryption keys required to perform
254 secure operations. ")
255 (license (list license:lgpl2.1+ ; the files keyutils.*
256 license:gpl2+)))) ; the rest
257
258 ;; There is no release candidate but commits point out a version number,
259 ;; furthermore no tarball exists.
260 (define-public eschalot
261 (let ((commit "0bf31d88a11898c19b1ed25ddd2aff7b35dbac44")
262 (revision "1"))
263 (package
264 (name "eschalot")
265 (version (string-append "1.2.0-" revision "." (string-take commit 7)))
266 (source
267 (origin
268 (method git-fetch)
269 (uri (git-reference
270 (url "https://github.com/schnabear/eschalot")
271 (commit commit)))
272 (file-name (string-append name "-" version))
273 (sha256
274 (base32
275 "0lj38ldh8vzi11wp4ghw4k0fkwp0s04zv8k8d473p1snmbh7mx98"))))
276 (inputs
277 `(("openssl" ,openssl))) ; It needs: openssl/{bn,pem,rsa,sha}.h
278 (build-system gnu-build-system)
279 (arguments
280 `(#:make-flags (list "CC=gcc"
281 (string-append "PREFIX=" (assoc-ref %outputs "out"))
282 (string-append "INSTALL=" "install"))
283 ;; XXX: make test would run a !VERY! long hashing of names with the use
284 ;; of a wordlist, the amount of computing time this would waste on build
285 ;; servers is in no relation to the size or importance of this small
286 ;; application, therefore we run our own tests on eschalot and worgen.
287 #:phases
288 (modify-phases %standard-phases
289 (delete 'configure)
290 (replace 'check
291 (lambda _
292 (and
293 (zero? (system* "./worgen" "8-12" "top1000.txt" "3-10" "top400nouns.txt"
294 "3-6" "top150adjectives.txt" "3-6"))
295 (zero? (system* "./eschalot" "-r" "^guix|^guixsd"))
296 (zero? (system* "./eschalot" "-r" "^gnu|^free"))
297 (zero? (system* "./eschalot" "-r" "^cyber|^hack"))
298 (zero? (system* "./eschalot" "-r" "^troll")))))
299 ;; Make install can not create the bin dir, create it.
300 (add-before 'install 'create-bin-dir
301 (lambda* (#:key outputs #:allow-other-keys)
302 (let* ((out (assoc-ref outputs "out"))
303 (bin (string-append out "/bin")))
304 (mkdir-p bin)
305 #t))))))
306 (home-page "https://github.com/schnabear/eschalot")
307 (synopsis "Tor hidden service name generator")
308 (description
309 "Eschalot is a tor hidden service name generator, it allows one to
310 produce customized vanity .onion addresses using a brute-force method. Searches
311 for valid names can be run with regular expressions and wordlists. For the
312 generation of wordlists the included tool @code{worgen} can be used. There is
313 no man page, refer to the home page for usage details.")
314 (license (list license:isc license:expat)))))
315
316 (define-public tomb
317 (package
318 (name "tomb")
319 (version "2.4")
320 (source (origin
321 (method url-fetch)
322 (uri (string-append "https://files.dyne.org/tomb/"
323 "Tomb-" version ".tar.gz"))
324 (sha256
325 (base32
326 "1hv1w79as7swqj0n137vz8n8mwvcgwlvd91sdyssz41jarg7f1vr"))))
327 (build-system gnu-build-system)
328 (native-inputs `(("sudo" ,sudo))) ;presence needed for 'check' phase
329 (inputs
330 `(("zsh" ,zsh)
331 ("gnupg" ,gnupg)
332 ("cryptsetup" ,cryptsetup)
333 ("e2fsprogs" ,e2fsprogs) ;for mkfs.ext4
334 ("gettext" ,gettext-minimal) ;used at runtime
335 ("mlocate" ,mlocate)
336 ("pinentry" ,pinentry)
337 ("qrencode" ,qrencode)
338 ("steghide" ,steghide)))
339 (arguments
340 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
341 ;; TODO: Build and install gtk and qt trays
342 #:phases
343 (modify-phases %standard-phases
344 (delete 'configure) ;no configuration to be done
345 (add-after 'install 'i18n
346 (lambda* (#:key make-flags #:allow-other-keys)
347 (zero? (apply system*
348 "make" "-C" "extras/translations"
349 "install" make-flags))))
350 (add-after 'install 'wrap
351 (lambda* (#:key inputs outputs #:allow-other-keys)
352 (let ((out (assoc-ref outputs "out")))
353 (wrap-program (string-append out "/bin/tomb")
354 `("PATH" ":" prefix
355 (,(string-append (assoc-ref inputs "mlocate") "/bin")
356 ,@(map (lambda (program)
357 (or (and=> (which program) dirname)
358 (error "program not found:" program)))
359 '("seq" "mkfs.ext4" "pinentry" "sudo"
360 "gpg" "cryptsetup" "gettext"
361 "qrencode" "steghide")))))
362 #t)))
363 (delete 'check)
364 (add-after 'wrap 'check
365 (lambda* (#:key outputs #:allow-other-keys)
366 ;; Running the full tests requires sudo/root access for
367 ;; cryptsetup, which is not available in the build environment.
368 ;; But we can run `tomb dig` without root, so make sure that
369 ;; works. TODO: It Would Be Nice to check the expected "index",
370 ;; "search", "bury", and "exhume" features are available by
371 ;; querying `tomb -h`.
372 (let ((tomb (string-append (assoc-ref outputs "out")
373 "/bin/tomb")))
374 (zero? (system* tomb "dig" "-s" "10" "secrets.tomb"))))))))
375 (home-page "http://www.dyne.org/software/tomb")
376 (synopsis "File encryption for secret data")
377 (description
378 "Tomb is an application to manage the creation and access of encrypted
379 storage files: it can be operated from commandline and it can integrate with a
380 user's graphical desktop.")
381 (license license:gpl3+)))
382
383 (define-public scrypt
384 (package
385 (name "scrypt")
386 (version "1.2.1")
387 (source
388 (origin
389 (method url-fetch)
390 (uri (string-append "https://www.tarsnap.com/scrypt/scrypt-"
391 version ".tgz"))
392 (sha256
393 (base32
394 "0xy5yhrwwv13skv9im9vm76rybh9f29j2dh4hlh2x01gvbkza8a6"))))
395 (build-system gnu-build-system)
396 (arguments
397 `(#:phases (modify-phases %standard-phases
398 (add-after 'unpack 'patch-command-invocations
399 (lambda _
400 (substitute* "Makefile.in"
401 (("command -p") ""))
402 #t))
403 (add-after 'install 'install-docs
404 (lambda* (#:key outputs #:allow-other-keys)
405 (let* ((out (assoc-ref %outputs "out"))
406 (misc (string-append out "/share/doc/scrypt")))
407 (install-file "FORMAT" misc)
408 #t))))))
409 (inputs
410 `(("openssl" ,openssl)))
411 (home-page "https://www.tarsnap.com/scrypt.html")
412 (synopsis "Memory-hard encryption tool based on scrypt")
413 (description "This packages provides a simple password-based encryption
414 utility as a demonstration of the @code{scrypt} key derivation function.
415 @code{Scrypt} is designed to be far more resistant against hardware brute-force
416 attacks than alternative functions such as @code{PBKDF2} or @code{bcrypt}.")
417 (license license:bsd-2)))
418
419 (define-public python-asn1crypto
420 (package
421 (name "python-asn1crypto")
422 (version "0.22.0")
423 (source
424 (origin
425 (method url-fetch)
426 (uri (string-append "https://github.com/wbond/asn1crypto/archive/"
427 version ".tar.gz"))
428 (sha256
429 (base32
430 "1kn910896l3knmilla1c9ly20q181s43w1ah08lzkbm1h3j6pcz0"))))
431 (build-system python-build-system)
432 (home-page "https://github.com/wbond/asn1crypto")
433 (synopsis "ASN.1 parser and serializer in Python")
434 (description "asn1crypto is an ASN.1 parser and serializer with definitions
435 for private keys, public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7,
436 PKCS#8, PKCS#12, PKCS#5, X.509 and TSP.")
437 (license license:expat)))
438
439 (define-public python2-asn1crypto
440 (package-with-python2 python-asn1crypto))
441
442 (define-public perl-math-random-isaac-xs
443 (package
444 (name "perl-math-random-isaac-xs")
445 (version "1.004")
446 (source
447 (origin
448 (method url-fetch)
449 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
450 "Math-Random-ISAAC-XS-" version ".tar.gz"))
451 (sha256
452 (base32
453 "0yxqqcqvj51fn7b7j5xqhz65v74arzgainn66c6k7inijbmr1xws"))))
454 (build-system perl-build-system)
455 (native-inputs
456 `(("perl-module-build" ,perl-module-build)
457 ("perl-test-nowarnings" ,perl-test-nowarnings)))
458 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC-XS")
459 (synopsis "C implementation of the ISAAC PRNG algorithm")
460 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
461 fast pseudo-random number generator. It is suitable for applications where a
462 significant amount of random data needs to be produced quickly, such as
463 solving using the Monte Carlo method or for games. The results are uniformly
464 distributed, unbiased, and unpredictable unless you know the seed.
465
466 This package implements the same interface as @code{Math::Random::ISAAC}.")
467 (license license:public-domain)))
468
469 (define-public perl-math-random-isaac
470 (package
471 (name "perl-math-random-isaac")
472 (version "1.004")
473 (source
474 (origin
475 (method url-fetch)
476 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
477 "Math-Random-ISAAC-" version ".tar.gz"))
478 (sha256
479 (base32
480 "0z1b3xbb3xz71h25fg6jgsccra7migq7s0vawx2rfzi0pwpz0wr7"))))
481 (build-system perl-build-system)
482 (native-inputs
483 `(("perl-test-nowarnings" ,perl-test-nowarnings)))
484 (propagated-inputs
485 `(("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)))
486 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC")
487 (synopsis "Perl interface to the ISAAC PRNG algorithm")
488 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
489 fast pseudo-random number generator. It is suitable for applications where a
490 significant amount of random data needs to be produced quickly, such as
491 solving using the Monte Carlo method or for games. The results are uniformly
492 distributed, unbiased, and unpredictable unless you know the seed.
493
494 This package provides a Perl interface to the ISAAC pseudo random number
495 generator.")
496 (license license:public-domain)))
497
498 (define-public perl-crypt-random-source
499 (package
500 (name "perl-crypt-random-source")
501 (version "0.12")
502 (source
503 (origin
504 (method url-fetch)
505 (uri (string-append "mirror://cpan/authors/id/E/ET/ETHER/"
506 "Crypt-Random-Source-" version ".tar.gz"))
507 (sha256
508 (base32
509 "00mw5m52sbz9nqp3f6axyrgcrihqxn7k8gv0vi1kvm1j1nc9g29h"))))
510 (build-system perl-build-system)
511 (native-inputs
512 `(("perl-module-build-tiny" ,perl-module-build-tiny)
513 ("perl-test-exception" ,perl-test-exception)))
514 (propagated-inputs
515 `(("perl-capture-tiny" ,perl-capture-tiny)
516 ("perl-module-find" ,perl-module-find)
517 ("perl-module-runtime" ,perl-module-runtime)
518 ("perl-moo" ,perl-moo)
519 ("perl-namespace-clean" ,perl-namespace-clean)
520 ("perl-sub-exporter" ,perl-sub-exporter)
521 ("perl-type-tiny" ,perl-type-tiny)))
522 (home-page "http://search.cpan.org/dist/Crypt-Random-Source")
523 (synopsis "Get weak or strong random data from pluggable sources")
524 (description "This module provides implementations for a number of
525 byte-oriented sources of random data.")
526 (license (package-license perl))))
527
528 (define-public perl-math-random-secure
529 (package
530 (name "perl-math-random-secure")
531 (version "0.080001")
532 (source
533 (origin
534 (method url-fetch)
535 (uri (string-append "mirror://cpan/authors/id/F/FR/FREW/"
536 "Math-Random-Secure-" version ".tar.gz"))
537 (sha256
538 (base32
539 "0dgbf4ncll4kmgkyb9fsaxn0vf2smc9dmwqzgh3259zc2zla995z"))))
540 (build-system perl-build-system)
541 (native-inputs
542 `(("perl-list-moreutils" ,perl-list-moreutils)
543 ("perl-test-leaktrace" ,perl-test-leaktrace)
544 ("perl-test-sharedfork" ,perl-test-sharedfork)
545 ("perl-test-warn" ,perl-test-warn)))
546 (inputs
547 `(("perl-crypt-random-source" ,perl-crypt-random-source)
548 ("perl-math-random-isaac" ,perl-math-random-isaac)
549 ("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)
550 ("perl-moo" ,perl-moo)))
551 (home-page "http://search.cpan.org/dist/Math-Random-Secure")
552 (synopsis "Cryptographically secure replacement for rand()")
553 (description "This module is intended to provide a
554 cryptographically-secure replacement for Perl's built-in @code{rand} function.
555 \"Crytographically secure\", in this case, means:
556
557 @enumerate
558 @item No matter how many numbers you see generated by the random number
559 generator, you cannot guess the future numbers, and you cannot guess the seed.
560 @item There are so many possible seeds that it would take decades, centuries,
561 or millenia for an attacker to try them all.
562 @item The seed comes from a source that generates relatively strong random
563 data on your platform, so the seed itself will be as random as possible.
564 @end enumerate\n")
565 (license license:artistic2.0)))