summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-08-31 17:07:07 +0200
committerLudovic Courtès <ludo@gnu.org>2018-09-04 17:25:11 +0200
commitca719424455465fca4b872c371daf2a46de88b33 (patch)
treece967f28949e46ddc864bb5d43a380fd7c9e0c0d /tests
parent7e1d229019c1924a2748e5daec2a619e7efbd7d7 (diff)
downloadgnu-guix-ca719424455465fca4b872c371daf2a46de88b33.tar
gnu-guix-ca719424455465fca4b872c371daf2a46de88b33.tar.gz
Switch to Guile-Gcrypt.
This removes (guix hash) and (guix pk-crypto), which now live as part of Guile-Gcrypt (version 0.1.0.) * guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm, tests/hash.scm, tests/pk-crypto.scm: Remove. * configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and LIBGCRYPT_LIBDIR assignments. * m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove. * README: Add Guile-Gcrypt to the dependencies; move libgcrypt as "required unless --disable-daemon". * doc/guix.texi (Requirements): Likewise. * gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm, guix/git.scm, guix/http-client.scm, guix/import/cpan.scm, guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm, guix/import/gnu.scm, guix/import/hackage.scm, guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm, guix/pki.scm, guix/scripts/archive.scm, guix/scripts/authenticate.scm, guix/scripts/download.scm, guix/scripts/hash.scm, guix/scripts/pack.scm, guix/scripts/publish.scm, guix/scripts/refresh.scm, guix/scripts/substitute.scm, guix/store.scm, guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm, tests/builders.scm, tests/challenge.scm, tests/cpan.scm, tests/crate.scm, tests/derivations.scm, tests/gem.scm, tests/nar.scm, tests/opam.scm, tests/pki.scm, tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm, tests/store.scm, tests/substitute.scm: Adjust imports. * gnu/system/vm.scm: Likewise. (guile-sqlite3&co): Rename to... (gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT. (expression->derivation-in-linux-vm)[config]: Remove. (iso9660-image)[config]: Remove. (qemu-image)[config]: Remove. (system-docker-image)[config]: Remove. * guix/scripts/pack.scm: Adjust imports. (guile-sqlite3&co): Rename to... (gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT. (self-contained-tarball)[build]: Call 'make-config.scm' without #:libgcrypt argument. (squashfs-image)[libgcrypt]: Remove. [build]: Call 'make-config.scm' without #:libgcrypt. (docker-image)[config, json]: Remove. [build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from the imported modules. * guix/self.scm (specification->package): Remove "libgcrypt", add "guile-gcrypt". (compiled-guix): Remove #:libgcrypt. [guile-gcrypt]: New variable. [dependencies]: Add it. [*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call. Add #:extensions. [*config*]: Remove #:libgcrypt from 'make-config.scm' call. (%dependency-variables): Remove %libgcrypt. (make-config.scm): Remove #:libgcrypt. * build-aux/build-self.scm (guile-gcrypt): New variable. (make-config.scm): Remove #:libgcrypt. (build-program)[fake-gcrypt-hash]: New variable. Add (gcrypt hash) to the imported modules. Adjust load path assignments. * gnu/packages/package-management.scm (guix)[propagated-inputs]: Add GUILE-GCRYPT. [arguments]: In 'wrap-program' phase, add GUILE-GCRYPT to the search path.
Diffstat (limited to 'tests')
-rw-r--r--tests/base32.scm2
-rw-r--r--tests/builders.scm2
-rw-r--r--tests/challenge.scm2
-rw-r--r--tests/cpan.scm2
-rw-r--r--tests/crate.scm2
-rw-r--r--tests/derivations.scm2
-rw-r--r--tests/gem.scm2
-rw-r--r--tests/hash.scm128
-rw-r--r--tests/nar.scm2
-rw-r--r--tests/opam.scm2
-rw-r--r--tests/packages.scm2
-rw-r--r--tests/pk-crypto.scm290
-rw-r--r--tests/pki.scm4
-rw-r--r--tests/publish.scm4
-rw-r--r--tests/pypi.scm2
-rw-r--r--tests/store-deduplication.scm2
-rw-r--r--tests/store.scm2
-rw-r--r--tests/substitute.scm4
18 files changed, 19 insertions, 437 deletions
diff --git a/tests/base32.scm b/tests/base32.scm
index 194f8da96b..134e578633 100644
--- a/tests/base32.scm
+++ b/tests/base32.scm
@@ -17,7 +17,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-base32)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix base32)
#:use-module (guix utils)
#:use-module (srfi srfi-1)
diff --git a/tests/builders.scm b/tests/builders.scm
index bb9e0fa85b..8b8ef013e7 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -25,7 +25,7 @@
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module (guix derivations)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module ((guix packages)
#:select (package-derivation package-native-search-paths))
diff --git a/tests/challenge.scm b/tests/challenge.scm
index 387d205a64..4b13ec278e 100644
--- a/tests/challenge.scm
+++ b/tests/challenge.scm
@@ -18,7 +18,7 @@
(define-module (test-challenge)
#:use-module (guix tests)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix derivations)
diff --git a/tests/cpan.scm b/tests/cpan.scm
index 396744e529..189dd027e6 100644
--- a/tests/cpan.scm
+++ b/tests/cpan.scm
@@ -20,7 +20,7 @@
(define-module (test-cpan)
#:use-module (guix import cpan)
#:use-module (guix base32)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module (guix grafts)
#:use-module (srfi srfi-64)
diff --git a/tests/crate.scm b/tests/crate.scm
index eb93822bbb..a1dcfd5e52 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -21,7 +21,7 @@
#:use-module (guix import crate)
#:use-module (guix base32)
#:use-module (guix build-system cargo)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module (ice-9 iconv)
#:use-module (ice-9 match)
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 5d83529183..159a6971b3 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -23,7 +23,7 @@
#:use-module (guix grafts)
#:use-module (guix store)
#:use-module (guix utils)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix base32)
#:use-module (guix tests)
#:use-module (guix tests http)
diff --git a/tests/gem.scm b/tests/gem.scm
index 4220170ff0..a12edb294c 100644
--- a/tests/gem.scm
+++ b/tests/gem.scm
@@ -21,7 +21,7 @@
(define-module (test-gem)
#:use-module (guix import gem)
#:use-module (guix base32)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module ((guix build utils) #:select (delete-file-recursively))
#:use-module (srfi srfi-41)
diff --git a/tests/hash.scm b/tests/hash.scm
deleted file mode 100644
index 47dff3915b..0000000000
--- a/tests/hash.scm
+++ /dev/null
@@ -1,128 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (test-hash)
- #:use-module (guix hash)
- #:use-module (guix base16)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-64)
- #:use-module (rnrs bytevectors)
- #:use-module (rnrs io ports))
-
-;; Test the (guix hash) module.
-
-(define %empty-sha256
- ;; SHA256 hash of the empty string.
- (base16-string->bytevector
- "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
-
-(define %hello-sha256
- ;; SHA256 hash of "hello world"
- (base16-string->bytevector
- "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"))
-
-
-(test-begin "hash")
-
-(test-equal "sha1, empty"
- (base16-string->bytevector "da39a3ee5e6b4b0d3255bfef95601890afd80709")
- (sha1 #vu8()))
-
-(test-equal "sha1, hello"
- (base16-string->bytevector "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed")
- (sha1 (string->utf8 "hello world")))
-
-(test-equal "sha256, empty"
- %empty-sha256
- (sha256 #vu8()))
-
-(test-equal "sha256, hello"
- %hello-sha256
- (sha256 (string->utf8 "hello world")))
-
-(test-equal "open-sha256-port, empty"
- %empty-sha256
- (let-values (((port get)
- (open-sha256-port)))
- (close-port port)
- (get)))
-
-(test-equal "open-sha256-port, hello"
- (list %hello-sha256 (string-length "hello world"))
- (let-values (((port get)
- (open-sha256-port)))
- (put-bytevector port (string->utf8 "hello world"))
- (force-output port)
- (list (get) (port-position port))))
-
-(test-assert "port-sha256"
- (let* ((file (search-path %load-path "ice-9/psyntax.scm"))
- (size (stat:size (stat file)))
- (contents (call-with-input-file file get-bytevector-all)))
- (equal? (sha256 contents)
- (call-with-input-file file port-sha256))))
-
-(test-equal "open-sha256-input-port, empty"
- `("" ,%empty-sha256)
- (let-values (((port get)
- (open-sha256-input-port (open-string-input-port ""))))
- (let ((str (get-string-all port)))
- (list str (get)))))
-
-(test-equal "open-sha256-input-port, hello"
- `("hello world" ,%hello-sha256)
- (let-values (((port get)
- (open-sha256-input-port
- (open-bytevector-input-port
- (string->utf8 "hello world")))))
- (let ((str (get-string-all port)))
- (list str (get)))))
-
-(test-equal "open-sha256-input-port, hello, one two"
- (list (string->utf8 "hel") (string->utf8 "lo")
- (base16-string->bytevector ; echo -n hello | sha256sum
- "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")
- " world")
- (let-values (((port get)
- (open-sha256-input-port
- (open-bytevector-input-port (string->utf8 "hello world")))))
- (let* ((one (get-bytevector-n port 3))
- (two (get-bytevector-n port 2))
- (hash (get))
- (three (get-string-all port)))
- (list one two hash three))))
-
-(test-equal "open-sha256-input-port, hello, read from wrapped port"
- (list (string->utf8 "hello")
- (base16-string->bytevector ; echo -n hello | sha256sum
- "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")
- " world")
- (let*-values (((wrapped)
- (open-bytevector-input-port (string->utf8 "hello world")))
- ((port get)
- (open-sha256-input-port wrapped)))
- (let* ((hello (get-bytevector-n port 5))
- (hash (get))
-
- ;; Now read from WRAPPED to make sure its current position is
- ;; correct.
- (world (get-string-all wrapped)))
- (list hello hash world))))
-
-(test-end)
diff --git a/tests/nar.scm b/tests/nar.scm
index 9b5fb984b4..d610ea53f7 100644
--- a/tests/nar.scm
+++ b/tests/nar.scm
@@ -21,7 +21,7 @@
#:use-module (guix nar)
#:use-module (guix serialization)
#:use-module (guix store)
- #:use-module ((guix hash)
+ #:use-module ((gcrypt hash)
#:select (open-sha256-port open-sha256-input-port))
#:use-module ((guix packages)
#:select (base32))
diff --git a/tests/opam.scm b/tests/opam.scm
index 26832174a8..a1320abfdc 100644
--- a/tests/opam.scm
+++ b/tests/opam.scm
@@ -19,7 +19,7 @@
(define-module (test-opam)
#:use-module (guix import opam)
#:use-module (guix base32)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module ((guix build utils) #:select (delete-file-recursively mkdir-p which))
#:use-module (srfi srfi-64)
diff --git a/tests/packages.scm b/tests/packages.scm
index 65ccb14889..237feb7aba 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -28,7 +28,7 @@
#:renamer (lambda (name)
(cond ((eq? name 'location) 'make-location)
(else name))))
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module (guix grafts)
diff --git a/tests/pk-crypto.scm b/tests/pk-crypto.scm
deleted file mode 100644
index fe33a6f7b5..0000000000
--- a/tests/pk-crypto.scm
+++ /dev/null
@@ -1,290 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2017 Ludovic Courtès <ludo@gnu.org>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (test-pk-crypto)
- #:use-module (guix pk-crypto)
- #:use-module (guix utils)
- #:use-module (guix base16)
- #:use-module (guix hash)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-26)
- #:use-module (srfi srfi-64)
- #:use-module (rnrs bytevectors)
- #:use-module (rnrs io ports)
- #:use-module (ice-9 match))
-
-;; Test the (guix pk-crypto) module.
-
-(define %key-pair
- ;; RSA key pair that was generated with:
- ;; (generate-key (string->canonical-sexp "(genkey (rsa (nbits 4:1024)))"))
- ;; which takes a bit of time.
- "(key-data
- (public-key
- (rsa
- (n #00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45#)
- (e #010001#)))
- (private-key
- (rsa
- (n #00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45#)
- (e #010001#)
- (d #58CAD84653D0046A8EC3F9AA82D9C829B145422109FC3F12DA01A694B92FA296E70D366FB166454D30E632CEE3A033B4C41781BA10325F69FCDC0250CA19C8EEB352FA085992494098DB133E682ED38A931701F0DED1A1E508F4341A4FB446A04F019427C7CB3C44F251EEA9D386100DA80F125E0FD5CE1B0DFEC6D21516EACD#)
- (p #00D47F185147EC39393CCDA4E7323FFC20FC8B8073E2A54DD63BA392A66975E4204CA48572496A9DFD7522436B852C07472A5AB25B7706F7C14E6F33FBC420FF3B#)
- (q #00E9AD22F158060BC9AE3601DA623AFC60FFF3058795802CA92371C00097335CF9A23D7782DE353C9DBA93D7BB99E6A24A411107605E722481C5C191F80D7EB77F#)
- (u #59B45B95AE01A7A7370FAFDB08FE73A4793CE37F228961B09B1B1E7DDAD9F8D3E28F5C5E8B4B067E6B8E0BBF3F690B42991A79E46108DDCDA2514323A66964DE#))))")
-
-(define %ecc-key-pair
- ;; Ed25519 key pair generated with:
- ;; (generate-key (string->canonical-sexp "(genkey (ecdsa (curve Ed25519) (flags rfc6979 transient)))"))
- "(key-data
- (public-key
- (ecc
- (curve Ed25519)
- (q #94869C1B9E69DB8DD910B7F7F4D6E56A63A964A59AE8F90F6703ACDDF6F50C81#)))
- (private-key
- (ecc
- (curve Ed25519)
- (q #94869C1B9E69DB8DD910B7F7F4D6E56A63A964A59AE8F90F6703ACDDF6F50C81#)
- (d #6EFB32D0B4EC6B3237B523539F1979379B82726AAA605EB2FBA6775B2B777B78#))))")
-
-(test-begin "pk-crypto")
-
-(test-assert "version"
- (gcrypt-version))
-
-(let ((sexps '("(foo bar)"
-
- ;; In Libgcrypt 1.5.3 the following integer is rendered as
- ;; binary, whereas in 1.6.0 it's rendered as is (hexadecimal.)
- ;;"#C0FFEE#"
-
- "(genkey \n (rsa \n (nbits \"1024\")\n )\n )")))
- (test-equal "string->canonical-sexp->string"
- sexps
- (let ((sexps (map string->canonical-sexp sexps)))
- (and (every canonical-sexp? sexps)
- (map (compose string-trim-both canonical-sexp->string) sexps)))))
-
-(gc) ; stress test!
-
-(let ((sexps `(("(foo bar)" foo -> "(foo bar)")
- ("(foo (bar (baz 3:123)))" baz -> "(baz \"123\")")
- ("(foo (bar 3:123))" baz -> #f))))
- (test-equal "find-sexp-token"
- (map (match-lambda
- ((_ _ '-> expected)
- expected))
- sexps)
- (map (match-lambda
- ((input token '-> _)
- (let ((sexp (find-sexp-token (string->canonical-sexp input) token)))
- (and sexp
- (string-trim-both (canonical-sexp->string sexp))))))
- sexps)))
-
-(gc)
-
-(test-equal "canonical-sexp-length"
- '(0 1 2 4 0 0)
- (map (compose canonical-sexp-length string->canonical-sexp)
- '("()" "(a)" "(a b)" "(a #616263# b #C001#)" "a" "#123456#")))
-
-(test-equal "canonical-sexp-list?"
- '(#t #f #t #f)
- (map (compose canonical-sexp-list? string->canonical-sexp)
- '("()" "\"abc\"" "(a b c)" "#123456#")))
-
-(gc)
-
-(test-equal "canonical-sexp-car + cdr"
- '("(b \n (c xyz)\n )")
- (let ((lst (string->canonical-sexp "(a (b (c xyz)))")))
- (map (lambda (sexp)
- (and sexp (string-trim-both (canonical-sexp->string sexp))))
- ;; Note: 'car' returns #f when the first element is an atom.
- (list (canonical-sexp-car (canonical-sexp-cdr lst))))))
-
-(gc)
-
-(test-equal "canonical-sexp-nth"
- '("(b pqr)" "(c \"456\")" "(d xyz)" #f #f)
-
- (let ((lst (string->canonical-sexp "(a (b 3:pqr) (c 3:456) (d 3:xyz))")))
- ;; XXX: In Libgcrypt 1.5.3, (canonical-sexp-nth lst 0) returns LST, whereas in
- ;; 1.6.0 it returns #f.
- (map (lambda (sexp)
- (and sexp (string-trim-both (canonical-sexp->string sexp))))
- (unfold (cut > <> 5)
- (cut canonical-sexp-nth lst <>)
- 1+
- 1))))
-
-(gc)
-
-(test-equal "canonical-sexp-nth-data"
- `(Name Otto Meier #f ,(base16-string->bytevector "123456") #f)
- (let ((lst (string->canonical-sexp
- "(Name Otto Meier (address Burgplatz) #123456#)")))
- (unfold (cut > <> 5)
- (cut canonical-sexp-nth-data lst <>)
- 1+
- 0)))
-
-(let ((bv (base16-string->bytevector
- "5eff0b55c9c5f5e87b4e34cd60a2d5654ca1eb78c7b3c67c3179fed1cff07b4c")))
- (test-equal "hash corrupt due to restrictive locale encoding"
- bv
-
- ;; In Guix up to 0.6 included this test would fail because at some point
- ;; the hash value would be cropped to ASCII. In practice 'guix
- ;; authenticate' would produce invalid signatures that would fail
- ;; signature verification. See <http://bugs.gnu.org/17312>.
- (let ((locale (setlocale LC_ALL)))
- (dynamic-wind
- (lambda ()
- (setlocale LC_ALL "C"))
- (lambda ()
- (hash-data->bytevector
- (string->canonical-sexp
- (canonical-sexp->string
- (bytevector->hash-data bv "sha256")))))
- (lambda ()
- (setlocale LC_ALL locale))))))
-
-(gc)
-
-;; XXX: The test below is typically too long as it needs to gather enough entropy.
-
-;; (test-assert "generate-key"
-;; (let ((key (generate-key (string->canonical-sexp
-;; "(genkey (rsa (nbits 3:128)))"))))
-;; (and (canonical-sexp? key)
-;; (find-sexp-token key 'key-data)
-;; (find-sexp-token key 'public-key)
-;; (find-sexp-token key 'private-key))))
-
-(test-assert "bytevector->hash-data->bytevector"
- (let* ((bv (sha256 (string->utf8 "Hello, world.")))
- (data (bytevector->hash-data bv "sha256")))
- (and (canonical-sexp? data)
- (let-values (((value algo) (hash-data->bytevector data)))
- (and (string=? algo "sha256")
- (bytevector=? value bv))))))
-
-(test-equal "key-type"
- '(rsa ecc)
- (map (compose key-type
- (cut find-sexp-token <> 'public-key)
- string->canonical-sexp)
- (list %key-pair %ecc-key-pair)))
-
-(test-assert "sign + verify"
- (let* ((pair (string->canonical-sexp %key-pair))
- (secret (find-sexp-token pair 'private-key))
- (public (find-sexp-token pair 'public-key))
- (data (bytevector->hash-data
- (sha256 (string->utf8 "Hello, world."))
- #:key-type (key-type public)))
- (sig (sign data secret)))
- (and (verify sig data public)
- (not (verify sig
- (bytevector->hash-data
- (sha256 (string->utf8 "Hi!"))
- #:key-type (key-type public))
- public)))))
-
-;; Ed25519 appeared in libgcrypt 1.6.0.
-(test-skip (if (version>? (gcrypt-version) "1.6.0") 0 1))
-(test-assert "sign + verify, Ed25519"
- (let* ((pair (string->canonical-sexp %ecc-key-pair))
- (secret (find-sexp-token pair 'private-key))
- (public (find-sexp-token pair 'public-key))
- (data (bytevector->hash-data
- (sha256 (string->utf8 "Hello, world."))))
- (sig (sign data secret)))
- (and (verify sig data public)
- (not (verify sig
- (bytevector->hash-data
- (sha256 (string->utf8 "Hi!")))
- public)))))
-
-(gc)
-
-(test-equal "canonical-sexp->sexp"
- `((data
- (flags pkcs1)
- (hash sha256
- ,(base16-string->bytevector
- "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb")))
-
- (public-key
- (rsa
- (n ,(base16-string->bytevector
- (string-downcase
- "00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45")))
- (e ,(base16-string->bytevector
- "010001")))))
-
- (list (canonical-sexp->sexp
- (string->canonical-sexp
- "(data
- (flags pkcs1)
- (hash \"sha256\"
- #2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb#))"))
-
- (canonical-sexp->sexp
- (find-sexp-token (string->canonical-sexp %key-pair)
- 'public-key))))
-
-
-(let ((lst
- `((data
- (flags pkcs1)
- (hash sha256
- ,(base16-string->bytevector
- "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb")))
-
- (public-key
- (rsa
- (n ,(base16-string->bytevector
- (string-downcase
- "00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45")))
- (e ,(base16-string->bytevector
- "010001"))))
-
- ,(base16-string->bytevector
- "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb"))))
- (test-equal "sexp->canonical-sexp->sexp"
- lst
- (map (compose canonical-sexp->sexp sexp->canonical-sexp)
- lst)))
-
-(let ((sexp `(signature
- (public-key
- (rsa
- (n ,(make-bytevector 1024 1))
- (e ,(base16-string->bytevector "010001")))))))
- (test-equal "https://bugs.g10code.com/gnupg/issue1594"
- ;; The gcrypt bug above was primarily affecting our uses in
- ;; 'canonical-sexp->sexp', typically when applied to a signature sexp (in
- ;; 'guix authenticate -verify') with a "big" RSA key, such as 4096 bits.
- sexp
- (canonical-sexp->sexp (sexp->canonical-sexp sexp))))
-
-(test-end)
diff --git a/tests/pki.scm b/tests/pki.scm
index 876ad98d73..d6a6b476c7 100644
--- a/tests/pki.scm
+++ b/tests/pki.scm
@@ -18,8 +18,8 @@
(define-module (test-pki)
#:use-module (guix pki)
- #:use-module (guix pk-crypto)
- #:use-module (guix hash)
+ #:use-module (gcrypt pk-crypto)
+ #:use-module (gcrypt hash)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-64))
diff --git a/tests/publish.scm b/tests/publish.scm
index 1ed8308076..0e793c1ee5 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -25,7 +25,7 @@
#:use-module (guix tests)
#:use-module (guix config)
#:use-module (guix utils)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix store)
#:use-module (guix derivations)
#:use-module (guix gexp)
@@ -33,7 +33,7 @@
#:use-module (guix base64)
#:use-module ((guix records) #:select (recutils->alist))
#:use-module ((guix serialization) #:select (restore-file))
- #:use-module (guix pk-crypto)
+ #:use-module (gcrypt pk-crypto)
#:use-module ((guix pki) #:select (%public-key-file %private-key-file))
#:use-module (guix zlib)
#:use-module (web uri)
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 310c6c8f29..616ec191f5 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -20,7 +20,7 @@
(define-module (test-pypi)
#:use-module (guix import pypi)
#:use-module (guix base32)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix tests)
#:use-module (guix build-system python)
#:use-module ((guix build utils) #:select (delete-file-recursively which))
diff --git a/tests/store-deduplication.scm b/tests/store-deduplication.scm
index 4ca2ec0f61..e438aa84c6 100644
--- a/tests/store-deduplication.scm
+++ b/tests/store-deduplication.scm
@@ -19,7 +19,7 @@
(define-module (test-store-deduplication)
#:use-module (guix tests)
#:use-module (guix store deduplication)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (guix build utils)
#:use-module (rnrs bytevectors)
diff --git a/tests/store.scm b/tests/store.scm
index 47fab0df18..71ac57580e 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -21,7 +21,7 @@
#:use-module (guix store)
#:use-module (guix utils)
#:use-module (guix monads)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix base32)
#:use-module (guix packages)
#:use-module (guix derivations)
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 0ad6247954..964a57f30b 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -20,9 +20,9 @@
(define-module (test-substitute)
#:use-module (guix scripts substitute)
#:use-module (guix base64)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix serialization)
- #:use-module (guix pk-crypto)
+ #:use-module (gcrypt pk-crypto)
#:use-module (guix pki)
#:use-module (guix config)
#:use-module (guix base32)