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>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
58 (define-public libsodium
64 (uri (list (string-append
65 "http://download.libsodium.org/libsodium/"
66 "releases/libsodium-" version ".tar.gz")
68 "https://download.libsodium.org/libsodium/"
69 "releases/old/libsodium-" version ".tar.gz")))
72 "1z93wfg4k5svg8yck6cgdr6ysj91kbpn03nyzwxanncy3b5sq4ww"))))
73 (build-system gnu-build-system)
74 (synopsis "Portable NaCl-based crypto library")
76 "Sodium is a new easy-to-use high-speed software library for network
77 communication, encryption, decryption, signatures, etc.")
79 (home-page "http://libsodium.org")))
81 (define-public signify
87 (uri (string-append "https://github.com/aperezdc/signify/"
88 "archive/v" version ".tar.gz"))
89 (file-name (string-append name "-" version ".tar.gz"))
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().
97 `(#:tests? #f ; no test suite
100 (string-append "PREFIX=" (assoc-ref %outputs "out")))
102 (modify-phases %standard-phases
103 (delete 'configure))))
105 `(("pkg-config" ,pkg-config)))
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
118 "See base64.c in the distribution for
119 the license from IBM.")))))
122 (define-public opendht
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)))
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") ""))))
147 "09yvkmbqbym3b5md4n96qc1s9sf2n8ji404hagih45rmsj49599x"))))
148 (build-system gnu-build-system)
152 ("readline" ,readline)
155 `(("msgpack" ,msgpack))) ;included in several installed headers
157 `(("autoconf" ,autoconf)
158 ("pkg-config" ,pkg-config)
159 ("automake" ,automake)
160 ("libtool" ,libtool)))
162 `(#:configure-flags '("--disable-tools" "--disable-python")
163 #:phases (modify-phases %standard-phases
164 (add-before 'configure 'autoconf
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
172 (license license:gpl3)))
182 (string-append "https://github.com/vgough/encfs/releases/download/v"
183 version "/encfs-" version ".tar.gz"))
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)
194 `(("gettext" ,gettext-minimal)
196 ;; Test dependencies.
203 ("tinyxml2" ,tinyxml2)))
205 `(#:configure-flags (list "-DUSE_INTERNAL_TINYXML=OFF")))
206 (home-page "https://vgough.github.io/encfs")
207 (synopsis "Encrypted virtual file system")
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
214 (license (list license:expat ; internal/easylogging++.h
215 license:lgpl3+ ; encfs library
216 license:gpl3+)))) ; command-line tools
218 (define-public keyutils
226 (string-append "https://people.redhat.com/dhowells/keyutils/keyutils-"
230 "1bl3w03ygxhc0hz69klfdlwqn33jvzxl1zfl2jmnb2v85iawb8jd"))
231 (modules '((guix build utils)))
232 ;; Create relative symbolic links instead of absolute ones to /lib/*
233 (snippet '(substitute* "Makefile" (("\\$\\(LNS\\) \\$\\(LIBDIR\\)/")
235 (build-system gnu-build-system)
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"
246 "SHAREDIR=/share/keyutils")
247 #:test-target "test"))
248 (home-page "https://people.redhat.com/dhowells/keyutils/")
249 (synopsis "Linux key management utilities")
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
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")
265 (version (string-append "1.2.0-" revision "." (string-take commit 7)))
270 (url "https://github.com/schnabear/eschalot")
272 (file-name (string-append name "-" version))
275 "0lj38ldh8vzi11wp4ghw4k0fkwp0s04zv8k8d473p1snmbh7mx98"))))
277 `(("openssl" ,openssl))) ; It needs: openssl/{bn,pem,rsa,sha}.h
278 (build-system gnu-build-system)
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.
288 (modify-phases %standard-phases
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")))
306 (home-page "https://github.com/schnabear/eschalot")
307 (synopsis "Tor hidden service name generator")
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)))))
322 (uri (string-append "https://files.dyne.org/tomb/"
323 "Tomb-" version ".tar.gz"))
326 "1hv1w79as7swqj0n137vz8n8mwvcgwlvd91sdyssz41jarg7f1vr"))))
327 (build-system gnu-build-system)
328 (native-inputs `(("sudo" ,sudo))) ;presence needed for 'check' phase
332 ("cryptsetup" ,cryptsetup)
333 ("e2fsprogs" ,e2fsprogs) ;for mkfs.ext4
334 ("gettext" ,gettext-minimal) ;used at runtime
336 ("pinentry" ,pinentry)
337 ("qrencode" ,qrencode)
338 ("steghide" ,steghide)))
340 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
341 ;; TODO: Build and install gtk and qt trays
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")
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")))))
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")
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")
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+)))
383 (define-public scrypt
390 (uri (string-append "https://www.tarsnap.com/scrypt/scrypt-"
394 "0xy5yhrwwv13skv9im9vm76rybh9f29j2dh4hlh2x01gvbkza8a6"))))
395 (build-system gnu-build-system)
397 `(#:phases (modify-phases %standard-phases
398 (add-after 'unpack 'patch-command-invocations
400 (substitute* "Makefile.in"
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)
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)))
419 (define-public python-asn1crypto
421 (name "python-asn1crypto")
426 (uri (string-append "https://github.com/wbond/asn1crypto/archive/"
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)))
439 (define-public python2-asn1crypto
440 (package-with-python2 python-asn1crypto))
442 (define-public perl-math-random-isaac-xs
444 (name "perl-math-random-isaac-xs")
449 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
450 "Math-Random-ISAAC-XS-" version ".tar.gz"))
453 "0yxqqcqvj51fn7b7j5xqhz65v74arzgainn66c6k7inijbmr1xws"))))
454 (build-system perl-build-system)
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.
466 This package implements the same interface as @code{Math::Random::ISAAC}.")
467 (license license:public-domain)))
469 (define-public perl-math-random-isaac
471 (name "perl-math-random-isaac")
476 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
477 "Math-Random-ISAAC-" version ".tar.gz"))
480 "0z1b3xbb3xz71h25fg6jgsccra7migq7s0vawx2rfzi0pwpz0wr7"))))
481 (build-system perl-build-system)
483 `(("perl-test-nowarnings" ,perl-test-nowarnings)))
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.
494 This package provides a Perl interface to the ISAAC pseudo random number
496 (license license:public-domain)))
498 (define-public perl-crypt-random-source
500 (name "perl-crypt-random-source")
505 (uri (string-append "mirror://cpan/authors/id/E/ET/ETHER/"
506 "Crypt-Random-Source-" version ".tar.gz"))
509 "00mw5m52sbz9nqp3f6axyrgcrihqxn7k8gv0vi1kvm1j1nc9g29h"))))
510 (build-system perl-build-system)
512 `(("perl-module-build-tiny" ,perl-module-build-tiny)
513 ("perl-test-exception" ,perl-test-exception)))
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))))
528 (define-public perl-math-random-secure
530 (name "perl-math-random-secure")
535 (uri (string-append "mirror://cpan/authors/id/F/FR/FREW/"
536 "Math-Random-Secure-" version ".tar.gz"))
539 "0dgbf4ncll4kmgkyb9fsaxn0vf2smc9dmwqzgh3259zc2zla995z"))))
540 (build-system perl-build-system)
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)))
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:
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.
565 (license license:artistic2.0)))