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 (setenv "SSH_AUTH_SOCK"
24 (call-check `(,(tool 'gpgconf) --null --list-dirs agent-ssh-socket))
28 (catch (skip "ssh-add not found")
30 (path-expand "ssh-add" (string-split (getenv "PATH") *pathsep*))))
33 '(("dsa" "9a:e1:f1:5f:46:ea:a5:06:e1:e2:f8:38:8e:06:54:58")
34 ("rsa" "c9:85:b5:55:00:84:a9:82:5a:df:d6:62:1b:5a:28:22")
35 ("ecdsa" "93:37:30:a6:4e:e7:6a:22:79:77:8e:bf:ed:14:e9:8e")
36 ("ed25519" "08:df:be:af:d2:f5:32:20:3a:1c:56:06:be:31:0f:bf")))
39 "Importing ssh keys..."
41 (let ((file (path-join (in-srcdir "samplekeys")
42 (string-append "ssh-" (car key) ".key")))
44 ;; We pipe the key to ssh-add so that it won't complain about
45 ;; file's permissions.
47 (pipe:open file (logior O_RDONLY O_BINARY))
48 (pipe:spawn `(,SSH-ADD -)))
49 (unless (string-contains? (call-popen `(,SSH-ADD -l "-E" md5) "") hash)
50 (fail "key not added"))))
53 (info "Checking for issue2316...")
54 (unlink (path-join GNUPGHOME "sshcontrol"))
56 (pipe:open (path-join (in-srcdir "samplekeys")
57 (string-append "ssh-rsa.key"))
58 (logior O_RDONLY O_BINARY))
59 (pipe:spawn `(,SSH-ADD -)))
61 (string-contains? (call-popen `(,SSH-ADD -l "-E" md5) "")
62 "c9:85:b5:55:00:84:a9:82:5a:df:d6:62:1b:5a:28:22")
63 (fail "known private key not (re-)added to sshcontrol"))