[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#43699] [PATCH] guix: Fix argument order of fxbit-set?
From: |
Lars-Dominik Braun |
Subject: |
[bug#43699] [PATCH] guix: Fix argument order of fxbit-set? |
Date: |
Tue, 29 Sep 2020 10:29:23 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
* guix/openpgp.scm (port-ascii-armored?): Fix it here…
(get-packet*): …and here…
(parse-subpackets): …and also here.
* tests/openpgp.scm (%binary-sample): New test vector.
("port-ascii-armored?, #t"): Add test.
("port-ascii-armored?, #f"): Add another test.
---
guix/openpgp.scm | 14 +++++++-------
tests/openpgp.scm | 12 ++++++++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/guix/openpgp.scm b/guix/openpgp.scm
index 33c851255b..f6c9f8ac78 100644
--- a/guix/openpgp.scm
+++ b/guix/openpgp.scm
@@ -239,7 +239,7 @@ writes to PORT the value 42 as an 8-bit integer and the
value #x7777 as a
(let ((idx (fxarithmetic-shift-right i 3))
(bit (fxand i #b111)))
(and (< idx (bytevector-length bv))
- (fxbit-set? (bytevector-u8-ref bv idx) bit))))
+ (fxbit-set? bit (bytevector-u8-ref bv idx)))))
(do ((names names (cdr names))
(i 0 (fx+ i 1))
(bits '()
@@ -410,9 +410,9 @@ hexadecimal format for fingerprints."
(define (port-ascii-armored? p)
(let ((tag (lookahead-u8 p)))
(cond ((eof-object? tag) #f)
- ((not (fxbit-set? tag 7)) #t)
+ ((not (fxbit-set? 7 tag)) #t)
(else
- (let ((type (if (fxbit-set? tag 6)
+ (let ((type (if (fxbit-set? 6 tag)
(fxbit-field tag 0 6)
(fxbit-field tag 2 6))))
(not (<= PACKET-SESSION-KEY type PACKET-MDC)))))))
@@ -444,7 +444,7 @@ hexadecimal format for fingerprints."
(define (get-packet* p get-data)
(let ((tag (get-u8 p)))
;; (unless (fxbit-set? tag 7) (error 'get-packet "Invalid tag" tag))
- (cond ((fxbit-set? tag 6) ;New packet format
+ (cond ((fxbit-set? 6 tag) ;New packet format
(let ((tag (fxbit-field tag 0 6))
(len (get-v4-length p)))
(get-data p tag len)))
@@ -726,7 +726,7 @@ FINGERPRINT, a bytevector."
(define (parse-subpackets bv signature-port)
(define (parse tag data)
(let ((type (fxbit-field tag 0 7))
- (critical? (fxbit-set? tag 7)))
+ (critical? (fxbit-set? 7 tag)))
(cond
((= type SUBPACKET-SIGNATURE-CTIME)
(cons 'signature-ctime
@@ -764,7 +764,7 @@ FINGERPRINT, a bytevector."
(value (get-bytevector-n p vlen)))
(cons 'notation-data
(list (utf8->string name)
- (if (fxbit-set? f1 7)
+ (if (fxbit-set? 7 f1)
(utf8->string value)
value)))))))
((= type SUBPACKET-PREFERRED-HASH-ALGORITHMS)
@@ -777,7 +777,7 @@ FINGERPRINT, a bytevector."
((= type SUBPACKET-KEY-SERVER-PREFERENCES)
(cons 'key-server-preferences
(if (and (>= (bytevector-length data) 1)
- (fxbit-set? (bytevector-u8-ref data 0) 7))
+ (fxbit-set? 7 (bytevector-u8-ref data 0)))
(list 'no-modify)
(list))))
((= type SUBPACKET-PREFERRED-KEY-SERVER)
diff --git a/tests/openpgp.scm b/tests/openpgp.scm
index 0beab6f88b..c2be26fa49 100644
--- a/tests/openpgp.scm
+++ b/tests/openpgp.scm
@@ -50,6 +50,12 @@ vBSFjNSiVHsuAA==
=AAAA
-----END PGP MESSAGE-----\n")
+(define %binary-sample
+ ;; Same message as %radix-64-sample, decoded into bytevector.
+ (base16-string->bytevector
+ "c838013b6d96c411efecef17ecefe3ca0004ce8979ea250a897995f979a9\
+0ad9a9a9050a890ac5a9c945a940c1a2fcd2bc14858cd4a2547b2e00"))
+
(define %civodul-fingerprint
"3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5")
@@ -155,6 +161,12 @@ Pz7oopeN72xgggYUNT37ezqN3MeCqw0=
read-radix-64))
list))
+(test-assert "port-ascii-armored?, #t"
+ (call-with-input-string %radix-64-sample port-ascii-armored?))
+
+(test-assert "port-ascii-armored?, #f"
+ (not (port-ascii-armored? (open-bytevector-input-port %binary-sample))))
+
(test-assert "get-openpgp-keyring"
(let* ((key (search-path %load-path "tests/civodul.key"))
(keyring (get-openpgp-keyring
--
2.26.2
signature.asc
Description: PGP signature
- [bug#43699] [PATCH] guix: Fix argument order of fxbit-set?,
Lars-Dominik Braun <=