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>
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 libffi)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages nettle)
41 #:use-module (gnu packages password-utils)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages readline)
45 #:use-module (gnu packages search)
46 #:use-module (gnu packages serialization)
47 #:use-module (gnu packages shells)
48 #:use-module (gnu packages tcl)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages xml)
51 #:use-module ((guix licenses) #:prefix license:)
52 #:use-module (guix packages)
53 #:use-module (guix download)
54 #:use-module (guix git-download)
55 #:use-module (guix build-system cmake)
56 #:use-module (guix build-system gnu)
57 #:use-module (guix build-system perl)
58 #:use-module (guix build-system python))
60 (define-public libsodium
66 (uri (list (string-append
67 "https://download.libsodium.org/libsodium/"
68 "releases/libsodium-" version ".tar.gz")
70 "https://download.libsodium.org/libsodium/"
71 "releases/old/libsodium-" version ".tar.gz")))
74 "1x3qw7lsz44vcxpcn1dvwig410phg6gmv31jwj94arrgka3rwspv"))))
75 (build-system gnu-build-system)
76 (synopsis "Portable NaCl-based crypto library")
78 "Sodium is a new easy-to-use high-speed software library for network
79 communication, encryption, decryption, signatures, etc.")
81 (home-page "https://libsodium.org")))
90 "https://archive.hadrons.org/software/libmd/libmd-"
95 "121s73pgbqsnmy6xblbrkj9y44c5zzzpf2hcmh6zvcvg4dk26gzx"))))
96 (build-system gnu-build-system)
97 (synopsis "Message Digest functions from BSD systems")
99 "The currently provided message digest algorithms are:
106 @item SHA-2 (SHA-256, SHA-384 and SHA-512)
108 (license (list license:bsd-3
111 license:public-domain))
112 (home-page "https://www.hadrons.org/software/libmd/")))
114 (define-public signify
120 (uri (string-append "https://github.com/aperezdc/signify/"
121 "archive/v" version ".tar.gz"))
122 (file-name (string-append name "-" version ".tar.gz"))
125 "0iv5bjaas70ymqchxasapin4c32c41kqzkfhc3kcjzd7rxy78msy"))))
126 (build-system gnu-build-system)
127 ;; TODO Build with libwaive (described in README.md), to implement something
128 ;; like OpenBSD's pledge().
130 `(#:tests? #f ; no test suite
133 (string-append "PREFIX=" (assoc-ref %outputs "out")))
135 (modify-phases %standard-phases
136 (delete 'configure))))
138 `(("pkg-config" ,pkg-config)))
140 `(("libbsd" ,libbsd)))
141 (synopsis "Create and verify cryptographic signatures")
142 (description "The signify utility creates and verifies cryptographic
143 signatures using the elliptic curve Ed25519. This is a Linux port of the
144 OpenBSD tool of the same name.")
145 (home-page "https://github.com/aperezdc/signify")
146 ;; This package includes third-party code that was originally released under
147 ;; various non-copyleft licenses. See the source files for clarification.
148 (license (list license:bsd-3 license:bsd-4 license:expat license:isc
149 license:public-domain (license:non-copyleft
151 "See base64.c in the distribution for
152 the license from IBM.")))))
155 (define-public opendht
164 "https://github.com/savoirfairelinux/" name
165 "/archive/" version ".tar.gz"))
166 (file-name (string-append name "-" version ".tar.gz"))
167 (modules '((guix build utils)))
170 (delete-file-recursively "src/argon2")
171 (substitute* "src/Makefile.am"
172 (("./argon2/libargon2.la") "")
173 (("SUBDIRS = argon2") ""))
174 (substitute* "src/crypto.cpp"
175 (("argon2/argon2.h") "argon2.h"))
176 (substitute* "configure.ac"
177 (("src/argon2/Makefile") ""))))
180 "09yvkmbqbym3b5md4n96qc1s9sf2n8ji404hagih45rmsj49599x"))))
181 (build-system gnu-build-system)
185 ("readline" ,readline)
188 `(("msgpack" ,msgpack))) ;included in several installed headers
190 `(("autoconf" ,autoconf)
191 ("pkg-config" ,pkg-config)
192 ("automake" ,automake)
193 ("libtool" ,libtool)))
195 `(#:configure-flags '("--disable-tools" "--disable-python")
196 #:phases (modify-phases %standard-phases
197 (add-after 'unpack 'autoconf
199 (zero? (system* "autoreconf" "-vfi")))))))
200 (home-page "https://github.com/savoirfairelinux/opendht/")
201 (synopsis "Distributed Hash Table (DHT) library")
202 (description "OpenDHT is a Distributed Hash Table (DHT) library. It may
203 be used to manage peer-to-peer network connections as needed for real time
205 (license license:gpl3)))
215 (string-append "https://github.com/vgough/encfs/releases/download/v"
216 version "/encfs-" version ".tar.gz"))
219 "1906254dg5hwljh0h4gyrw09ms3b57dlhjfzhfzffv50yzpkl837"))
220 (modules '((guix build utils)))
221 ;; Remove bundled dependencies in favour of proper inputs.
222 (snippet '(for-each delete-file-recursively
223 (find-files "internal" "^tinyxml2-[0-9]"
224 #:directories? #t)))))
225 (build-system cmake-build-system)
227 `(("gettext" ,gettext-minimal)
229 ;; Test dependencies.
236 ("tinyxml2" ,tinyxml2)))
238 `(#:configure-flags (list "-DUSE_INTERNAL_TINYXML=OFF")))
239 (home-page "https://vgough.github.io/encfs")
240 (synopsis "Encrypted virtual file system")
242 "EncFS creates a virtual encrypted file system in user-space. Each file
243 created under an EncFS mount point is stored as a separate encrypted file on
244 the underlying file system. Like most encrypted file systems, EncFS is meant
245 to provide security against off-line attacks, such as a drive falling into
247 (license (list license:expat ; internal/easylogging++.h
248 license:lgpl3+ ; encfs library
249 license:gpl3+)))) ; command-line tools
251 (define-public keyutils
259 (string-append "https://people.redhat.com/dhowells/keyutils/keyutils-"
263 "1bl3w03ygxhc0hz69klfdlwqn33jvzxl1zfl2jmnb2v85iawb8jd"))
264 (modules '((guix build utils)))
265 ;; Create relative symbolic links instead of absolute ones to /lib/*
266 (snippet '(substitute* "Makefile" (("\\$\\(LNS\\) \\$\\(LIBDIR\\)/")
268 (build-system gnu-build-system)
270 `(#:phases (modify-phases %standard-phases
271 (delete 'configure)) ; no configure script
272 #:make-flags (list "CC=gcc"
273 "RPATH=-Wl,-rpath,$(DESTDIR)$(LIBDIR)"
274 (string-append "DESTDIR="
275 (assoc-ref %outputs "out"))
276 "INCLUDEDIR=/include"
279 "SHAREDIR=/share/keyutils")
280 #:test-target "test"))
281 (home-page "https://people.redhat.com/dhowells/keyutils/")
282 (synopsis "Linux key management utilities")
284 "Keyutils is a set of utilities for managing the key retention facility in
285 the Linux kernel, which can be used by file systems, block devices, and more to
286 gain and retain the authorization and encryption keys required to perform
287 secure operations. ")
288 (license (list license:lgpl2.1+ ; the files keyutils.*
289 license:gpl2+)))) ; the rest
291 ;; There is no release candidate but commits point out a version number,
292 ;; furthermore no tarball exists.
293 (define-public eschalot
294 (let ((commit "0bf31d88a11898c19b1ed25ddd2aff7b35dbac44")
298 (version (string-append "1.2.0-" revision "." (string-take commit 7)))
303 (url "https://github.com/schnabear/eschalot")
305 (file-name (string-append name "-" version))
308 "0lj38ldh8vzi11wp4ghw4k0fkwp0s04zv8k8d473p1snmbh7mx98"))))
310 `(("openssl" ,openssl))) ; It needs: openssl/{bn,pem,rsa,sha}.h
311 (build-system gnu-build-system)
313 `(#:make-flags (list "CC=gcc"
314 (string-append "PREFIX=" (assoc-ref %outputs "out"))
315 (string-append "INSTALL=" "install"))
316 ;; XXX: make test would run a !VERY! long hashing of names with the use
317 ;; of a wordlist, the amount of computing time this would waste on build
318 ;; servers is in no relation to the size or importance of this small
319 ;; application, therefore we run our own tests on eschalot and worgen.
321 (modify-phases %standard-phases
326 (zero? (system* "./worgen" "8-12" "top1000.txt" "3-10" "top400nouns.txt"
327 "3-6" "top150adjectives.txt" "3-6"))
328 (zero? (system* "./eschalot" "-r" "^guix|^guixsd"))
329 (zero? (system* "./eschalot" "-r" "^gnu|^free"))
330 (zero? (system* "./eschalot" "-r" "^cyber|^hack"))
331 (zero? (system* "./eschalot" "-r" "^troll")))))
332 ;; Make install can not create the bin dir, create it.
333 (add-before 'install 'create-bin-dir
334 (lambda* (#:key outputs #:allow-other-keys)
335 (let* ((out (assoc-ref outputs "out"))
336 (bin (string-append out "/bin")))
339 (home-page "https://github.com/schnabear/eschalot")
340 (synopsis "Tor hidden service name generator")
342 "Eschalot is a tor hidden service name generator, it allows one to
343 produce customized vanity .onion addresses using a brute-force method. Searches
344 for valid names can be run with regular expressions and wordlists. For the
345 generation of wordlists the included tool @code{worgen} can be used. There is
346 no man page, refer to the home page for usage details.")
347 (license (list license:isc license:expat)))))
355 (uri (string-append "https://files.dyne.org/tomb/"
356 "Tomb-" version ".tar.gz"))
359 "1hv1w79as7swqj0n137vz8n8mwvcgwlvd91sdyssz41jarg7f1vr"))))
360 (build-system gnu-build-system)
361 (native-inputs `(("sudo" ,sudo))) ;presence needed for 'check' phase
365 ("cryptsetup" ,cryptsetup)
366 ("e2fsprogs" ,e2fsprogs) ;for mkfs.ext4
367 ("gettext" ,gettext-minimal) ;used at runtime
369 ("pinentry" ,pinentry)
370 ("qrencode" ,qrencode)
371 ("steghide" ,steghide)))
373 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
374 ;; TODO: Build and install gtk and qt trays
376 (modify-phases %standard-phases
377 (delete 'configure) ;no configuration to be done
378 (add-after 'install 'i18n
379 (lambda* (#:key make-flags #:allow-other-keys)
380 (zero? (apply system*
381 "make" "-C" "extras/translations"
382 "install" make-flags))))
383 (add-after 'install 'wrap
384 (lambda* (#:key inputs outputs #:allow-other-keys)
385 (let ((out (assoc-ref outputs "out")))
386 (wrap-program (string-append out "/bin/tomb")
388 (,(string-append (assoc-ref inputs "mlocate") "/bin")
389 ,@(map (lambda (program)
390 (or (and=> (which program) dirname)
391 (error "program not found:" program)))
392 '("seq" "mkfs.ext4" "pinentry" "sudo"
393 "gpg" "cryptsetup" "gettext"
394 "qrencode" "steghide")))))
397 (add-after 'wrap 'check
398 (lambda* (#:key outputs #:allow-other-keys)
399 ;; Running the full tests requires sudo/root access for
400 ;; cryptsetup, which is not available in the build environment.
401 ;; But we can run `tomb dig` without root, so make sure that
402 ;; works. TODO: It Would Be Nice to check the expected "index",
403 ;; "search", "bury", and "exhume" features are available by
404 ;; querying `tomb -h`.
405 (let ((tomb (string-append (assoc-ref outputs "out")
407 (zero? (system* tomb "dig" "-s" "10" "secrets.tomb"))))))))
408 (home-page "http://www.dyne.org/software/tomb")
409 (synopsis "File encryption for secret data")
411 "Tomb is an application to manage the creation and access of encrypted
412 storage files: it can be operated from commandline and it can integrate with a
413 user's graphical desktop.")
414 (license license:gpl3+)))
416 (define-public scrypt
423 (uri (string-append "https://www.tarsnap.com/scrypt/scrypt-"
427 "0xy5yhrwwv13skv9im9vm76rybh9f29j2dh4hlh2x01gvbkza8a6"))))
428 (build-system gnu-build-system)
430 `(#:phases (modify-phases %standard-phases
431 (add-after 'unpack 'patch-command-invocations
433 (substitute* "Makefile.in"
436 (add-after 'install 'install-docs
437 (lambda* (#:key outputs #:allow-other-keys)
438 (let* ((out (assoc-ref %outputs "out"))
439 (misc (string-append out "/share/doc/scrypt")))
440 (install-file "FORMAT" misc)
443 `(("openssl" ,openssl)))
444 (home-page "https://www.tarsnap.com/scrypt.html")
445 (synopsis "Memory-hard encryption tool based on scrypt")
446 (description "This packages provides a simple password-based encryption
447 utility as a demonstration of the @code{scrypt} key derivation function.
448 @code{Scrypt} is designed to be far more resistant against hardware brute-force
449 attacks than alternative functions such as @code{PBKDF2} or @code{bcrypt}.")
450 (license license:bsd-2)))
452 (define-public python-asn1crypto
454 (name "python-asn1crypto")
459 (uri (string-append "https://github.com/wbond/asn1crypto/archive/"
463 "1kn910896l3knmilla1c9ly20q181s43w1ah08lzkbm1h3j6pcz0"))))
464 (build-system python-build-system)
465 (home-page "https://github.com/wbond/asn1crypto")
466 (synopsis "ASN.1 parser and serializer in Python")
467 (description "asn1crypto is an ASN.1 parser and serializer with definitions
468 for private keys, public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7,
469 PKCS#8, PKCS#12, PKCS#5, X.509 and TSP.")
470 (license license:expat)))
472 (define-public python2-asn1crypto
473 (package-with-python2 python-asn1crypto))
475 (define-public perl-math-random-isaac-xs
477 (name "perl-math-random-isaac-xs")
482 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
483 "Math-Random-ISAAC-XS-" version ".tar.gz"))
486 "0yxqqcqvj51fn7b7j5xqhz65v74arzgainn66c6k7inijbmr1xws"))))
487 (build-system perl-build-system)
489 `(("perl-module-build" ,perl-module-build)
490 ("perl-test-nowarnings" ,perl-test-nowarnings)))
491 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC-XS")
492 (synopsis "C implementation of the ISAAC PRNG algorithm")
493 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
494 fast pseudo-random number generator. It is suitable for applications where a
495 significant amount of random data needs to be produced quickly, such as
496 solving using the Monte Carlo method or for games. The results are uniformly
497 distributed, unbiased, and unpredictable unless you know the seed.
499 This package implements the same interface as @code{Math::Random::ISAAC}.")
500 (license license:public-domain)))
502 (define-public perl-math-random-isaac
504 (name "perl-math-random-isaac")
509 (uri (string-append "mirror://cpan/authors/id/J/JA/JAWNSY/"
510 "Math-Random-ISAAC-" version ".tar.gz"))
513 "0z1b3xbb3xz71h25fg6jgsccra7migq7s0vawx2rfzi0pwpz0wr7"))))
514 (build-system perl-build-system)
516 `(("perl-test-nowarnings" ,perl-test-nowarnings)))
518 `(("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)))
519 (home-page "http://search.cpan.org/dist/Math-Random-ISAAC")
520 (synopsis "Perl interface to the ISAAC PRNG algorithm")
521 (description "ISAAC (Indirection, Shift, Accumulate, Add, and Count) is a
522 fast pseudo-random number generator. It is suitable for applications where a
523 significant amount of random data needs to be produced quickly, such as
524 solving using the Monte Carlo method or for games. The results are uniformly
525 distributed, unbiased, and unpredictable unless you know the seed.
527 This package provides a Perl interface to the ISAAC pseudo random number
529 (license license:public-domain)))
531 (define-public perl-crypt-random-source
533 (name "perl-crypt-random-source")
538 (uri (string-append "mirror://cpan/authors/id/E/ET/ETHER/"
539 "Crypt-Random-Source-" version ".tar.gz"))
542 "00mw5m52sbz9nqp3f6axyrgcrihqxn7k8gv0vi1kvm1j1nc9g29h"))))
543 (build-system perl-build-system)
545 `(("perl-module-build-tiny" ,perl-module-build-tiny)
546 ("perl-test-exception" ,perl-test-exception)))
548 `(("perl-capture-tiny" ,perl-capture-tiny)
549 ("perl-module-find" ,perl-module-find)
550 ("perl-module-runtime" ,perl-module-runtime)
551 ("perl-moo" ,perl-moo)
552 ("perl-namespace-clean" ,perl-namespace-clean)
553 ("perl-sub-exporter" ,perl-sub-exporter)
554 ("perl-type-tiny" ,perl-type-tiny)))
555 (home-page "http://search.cpan.org/dist/Crypt-Random-Source")
556 (synopsis "Get weak or strong random data from pluggable sources")
557 (description "This module provides implementations for a number of
558 byte-oriented sources of random data.")
559 (license (package-license perl))))
561 (define-public perl-math-random-secure
563 (name "perl-math-random-secure")
568 (uri (string-append "mirror://cpan/authors/id/F/FR/FREW/"
569 "Math-Random-Secure-" version ".tar.gz"))
572 "0dgbf4ncll4kmgkyb9fsaxn0vf2smc9dmwqzgh3259zc2zla995z"))))
573 (build-system perl-build-system)
575 `(("perl-list-moreutils" ,perl-list-moreutils)
576 ("perl-test-leaktrace" ,perl-test-leaktrace)
577 ("perl-test-sharedfork" ,perl-test-sharedfork)
578 ("perl-test-warn" ,perl-test-warn)))
580 `(("perl-crypt-random-source" ,perl-crypt-random-source)
581 ("perl-math-random-isaac" ,perl-math-random-isaac)
582 ("perl-math-random-isaac-xs" ,perl-math-random-isaac-xs)
583 ("perl-moo" ,perl-moo)))
584 (home-page "http://search.cpan.org/dist/Math-Random-Secure")
585 (synopsis "Cryptographically secure replacement for rand()")
586 (description "This module is intended to provide a
587 cryptographically-secure replacement for Perl's built-in @code{rand} function.
588 \"Crytographically secure\", in this case, means:
591 @item No matter how many numbers you see generated by the random number
592 generator, you cannot guess the future numbers, and you cannot guess the seed.
593 @item There are so many possible seeds that it would take decades, centuries,
594 or millenia for an attacker to try them all.
595 @item The seed comes from a source that generates relatively strong random
596 data on your platform, so the seed itself will be as random as possible.
598 (license license:artistic2.0)))
600 (define-public python-pynacl
602 (name "python-pynacl")
607 (uri (pypi-uri "PyNaCl" version))
608 (modules '((guix build utils)))
609 ;; Remove bundled libsodium
610 (snippet '(delete-file-recursively "src/libsodium"))
613 "135gz0020fqx8fbr9izpwyq49aww202nkqacq0cw61xz99sjpx9j"))))
614 (build-system python-build-system)
617 (modify-phases %standard-phases
618 (add-before 'build 'use-system-sodium
620 (setenv "SODIUM_INSTALL" "system")
623 `(("python-pytest" ,python-pytest)))
625 `(("python-cffi" ,python-cffi)
626 ("python-six" ,python-six)
627 ("libsodium" ,libsodium)))
628 (home-page "https://github.com/pyca/pynacl/")
629 (synopsis "Python bindings to libsodium")
631 "PyNaCl is a Python binding to libsodium, which is a fork of the
632 Networking and Cryptography library. These libraries have a stated goal
633 of improving usability, security and speed.")
634 (license license:asl2.0)))