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"))
21 (setup-legacy-environment)
23 (catch (skip "gpgtar not built")
24 (call-check `(,(tool 'gpgtar) --help)))
26 (define testfiles (append plain-files data-files))
28 (if have-opt-always-trust
29 "--no-permission-warning --always-trust"
30 "--no-permission-warning"))
32 (define (do-test create-flags inspect-flags extract-flags)
34 (call-check `(,(tool 'gpgtar) --gpg ,(tool 'gpg) --gpg-args ,gpgargs
40 (pipe:spawn `(,(tool 'gpgtar) --gpg ,(tool 'gpg) --gpg-args ,gpgargs
41 --list-archive ,@inspect-flags
45 (unless (all (lambda (f) (string-contains? c f)) testfiles)
46 (fail "some file(s) are missing from archive")))))
48 (with-temporary-working-directory
49 (call-check `(,(tool 'gpgtar) --gpg ,(tool 'gpg) --gpg-args ,gpgargs
50 --tar-args --directory=.
55 (lambda (f) (unless (call-with-input-file f (lambda (x) #t))
56 (fail (string-append "missing file: " f))))
59 (info "Checking gpgtar without encryption")
60 (do-test '(--skip-crypto --encrypt) '(--skip-crypto)
61 '(--skip-crypto --decrypt))
63 (info "Checking gpgtar without encryption with nicer actions")
64 (do-test '(--create) '(--skip-crypto) '(--extract))
66 (info "Checking gpgtar with asymmetric encryption")
67 (do-test `(--encrypt --recipient ,usrname2) '() '(--decrypt))
69 (info "Checking gpgtar with asymmetric encryption and signature")
70 (do-test `(--encrypt --recipient ,usrname2 --sign --local-user ,usrname3)
73 (info "Checking gpgtar with signature")
74 (do-test `(--sign --local-user ,usrname3) '() '(--decrypt))
76 (lettmp (passphrasefile)
77 (letfd ((fd (open passphrasefile (logior O_WRONLY O_CREAT O_BINARY) #o600)))
78 (display "streng geheimes hupsipupsi" (fdopen fd "wb")))
80 (let ((ppflags `(--gpg-args ,(string-append "--passphrase-file="
82 (info "Checking gpgtar with symmetric encryption")
83 (do-test `(,@ppflags --symmetric) ppflags (cons '--decrypt ppflags))
85 (info "Checking gpgtar with symmetric encryption and chosen cipher")
86 (do-test `(,@ppflags --symmetric --gpg-args
87 ,(string-append "--cipher="
88 (car (force all-cipher-algos))))
89 ppflags (cons '--decrypt ppflags))
91 (info "Checking gpgtar with both symmetric and asymmetric encryption")
92 (do-test `(,@ppflags --symmetric --encrypt --recipient ,usrname2
93 --sign --local-user ,usrname3)
94 ppflags (cons '--decrypt ppflags))))