summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-04-22 11:30:51 +0200
committerLudovic Courtès <ludo@gnu.org>2014-04-22 11:30:58 +0200
commit6f69588529f9898dc4f2defd21603cc4abbaca17 (patch)
treed272d8bd84f0653e0d5b7d409df3211c29fec784 /tests
parent6030d8493e13af81be63c3cee530d44b4dff1ad6 (diff)
downloadguix-6f69588529f9898dc4f2defd21603cc4abbaca17.tar.gz
authenticate: Allow signatures with binary data to be written to stdout.
Fixes <http://bugs.gnu.org/17312>.

* guix/scripts/authenticate.scm (guix-authenticate): Add calls to
  'set-port-encoding!' and 'set-port-conversion-strategy!'.  Wrap body
  in 'with-fluids' form that sets '%default-port-encoding' and
  '%default-port-conversion-strategy'.
* tests/guix-authenticate.sh: Add test.
* tests/pk-crypto.scm ("hash corrupt due to restrictive locale
  encoding"): Add reference to bug.
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-authenticate.sh21
-rw-r--r--tests/pk-crypto.scm2
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/guix-authenticate.sh b/tests/guix-authenticate.sh
index 35ec7ffd6a..72c3d161d7 100644
--- a/tests/guix-authenticate.sh
+++ b/tests/guix-authenticate.sh
@@ -72,3 +72,24 @@ if guix authenticate rsautl -verify				\
 then false
 else true
 fi
+
+
+# Test for <http://bugs.gnu.org/17312>: make sure 'guix authenticate' produces
+# valid signatures when run in the C locale.
+echo "5eff0b55c9c5f5e87b4e34cd60a2d5654ca1eb78c7b3c67c3179fed1cff07b4c" \
+    > "$hash"
+
+LC_ALL=C
+export LC_ALL
+
+guix authenticate rsautl -sign				\
+    -inkey "$abs_top_srcdir/tests/signing-key.sec"	\
+    -in "$hash" > "$sig"
+
+guix authenticate rsautl -verify			\
+        -inkey "$abs_top_srcdir/tests/signing-key.pub"	\
+        -pubin -in "$sig"
+hash2="`guix authenticate rsautl -verify		\
+          -inkey $abs_top_srcdir/tests/signing-key.pub	\
+          -pubin -in $sig`"
+test "$hash2" = `cat "$hash"`
diff --git a/tests/pk-crypto.scm b/tests/pk-crypto.scm
index 67bbc83d49..f5008f3248 100644
--- a/tests/pk-crypto.scm
+++ b/tests/pk-crypto.scm
@@ -153,7 +153,7 @@
     ;; 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.
+    ;; signature verification.  See <http://bugs.gnu.org/17312>.
     (let ((locale (setlocale LC_ALL)))
      (dynamic-wind
        (lambda ()