summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-12-27 23:32:26 +0100
committerLudovic Courtès <ludo@gnu.org>2013-12-29 15:57:23 +0100
commitb0a33ac157ce99688b6d668124377fdd81bf413e (patch)
tree9b5e2c553a7b969b45f753f0b18c73519a692856 /tests
parent557813760d0dc74d5e5afba8aa4ea0310378eec2 (diff)
downloadguix-b0a33ac157ce99688b6d668124377fdd81bf413e.tar.gz
pk-crypto: Rename 'gcry-sexp' to 'canonical-sexp'.
* guix/pk-crypto.scm: Rename procedures, variables, etc. from
  'gcry-sexp' to 'canonical-sexp'.  Add comment with references.
* guix/scripts/authenticate.scm, tests/pk-crypto.scm: Adjust
  accordingly.
Diffstat (limited to 'tests')
-rw-r--r--tests/pk-crypto.scm46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/pk-crypto.scm b/tests/pk-crypto.scm
index eddd5c4945..85f8f9407e 100644
--- a/tests/pk-crypto.scm
+++ b/tests/pk-crypto.scm
@@ -32,7 +32,7 @@
 
 (define %key-pair
   ;; Key pair that was generated with:
-  ;;   (generate-key (string->gcry-sexp "(genkey (rsa (nbits 4:1024)))"))
+  ;;   (generate-key (string->canonical-sexp "(genkey (rsa (nbits 4:1024)))"))
   ;; which takes a bit of time.
   "(key-data
     (public-key
@@ -57,11 +57,11 @@
                ;;"#C0FFEE#"
 
                "(genkey \n (rsa \n  (nbits \"1024\")\n  )\n )")))
-  (test-equal "string->gcry-sexp->string"
+  (test-equal "string->canonical-sexp->string"
     sexps
-    (let ((sexps (map string->gcry-sexp sexps)))
-      (and (every gcry-sexp? sexps)
-           (map (compose string-trim-both gcry-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!
 
@@ -75,43 +75,43 @@
          sexps)
     (map (match-lambda
           ((input token '-> _)
-           (let ((sexp (find-sexp-token (string->gcry-sexp input) token)))
+           (let ((sexp (find-sexp-token (string->canonical-sexp input) token)))
              (and sexp
-                  (string-trim-both (gcry-sexp->string sexp))))))
+                  (string-trim-both (canonical-sexp->string sexp))))))
          sexps)))
 
 (gc)
 
-(test-equal "gcry-sexp-car + cdr"
+(test-equal "canonical-sexp-car + cdr"
   '("(b \n (c xyz)\n )")
-  (let ((lst (string->gcry-sexp "(a (b (c xyz)))")))
+  (let ((lst (string->canonical-sexp "(a (b (c xyz)))")))
     (map (lambda (sexp)
-           (and sexp (string-trim-both (gcry-sexp->string sexp))))
+           (and sexp (string-trim-both (canonical-sexp->string sexp))))
          ;; Note: 'car' returns #f when the first element is an atom.
-         (list (gcry-sexp-car (gcry-sexp-cdr lst))))))
+         (list (canonical-sexp-car (canonical-sexp-cdr lst))))))
 
 (gc)
 
-(test-equal "gcry-sexp-nth"
+(test-equal "canonical-sexp-nth"
   '("(b pqr)" "(c \"456\")" "(d xyz)" #f #f)
 
-  (let ((lst (string->gcry-sexp "(a (b 3:pqr) (c 3:456) (d 3:xyz))")))
-    ;; XXX: In Libgcrypt 1.5.3, (gcry-sexp-nth lst 0) returns LST, whereas in
+  (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 (gcry-sexp->string sexp))))
+           (and sexp (string-trim-both (canonical-sexp->string sexp))))
          (unfold (cut > <> 5)
-                 (cut gcry-sexp-nth lst <>)
+                 (cut canonical-sexp-nth lst <>)
                  1+
                  1))))
 
 (gc)
 
-(test-equal "gcry-sexp-nth-data"
+(test-equal "canonical-sexp-nth-data"
   '("Name" "Otto" "Meier" #f #f #f)
-  (let ((lst (string->gcry-sexp "(Name Otto Meier (address Burgplatz))")))
+  (let ((lst (string->canonical-sexp "(Name Otto Meier (address Burgplatz))")))
     (unfold (cut > <> 5)
-            (cut gcry-sexp-nth-data lst <>)
+            (cut canonical-sexp-nth-data lst <>)
             1+
             0)))
 
@@ -120,9 +120,9 @@
 ;; XXX: The test below is typically too long as it needs to gather enough entropy.
 
 ;; (test-assert "generate-key"
-;;   (let ((key (generate-key (string->gcry-sexp
+;;   (let ((key (generate-key (string->canonical-sexp
 ;;                             "(genkey (rsa (nbits 3:128)))"))))
-;;     (and (gcry-sexp? key)
+;;     (and (canonical-sexp? key)
 ;;          (find-sexp-token key 'key-data)
 ;;          (find-sexp-token key 'public-key)
 ;;          (find-sexp-token key 'private-key))))
@@ -130,13 +130,13 @@
 (test-assert "bytevector->hash-data->bytevector"
   (let* ((bv   (sha256 (string->utf8 "Hello, world.")))
          (data (bytevector->hash-data bv "sha256")))
-    (and (gcry-sexp? data)
+    (and (canonical-sexp? data)
          (let-values (((value algo) (hash-data->bytevector data)))
            (and (string=? algo "sha256")
                 (bytevector=? value bv))))))
 
 (test-assert "sign + verify"
-  (let* ((pair   (string->gcry-sexp %key-pair))
+  (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