chiark / gitweb /
doc: Document summary values of TOFU_STATS
[gnupg2.git] / tests / openpgp / import.scm
1 #!/usr/bin/env gpgscm
2
3 ;; Copyright (C) 2016 g10 Code GmbH
4 ;;
5 ;; This file is part of GnuPG.
6 ;;
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.
11 ;;
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.
16 ;;
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/>.
19
20 (load (with-path "defs.scm"))
21 (setup-environment)
22
23 (info "Checking bug 894: segv importing certain keys.")
24 (call-check `(,(tool 'gpg) --import ,(in-srcdir "bug894-test.asc")))
25
26 (define keyid "0xC108E83A")
27 (info "Checking bug 1223: designated revoker sigs are not properly merged.")
28 (call `(,(tool 'gpg) --delete-key --batch --yes ,keyid))
29 (call `(,(tool 'gpg) --import ,(in-srcdir "bug1223-bogus.asc")))
30 (call `(,(tool 'gpg) --import ,(in-srcdir "bug1223-good.asc")))
31 (tr:do
32  (tr:pipe-do
33   (pipe:gpg `(--list-keys --with-colons ,keyid)))
34  (tr:call-with-content
35   (lambda (c)
36     ;; XXX we do not have a regexp library
37     (unless (any (lambda (line)
38                    (and (string-prefix? line "rvk:")
39                         (string-contains? line ":0EE5BE979282D80B9F7540F1CCD2ED94D21739E9:")))
40                  (string-split-newlines c))
41             (exit 1)))))
42
43 (define fpr1 "9E669861368BCA0BE42DAF7DDDA252EBB8EBE1AF")
44 (define fpr2 "A55120427374F3F7AA5F1166DDA252EBB8EBE1AF")
45 (info "Checking import of two keys with colliding long key ids.")
46 (call `(,(tool 'gpg) --delete-key --batch --yes ,fpr1 ,fpr2))
47 (call `(,(tool 'gpg) --import ,(in-srcdir "samplekeys/dda252ebb8ebe1af-1.asc")))
48 (call `(,(tool 'gpg) --import ,(in-srcdir "samplekeys/dda252ebb8ebe1af-2.asc")))
49 (tr:do
50  (tr:pipe-do
51   (pipe:gpg `(--list-keys --with-colons ,fpr1 ,fpr2)))
52  (tr:call-with-content
53   (lambda (c)
54     ;; XXX we do not have a regexp library
55     (let ((keys (filter
56                  (lambda (line)
57                    (and (string-prefix? line "pub:")
58                         (string-contains? line ":4096:1:DDA252EBB8EBE1AF:")))
59                  (string-split-newlines c))))
60       (unless (= 2 (length keys))
61               (fail "Importing keys with long id collision failed"))))))