gnu: Add libtomcrypt.

* gnu/packages/multiprecision.scm (libtomcrypt): New variable.
This commit is contained in:
Efraim Flashner 2021-02-11 11:03:17 +02:00
parent 78bbf6c443
commit 4b62be5ca4
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -6,7 +6,7 @@
;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
;;;
;;; This file is part of GNU Guix.
;;;
@ -320,6 +320,78 @@ (define-public tomsfastmath
multiplies.")
(license public-domain)))
(define-public libtomcrypt
(package
(name "libtomcrypt")
(version "1.18.2")
(outputs '("out" "static"))
(source
(origin
(method url-fetch)
(uri (string-append "https://github.com/libtom/libtomcrypt"
"/releases/download/v" version
"/crypt-" version ".tar.xz"))
(sha256
(base32
"113vfrgapyv72lalhd3nkw7jnks8az0gcb5wqn9hj19nhcxlrbcn"))
(modules '((guix build utils)))
(snippet
'(begin
;; Patch CVE-2019-17362
;; https://github.com/libtom/libtomcrypt/commit/25c26a3b7a9ad8192ccc923e15cf62bf0108ef94
(substitute* "src/pk/asn1/der/utf8/der_decode_utf8_string.c"
(("z > 4") "z == 1 || z > 4"))
#t))))
(build-system gnu-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(delete 'configure) ; no configure
(add-after 'unpack 'prepare-build
(lambda _
;; We want the shared library by default so force it to be the
;; default makefile target.
(delete-file "makefile")
(symlink "makefile.shared" "makefile")
#t))
(add-after 'build 'build-static
(lambda* (#:key make-flags #:allow-other-keys)
(apply invoke "make" "-f" "makefile.unix" make-flags)))
(replace 'check
(lambda* (#:key test-target make-flags #:allow-other-keys)
(apply invoke "make" "-f" "makefile.unix" test-target make-flags)
(invoke "./test")))
(add-after 'install 'install-static-library
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(static (assoc-ref outputs "static")))
(mkdir-p (string-append static "/lib"))
(mkdir-p (string-append static "/include"))
(rename-file (string-append out "/lib/libtomcrypt.a")
(string-append static "/lib/libtomcrypt.a"))
(copy-recursively (string-append out "/include")
(string-append static "/include"))
#t))))
#:test-target "test"
#:make-flags
(list (string-append "PREFIX=" (assoc-ref %outputs "out"))
"CFLAGS += -DLTM_DESC -DUSE_LTM"
(string-append "EXTRALIBS=" (assoc-ref %build-inputs "libtommath")
"/lib/libtommath.so")
(string-append "CC=" ,(cc-for-target)))))
(native-inputs
`(("libtool" ,libtool)))
(inputs
`(("libtommath" ,libtommath)))
(home-page "https://www.libtom.net/LibTomCrypt/")
(synopsis "Cryptographic toolkit")
(description "LibTomCrypt is a fairly comprehensive, modular and portable
cryptographic toolkit that provides developers with a vast array of well known
published block ciphers, one-way hash functions, chaining modes, pseudo-random
number generators, public key cryptography and a plethora of other routines.")
(properties `((lint-hidden-cve . ("CVE-2019-17362"))))
(license unlicense)))
(define-public libtommath
(package
(name "libtommath")