3 ;; Copyright (C) 2016 g10 Code GmbH
5 ;; This file is part of GnuPG.
7 ;; GnuPG is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GnuPG is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
20 (load (with-path "defs.scm"))
23 (define GNUPGHOME (getenv "GNUPGHOME"))
24 (if (string=? "" GNUPGHOME)
25 (fail "GNUPGHOME not set"))
27 (setenv "SSH_AUTH_SOCK"
28 (call-check `(,(tool 'gpgconf) --null --list-dirs agent-ssh-socket))
32 (catch (skip "ssh-add not found")
34 (path-expand "ssh-add" (string-split (getenv "PATH") *pathsep*))))
37 '(("dsa" "9a:e1:f1:5f:46:ea:a5:06:e1:e2:f8:38:8e:06:54:58")
38 ("rsa" "c9:85:b5:55:00:84:a9:82:5a:df:d6:62:1b:5a:28:22")
39 ("ecdsa" "93:37:30:a6:4e:e7:6a:22:79:77:8e:bf:ed:14:e9:8e")
40 ("ed25519" "08:df:be:af:d2:f5:32:20:3a:1c:56:06:be:31:0f:bf")))
43 "Importing ssh keys..."
45 (let ((file (path-join (in-srcdir "samplekeys")
46 (string-append "ssh-" (car key) ".key")))
48 ;; We pipe the key to ssh-add so that it won't complain about
49 ;; file's permissions.
51 (pipe:open file (logior O_RDONLY O_BINARY))
52 (pipe:spawn `(,SSH-ADD -)))
53 (unless (string-contains? (call-popen `(,SSH-ADD -l "-E" md5) "") hash)
54 (fail "key not added"))))
57 (info "Checking for issue2316...")
58 (unlink (string-append GNUPGHOME "/sshcontrol"))
60 (pipe:open (path-join (in-srcdir "samplekeys")
61 (string-append "ssh-rsa.key"))
62 (logior O_RDONLY O_BINARY))
63 (pipe:spawn `(,SSH-ADD -)))
65 (string-contains? (call-popen `(,SSH-ADD -l "-E" md5) "")
66 "c9:85:b5:55:00:84:a9:82:5a:df:d6:62:1b:5a:28:22")
67 (fail "known private key not (re-)added to sshcontrol"))