mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tests: Add test for the ssh key export.
* tests/openpgp/Makefile.am (XTESTS): Add new test. (sample_keys): Add new files. * tests/openpgp/samplekeys/authenticate-only.pub.asc: New file. * tests/openpgp/samplekeys/authenticate-only.sec.asc: Likewise. * tests/openpgp/ssh-export.scm: Likewise. GnuPG-bug-id: 2848 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
4db9a42564
commit
47b8b9e2ce
@ -81,6 +81,7 @@ XTESTS = \
|
||||
default-key.scm \
|
||||
export.scm \
|
||||
ssh-import.scm \
|
||||
ssh-export.scm \
|
||||
quick-key-manipulation.scm \
|
||||
key-selection.scm \
|
||||
issue2015.scm \
|
||||
@ -186,7 +187,9 @@ sample_keys = samplekeys/README \
|
||||
samplekeys/ssh-ecdsa.key \
|
||||
samplekeys/ssh-ed25519.key \
|
||||
samplekeys/ssh-rsa.key \
|
||||
samplekeys/issue2346.gpg
|
||||
samplekeys/issue2346.gpg \
|
||||
samplekeys/authenticate-only.pub.asc \
|
||||
samplekeys/authenticate-only.sec.asc
|
||||
|
||||
sample_msgs = samplemsgs/issue2419.asc
|
||||
|
||||
|
31
tests/openpgp/samplekeys/authenticate-only.pub.asc
Normal file
31
tests/openpgp/samplekeys/authenticate-only.pub.asc
Normal file
@ -0,0 +1,31 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQENBFg8F68BCAC5VS/59Nrg5mw+wEAnk/vi0CGI+K5rGTmyAruy/aiS4kYfUJiE
|
||||
Pq/JZYCeNQ9GTbJN5M+Fiv1bhw6xeEfl4FAC/A0Uo39fvUSLJH2V+8lT3GxXt8KR
|
||||
Yx8MvotvoKiG1DRvgnwRh1qibX6+htJahPwHDViUuFz0ZeEPWiCwuoMOELmiTsuE
|
||||
VZbQsv08BwCOzIc3M8s63TtwMCUe+MBhqfRjEu6/Gt7miuGGVFXB96ao2O9u1HsR
|
||||
7cUjgVQ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JBi2JwARAQABiQE2BBgBCAAgFiEEkn7zd/0aG295XkDA
|
||||
KoeRfY/7pJ8FAlg8F9kCGyAACgkQKoeRfY/7pJ+sawf/eSjxxAglAdolF9lK070u
|
||||
VmMgq4GFPqJ3RqJPUFjwEFFSYLXkiALnMGXDSmOfPqCQ4c+PWwumFhKCz4MXVDD8
|
||||
x6mi9Z+HlEwIMaCnckrSTuQ5OgwO/6vkhz42OcgMZ3WQnWfNVM8jbNP9vX1vroPe
|
||||
HLFaPGy9KJMM0Z/hlCIIeyK/a90zWlT5UMfRoqNQRbY/iiYdmpvf69I9PobGVbo/
|
||||
7ahZTumPWwjiGOztNXeuo5UUaAVVxMQBYKp2w3wil2sHzYfTfYUSMyh+oUFx4Xlz
|
||||
WF3bLzsafRaeuK1h5+JuvIcimvU5zWZtn0hOpiIXpZOoJvvM9r5D4ZRT5UX2blQ8
|
||||
Pw==
|
||||
=vt5C
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
60
tests/openpgp/samplekeys/authenticate-only.sec.asc
Normal file
60
tests/openpgp/samplekeys/authenticate-only.sec.asc
Normal file
@ -0,0 +1,60 @@
|
||||
-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||
|
||||
lQPGBFg8F68BCAC5VS/59Nrg5mw+wEAnk/vi0CGI+K5rGTmyAruy/aiS4kYfUJiE
|
||||
Pq/JZYCeNQ9GTbJN5M+Fiv1bhw6xeEfl4FAC/A0Uo39fvUSLJH2V+8lT3GxXt8KR
|
||||
Yx8MvotvoKiG1DRvgnwRh1qibX6+htJahPwHDViUuFz0ZeEPWiCwuoMOELmiTsuE
|
||||
VZbQsv08BwCOzIc3M8s63TtwMCUe+MBhqfRjEu6/Gt7miuGGVFXB96ao2O9u1HsR
|
||||
7cUjgVQp6JwGLgIIijjy167Ms+fKZetqA9tzu1C1SAtNYiqmAUoqGG1YEjS7oApo
|
||||
AKmHD+LGCMUPg5d6bhw+NyHjDAFWJEYv3kG3ABEBAAH+BwMCzWzbxiWo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ndZCdZ81UzyNs0/29fW+u
|
||||
g94csVo8bL0okwzRn+GUIgh7Ir9r3TNaVPlQx9Gio1BFtj+KJh2am9/r0j0+hsZV
|
||||
uj/tqFlO6Y9bCOIY7O01d66jlRRoBVXExAFgqnbDfCKXawfNh9N9hRIzKH6hQXHh
|
||||
eXNYXdsvOxp9Fp64rWHn4m68hyKa9TnNZm2fSE6mIhelk6gm+8z2vkPhlFPlRfZu
|
||||
VDw/
|
||||
=vLFX
|
||||
-----END PGP PRIVATE KEY BLOCK-----
|
52
tests/openpgp/ssh-export.scm
Executable file
52
tests/openpgp/ssh-export.scm
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env gpgscm
|
||||
|
||||
;; Copyright (C) 2016 g10 Code GmbH
|
||||
;;
|
||||
;; This file is part of GnuPG.
|
||||
;;
|
||||
;; GnuPG is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; GnuPG is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(load (with-path "defs.scm"))
|
||||
(setup-environment)
|
||||
|
||||
(define key
|
||||
`(,(in-srcdir "samplekeys" "authenticate-only.sec.asc")
|
||||
"927EF377FD1A1B6F795E40C02A87917D8FFBA49F"
|
||||
"72360FDB6380212D5DAF2FA9E51185A9253C496D"
|
||||
"ssh-rsa"))
|
||||
|
||||
(define :file car)
|
||||
(define :fpr cadr)
|
||||
(define :subkey-fpr caddr)
|
||||
(define :kind cadddr)
|
||||
|
||||
;; Return true if a-str and b-str share a suffix of length n.
|
||||
(define (string-common-suffix? n a-str b-str)
|
||||
(let ((a-len (string-length a-str))
|
||||
(b-len (string-length b-str)))
|
||||
(if (> n (min a-len b-len))
|
||||
#f
|
||||
(string=? (substring a-str (- a-len n) a-len)
|
||||
(substring b-str (- b-len n) b-len)))))
|
||||
|
||||
(info "Checking ssh export...")
|
||||
(call-check `(,@GPG --yes --import ,(:file key)))
|
||||
|
||||
(let* ((result (call-check `(,@GPG --export-ssh-key ,(:fpr key))))
|
||||
;; XXX: We should split at any whitespace here.
|
||||
(parts (string-split (string-trim char-whitespace? result) #\space)))
|
||||
(assert (string=? (car parts) (:kind key)))
|
||||
;; XXX: We should not use a short keyid as the comment when
|
||||
;; exporting an ssh key.
|
||||
(assert (string-common-suffix? 8 (caddr parts) (:subkey-fpr key))))
|
Loading…
x
Reference in New Issue
Block a user