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, 2017 ng0 <ng0@infotropique.org>
8 ;;; Copyright © 2016, 2017 Eric Bavier <bavier@member.fsf.org>
9 ;;; Copyright © 2017 Pierre Langlois <pierre.langlois@gmx.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages crypto)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages admin)
29 #:use-module (gnu packages aidc)
30 #:use-module (gnu packages attr)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages boost)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages cryptsetup)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages gnupg)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages libbsd)
40 #:use-module (gnu packages libffi)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages nettle)
43 #:use-module (gnu packages password-utils)
44 #:use-module (gnu packages perl)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages readline)
47 #:use-module (gnu packages search)
48 #:use-module (gnu packages serialization)
49 #:use-module (gnu packages shells)
50 #:use-module (gnu packages tcl)
51 #:use-module (gnu packages tls)
52 #:use-module (gnu packages xml)
53 #:use-module ((guix licenses) #:prefix license:)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix build-system cmake)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix build-system perl)
60 #:use-module (guix build-system python))
62 (define-public libsodium
68 (uri (list (string-append
69 "https://download.libsodium.org/libsodium/"
70 "releases/libsodium-" version ".tar.gz")
72 "https://download.libsodium.org/libsodium/"
73 "releases/old/libsodium-" version ".tar.gz")))
76 "1x3qw7lsz44vcxpcn1dvwig410phg6gmv31jwj94arrgka3rwspv"))))
77 (build-system gnu-build-system)
78 (synopsis "Portable NaCl-based crypto library")
80 "Sodium is a new easy-to-use high-speed software library for network
81 communication, encryption, decryption, signatures, etc.")
83 (home-page "https://libsodium.org")))
92 "https://archive.hadrons.org/software/libmd/libmd-"
97 "121s73pgbqsnmy6xblbrkj9y44c5zzzpf2hcmh6zvcvg4dk26gzx"))))
98 (build-system gnu-build-system)
99 (synopsis "Message Digest functions from BSD systems")
101 "The currently provided message digest algorithms are:
108 @item SHA-2 (SHA-256, SHA-384 and SHA-512)
110 (license (list license:bsd-3
113 license:public-domain))
114 (home-page "https://www.hadrons.org/software/libmd/")))
116 (define-public signify
122 (uri (string-append "https://github.com/aperezdc/signify/"
123 "archive/v" version ".tar.gz"))
124 (file-name (string-append name "-" version ".tar.gz"))
127 "0iv5bjaas70ymqchxasapin4c32c41kqzkfhc3kcjzd7rxy78msy"))))
128 (build-system gnu-build-system)
129 ;; TODO Build with libwaive (described in README.md), to implement something
130 ;; like OpenBSD's pledge().
132 `(#:tests? #f ; no test suite
135 (string-append "PREFIX=" (assoc-ref %outputs "out")))
137 (modify-phases %standard-phases
138 (delete 'configure))))
140 `(("pkg-config" ,pkg-config)))
142 `(("libbsd" ,libbsd)))
143 (synopsis "Create and verify cryptographic signatures")
144 (description "The signify utility creates and verifies cryptographic
145 signatures using the elliptic curve Ed25519. This is a Linux port of the
146 OpenBSD tool of the same name.")
147 (home-page "https://github.com/aperezdc/signify")
148 ;; This package includes third-party code that was originally released under
149 ;; various non-copyleft licenses. See the source files for clarification.
150 (license (list license:bsd-3 license:bsd-4 license:expat license:isc
151 license:public-domain (license:non-copyleft
153 "See base64.c in the distribution for
154 the license from IBM.")))))
157 (define-public opendht
166 "https://github.com/savoirfairelinux/" name
167 "/archive/" version ".tar.gz"))
168 (file-name (string-append name "-" version ".tar.gz"))
169 (modules '((guix build utils)))
172 (delete-file-recursively "src/argon2")
173 (substitute* "src/Makefile.am"
174 (("./argon2/libargon2.la") "")
175 (("SUBDIRS = argon2") ""))
176 (substitute* "src/crypto.cpp"
177 (("argon2/argon2.h") "argon2.h"))
178 (substitute* "configure.ac"
179 (("src/argon2/Makefile") ""))))
182 "09yvkmbqbym3b5md4n96qc1s9sf2n8ji404hagih45rmsj49599x"))))
183 (build-system gnu-build-system)
187 ("readline" ,readline)
190 `(("msgpack" ,msgpack))) ;included in several installed headers
192 `(("autoconf" ,autoconf)
193 ("pkg-config" ,pkg-config)
194 ("automake" ,automake)
195 ("libtool" ,libtool)))
197 `(#:configure-flags '("--disable-tools" "--disable-python")
198 #:phases (modify-phases %standard-phases
199 (add-after 'unpack 'autoconf
201 (zero? (system* "autoreconf" "-vfi")))))))
202 (home-page "https://github.com/savoirfairelinux/opendht/")
203 (synopsis "Distributed Hash Table (DHT) library")
204 (description "OpenDHT is a Distributed Hash Table (DHT) library. It may
205 be used to manage peer-to-peer network connections as needed for real time
207 (license license:gpl3)))
217 (string-append "https://github.com/vgough/encfs/releases/download/v"
218 version "/encfs-" version ".tar.gz"))
221 "1906254dg5hwljh0h4gyrw09ms3b57dlhjfzhfzffv50yzpkl837"))
222 (modules '((guix build utils)))
223 ;; Remove bundled dependencies in favour of proper inputs.
224 (snippet '(for-each delete-file-recursively
225 (find-files "internal" "^tinyxml2-[0-9]"
226 #:directories? #t)))))
227 (build-system cmake-build-system)
229 `(("gettext" ,gettext-minimal)
231 ;; Test dependencies.
238 ("tinyxml2" ,tinyxml2)))
240 `(#:configure-flags (list "-DUSE_INTERNAL_TINYXML=OFF")))
241 (home-page "https://vgough.github.io/encfs")
242 (synopsis "Encrypted virtual file system")
244 "EncFS creates a virtual encrypted file system in user-space. Each file
245 created under an EncFS mount point is stored as a separate encrypted file on
246 the underlying file system. Like most encrypted file systems, EncFS is meant
247 to provide security against off-line attacks, such as a drive falling into
249 (license (list license:expat ; internal/easylogging++.h
250 license:lgpl3+ ; encfs library
251 license:gpl3+)))) ; command-line tools
253 (define-public keyutils
261 (string-append "https://people.redhat.com/dhowells/keyutils/keyutils-"
265 "1bl3w03ygxhc0hz69klfdlwqn33jvzxl1zfl2jmnb2v85iawb8jd"))
266 (modules '((guix build utils)))
267 ;; Create relative symbolic links instead of absolute ones to /lib/*
268 (snippet '(substitute* "Makefile" (("\\$\\(LNS\\) \\$\\(LIBDIR\\)/")
270 (build-system gnu-build-system)
272 `(#:phases (modify-phases %standard-phases
273 (delete 'configure)) ; no configure script
274 #:make-flags (list "CC=gcc"
275 "RPATH=-Wl,-rpath,$(DESTDIR)$(LIBDIR)"
276 (string-append "DESTDIR="
277 (assoc-ref %outputs "out"))
278 "INCLUDEDIR=/include"
281 "SHAREDIR=/share/keyutils")
282 #:test-target "test"))
283 (home-page "https://people.redhat.com/dhowells/keyutils/")
284 (synopsis "Linux key management utilities")
286 "Keyutils is a set of utilities for managing the key retention facility in
287 the Linux kernel, which can be used by file systems, block devices, and more to
288 gain and retain the authorization and encryption keys required to perform
289 secure operations. ")
290 (license (list license:lgpl2.1+ ; the files keyutils.*
291 license:gpl2+)))) ; the rest
293 ;; There is no release candidate but commits point out a version number,
294 ;; furthermore no tarball exists.
295 (define-public eschalot
296 (let ((commit "0bf31d88a11898c19b1ed25ddd2aff7b35dbac44")
300 (version (string-append "1.2.0-" revision "." (string-take commit 7)))
305 (url "https://github.com/schnabear/eschalot")
307 (file-name (string-append name "-" version))
310 "0lj38ldh8vzi11wp4ghw4k0fkwp0s04zv8k8d473p1snmbh7mx98"))))
312 `(("openssl" ,openssl))) ; It needs: openssl/{bn,pem,rsa,sha}.h
313 (build-system gnu-build-system)
315 `(#:make-flags (list "CC=gcc"
316 (string-append "PREFIX=" (assoc-ref %outputs "out"))
317 (string-append "INSTALL=" "install"))
318 ;; XXX: make test would run a !VERY! long hashing of names with the use
319 ;; of a wordlist, the amount of computing time this would waste on build
320 ;; servers is in no relation to the size or importance of this small
321 ;; application, therefore we run our own tests on eschalot and worgen.
323 (modify-phases %standard-phases
328 (zero? (system* "./worgen" "8-12" "top1000.txt" "3-10" "top400nouns.txt"
329 "3-6" "top150adjectives.txt" "3-6"))
330 (zero? (system* "./eschalot" "-r" "^guix|^guixsd"))
331 (zero? (system* "./eschalot" "-r" "^gnu|^free"))
332 (zero? (system* "./eschalot" "-r" "^cyber|^hack"))
333 (zero? (system* "./eschalot" "-r" "^troll")))))
334 ;; Make install can not create the bin dir, create it.
335 (add-before 'install 'create-bin-dir
336 (lambda* (#:key outputs #:allow-other-keys)
337 (let* ((out (assoc-ref outputs "out"))
338 (bin (string-append out "/bin")))
341 (home-page "https://github.com/schnabear/eschalot")
342 (synopsis "Tor hidden service name generator")
344 "Eschalot is a tor hidden service name generator, it allows one to
345 produce customized vanity .onion addresses using a brute-force method. Searches
346 for valid names can be run with regular expressions and wordlists. For the
347 generation of wordlists the included tool @code{worgen} can be used. There is
348 no man page, refer to the home page for usage details.")
349 (license (list license:isc license:expat)))))
357 (uri (string-append "https://files.dyne.org/tomb/"
358 "Tomb-" version ".tar.gz"))
361 "1hv1w79as7swqj0n137vz8n8mwvcgwlvd91sdyssz41jarg7f1vr"))))
362 (build-system gnu-build-system)
363 (native-inputs `(("sudo" ,sudo))) ;presence needed for 'check' phase
367 ("cryptsetup" ,cryptsetup)
368 ("e2fsprogs" ,e2fsprogs) ;for mkfs.ext4
369 ("gettext" ,gettext-minimal) ;used at runtime
371 ("pinentry" ,pinentry)
372 ("qrencode" ,qrencode)
373 ("steghide" ,steghide)))
375 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
376 ;; TODO: Build and install gtk and qt trays
378 (modify-phases %standard-phases
379 (delete 'configure) ;no configuration to be done
380 (add-after 'install 'i18n
381 (lambda* (#:key make-flags #:allow-other-keys)
382 (zero? (apply system*
383 "make" "-C" "extras/translations"
384 "install" make-flags))))
385 (add-after 'install 'wrap
386 (lambda* (#:key inputs outputs #:allow-other-keys)
387 (let ((out (assoc-ref outputs "out")))
388 (wrap-program (string-append out "/bin/tomb")
390 (,(string-append (assoc-ref inputs "mlocate") "/bin")
391 ,@(map (lambda (program)
392 (or (and=> (which program) dirname)
393 (error "program not found:" program)))
394 '("seq" "mkfs.ext4" "pinentry" "sudo"
395 "gpg" "cryptsetup" "gettext"
396 "qrencode" "steghide")))))
399 (add-after 'wrap 'check
400 (lambda* (#:key outputs #:allow-other-keys)
401 ;; Running the full tests requires sudo/root access for
402 ;; cryptsetup, which is not available in the build environment.
403 ;; But we can run `tomb dig` without root, so make sure that
404 ;; works. TODO: It Would Be Nice to check the expected "index",
405 ;; "search", "bury", and "exhume" features are available by
406 ;; querying `tomb -h`.
407 (let ((tomb (string-append (assoc-ref outputs "out")
409 (zero? (system* tomb "dig" "-s" "10" "secrets.tomb"))))))))
410 (home-page "http://www.dyne.org/software/tomb")
411 (synopsis "File encryption for secret data")
413 "Tomb is an application to manage the creation and access of encrypted
414 storage files: it can be operated from commandline and it can integrate with a
415 user's graphical desktop.")
416 (license license:gpl3+)))
418 (define-public scrypt
425 (uri (string-append "https://www.tarsnap.com/scrypt/scrypt-"
429 "0xy5yhrwwv13skv9im9vm76rybh9f29j2dh4hlh2x01gvbkza8a6"))))
430 (build-system gnu-build-system)
432 `(#:phases (modify-phases %standard-phases
433 (add-after 'unpack 'patch-command-invocations
435 (substitute* "Makefile.in"
438 (add-after 'install 'install-docs
439 (lambda* (#:key outputs #:allow-other-keys)
440 (let* ((out (assoc-ref %outputs "out"))
441 (misc (string-append out "/share/doc/scrypt")))
442 (install-file "FORMAT" misc)
445 `(("openssl" ,openssl)))
446 (home-page "https://www.tarsnap.com/scrypt.html")
447 (synopsis "Memory-hard encryption tool based on scrypt")
448 (description "This packages provides a simple password-based encryption
449 utility as a demonstration of the @code{scrypt} key derivation function.
450 @code{Scrypt} is designed to be far more resistant against hardware brute-force
451 attacks than alternative functions such as @code{PBKDF2} or @code{bcrypt}.")
452 (license license:bsd-2)))
454 (define-public python-asn1crypto
456 (name "python-asn1crypto")
461 (uri (string-append "https://github.com/wbond/asn1crypto/archive/"
465 "1kn910896l3knmilla1c9ly20q181s43w1ah08lzkbm1h3j6pcz0"))))
466 (build-system python-build-system)
467 (home-page "https://github.com/wbond/asn1crypto")
468 (synopsis "ASN.1 parser and serializer in Python")
469 (description "asn1crypto is an ASN.1 parser and serializer with definitions
470 for private keys, public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7,
471 PKCS#8, PKCS#12, PKCS#5, X.509 and TSP.")
472 (license license:expat)))
474 (define-public python2-asn1crypto
475 (package-with-python2 python-asn1crypto))
477 (define-public perl-math-random-isaac-xs
479 (name "perl-math-random-isaac-xs")
484 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
485 "Math-Random-ISAAC-XS-" version ".tar.gz"))
488 "0yxqqcqvj51fn7b7j5xqhz65v74arzgainn66c6k7inijbmr1xws"))))
489 (build-system perl-build-system)
491 `(("perl-module-build" ,perl-module-build)
492 ("perl-test-nowarnings" ,perl-test-nowarnings)))
493 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC-XS")
494 (synopsis "C implementation of the ISAAC PRNG algorithm")
495 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
496 fast pseudo-random number generator. It is suitable for applications where a
497 significant amount of random data needs to be produced quickly, such as
498 solving using the Monte Carlo method or for games. The results are uniformly
499 distributed, unbiased, and unpredictable unless you know the seed.
501 This package implements the same interface as @code{Math::Random::ISAAC}.")
502 (license license:public-domain)))
504 (define-public perl-math-random-isaac
506 (name "perl-math-random-isaac")
511 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
512 "Math-Random-ISAAC-" version ".tar.gz"))
515 "0z1b3xbb3xz71h25fg6jgsccra7migq7s0vawx2rfzi0pwpz0wr7"))))
516 (build-system perl-build-system)
518 `(("perl-test-nowarnings" ,perl-test-nowarnings)))
520 `(("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)))
521 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC")
522 (synopsis "Perl interface to the ISAAC PRNG algorithm")
523 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
524 fast pseudo-random number generator. It is suitable for applications where a
525 significant amount of random data needs to be produced quickly, such as
526 solving using the Monte Carlo method or for games. The results are uniformly
527 distributed, unbiased, and unpredictable unless you know the seed.
529 This package provides a Perl interface to the ISAAC pseudo random number
531 (license license:public-domain)))
533 (define-public perl-crypt-random-source
535 (name "perl-crypt-random-source")
540 (uri (string-append "mirror://cpan/authors/id/E/ET/ETHER/"
541 "Crypt-Random-Source-" version ".tar.gz"))
544 "00mw5m52sbz9nqp3f6axyrgcrihqxn7k8gv0vi1kvm1j1nc9g29h"))))
545 (build-system perl-build-system)
547 `(("perl-module-build-tiny" ,perl-module-build-tiny)
548 ("perl-test-exception" ,perl-test-exception)))
550 `(("perl-capture-tiny" ,perl-capture-tiny)
551 ("perl-module-find" ,perl-module-find)
552 ("perl-module-runtime" ,perl-module-runtime)
553 ("perl-moo" ,perl-moo)
554 ("perl-namespace-clean" ,perl-namespace-clean)
555 ("perl-sub-exporter" ,perl-sub-exporter)
556 ("perl-type-tiny" ,perl-type-tiny)))
557 (home-page "http://search.cpan.org/dist/Crypt-Random-Source")
558 (synopsis "Get weak or strong random data from pluggable sources")
559 (description "This module provides implementations for a number of
560 byte-oriented sources of random data.")
561 (license license:perl-license)))
563 (define-public perl-math-random-secure
565 (name "perl-math-random-secure")
570 (uri (string-append "mirror://cpan/authors/id/F/FR/FREW/"
571 "Math-Random-Secure-" version ".tar.gz"))
574 "0dgbf4ncll4kmgkyb9fsaxn0vf2smc9dmwqzgh3259zc2zla995z"))))
575 (build-system perl-build-system)
577 `(("perl-list-moreutils" ,perl-list-moreutils)
578 ("perl-test-leaktrace" ,perl-test-leaktrace)
579 ("perl-test-sharedfork" ,perl-test-sharedfork)
580 ("perl-test-warn" ,perl-test-warn)))
582 `(("perl-crypt-random-source" ,perl-crypt-random-source)
583 ("perl-math-random-isaac" ,perl-math-random-isaac)
584 ("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)
585 ("perl-moo" ,perl-moo)))
586 (home-page "http://search.cpan.org/dist/Math-Random-Secure")
587 (synopsis "Cryptographically secure replacement for rand()")
588 (description "This module is intended to provide a
589 cryptographically-secure replacement for Perl's built-in @code{rand} function.
590 \"Crytographically secure\", in this case, means:
593 @item No matter how many numbers you see generated by the random number
594 generator, you cannot guess the future numbers, and you cannot guess the seed.
595 @item There are so many possible seeds that it would take decades, centuries,
596 or millenia for an attacker to try them all.
597 @item The seed comes from a source that generates relatively strong random
598 data on your platform, so the seed itself will be as random as possible.
600 (license license:artistic2.0)))
602 (define-public python-pynacl
604 (name "python-pynacl")
609 (uri (pypi-uri "PyNaCl" version))
610 (modules '((guix build utils)))
611 ;; Remove bundled libsodium
612 (snippet '(delete-file-recursively "src/libsodium"))
615 "135gz0020fqx8fbr9izpwyq49aww202nkqacq0cw61xz99sjpx9j"))))
616 (build-system python-build-system)
619 (modify-phases %standard-phases
620 (add-before 'build 'use-system-sodium
622 (setenv "SODIUM_INSTALL" "system")
625 `(("python-pytest" ,python-pytest)))
627 `(("python-cffi" ,python-cffi)
628 ("python-six" ,python-six)
629 ("libsodium" ,libsodium)))
630 (home-page "https://github.com/pyca/pynacl/")
631 (synopsis "Python bindings to libsodium")
633 "PyNaCl is a Python binding to libsodium, which is a fork of the
634 Networking and Cryptography library. These libraries have a stated goal
635 of improving usability, security and speed.")
636 (license license:asl2.0)))
638 (define-public crypto++
643 (method url-fetch/zipbomb)
644 (uri (string-append "https://cryptopp.com/cryptopp"
645 (string-join (string-split version #\.) "")
649 "0d1cqdz369ivi082k59025wvxzywvkizw7i0pf5h0a1izs3g8pm7"))
651 (search-patches "crypto++-fix-dos-in-asn.1-decoders.patch"))))
652 (build-system gnu-build-system)
655 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
657 (modify-phases %standard-phases
658 (delete 'configure))))
661 (home-page "https://cryptopp.com/")
662 (synopsis "C++ class library of cryptographic schemes")
663 (description "Crypto++ is a C++ class library of cryptographic schemes.")
664 ;; The compilation is distributed under the Boost license; the individual
665 ;; files in the compilation are in the public domain.
666 (license (list license:boost1.0 license:public-domain))))