Browse Source

publish: Export 'signed-string'.

* guix/scripts/publish.scm (signed-string): Export and improve docstring.
* tests/publish.scm ("/*.narinfo")
("/*.narinfo with properly encoded '+' sign"): Adjust accordingly.
wip-pinebook-pro
Ludovic Courtès 2 years ago
parent
commit
4fe01b09ea
No known key found for this signature in database GPG Key ID: 90B11993D9AEBB5
  1. 4
      guix/scripts/publish.scm
  2. 8
      tests/publish.scm

4
guix/scripts/publish.scm

@ -64,6 +64,7 @@
#:use-module ((guix build syscalls) #:select (set-thread-name))
#:export (%public-key
%private-key
signed-string
guix-publish))
@ -237,7 +238,8 @@ if ITEM is already compressed."
("Priority" . 100)))
(define (signed-string s)
"Sign the hash of the string S with the daemon's key."
"Sign the hash of the string S with the daemon's key. Return a canonical
sexp for the signature."
(let* ((public-key (%public-key))
(hash (bytevector->hash-data (sha256 (string->utf8 s))
#:key-type (key-type public-key))))

8
tests/publish.scm

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@ -153,8 +153,7 @@ References: ~a~%"
(signature (base64-encode
(string->utf8
(canonical-sexp->string
((@@ (guix scripts publish) signed-string)
unsigned-info))))))
(signed-string unsigned-info))))))
(format #f "~aSignature: 1;~a;~a~%"
unsigned-info (gethostname) signature))
(utf8->string
@ -184,8 +183,7 @@ References: ~%"
(signature (base64-encode
(string->utf8
(canonical-sexp->string
((@@ (guix scripts publish) signed-string)
unsigned-info))))))
(signed-string unsigned-info))))))
(format #f "~aSignature: 1;~a;~a~%"
unsigned-info (gethostname) signature))

Loading…
Cancel
Save