-
Notifications
You must be signed in to change notification settings - Fork 6
/
passphrase_handling.t
62 lines (45 loc) · 1.13 KB
/
passphrase_handling.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl -w
#
# $Id: passphrase_handling.t,v 1.6 2001/05/03 06:02:39 ftobin Exp $
#
use strict;
use English qw( -no_match_vars );
use Symbol;
use IO::File;
use lib './t';
use MyTest;
use MyTestSpecific;
TEST
{
reset_handles();
return $gnupg->test_default_key_passphrase()
};
$gnupg->clear_passphrase();
TEST
{
reset_handles();
my $passphrase_handle = gensym;
$handles->passphrase( $passphrase_handle );
my $pid = $gnupg->sign( handles => $handles );
print $passphrase_handle 'test';
print $stdin @{ $texts{plain}->data() };
close $passphrase_handle;
close $stdin;
waitpid $pid, 0;
return $CHILD_ERROR == 0;
};
TEST
{
reset_handles();
$handles->clear_stderr();
$handles->stderr( '>&STDERR' );
my $pass_fn = 'test/passphrase';
my $passfile = IO::File->new( $pass_fn )
or die "cannot open $pass_fn: $ERRNO";
$handles->passphrase( $passfile );
$handles->options( 'passphrase' )->{direct} = 1;
my $pid = $gnupg->sign( handles => $handles );
close $stdin;
waitpid $pid, 0;
return $CHILD_ERROR == 0;
};