blob: 97872ad24546d125066cac2a72a17186d04878f4 (
plain)
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
63
64
|
# file : tests/client.testscript
# license : MIT; see accompanying LICENSE file
test.arguments += rsautl -sign -keyform engine -engine pkcs11
: args
:
{
: none
:
$* 2>'error: -inkey option is required' != 0
: no-sock
:
env --unset=OPENSSL_AGENT_PKCS11_SOCK - $* -inkey 'pkcs11:' 2>>EOE != 0
error: OPENSSL_AGENT_PKCS11_SOCK environment variable is not set
EOE
}
: pkcs11
:
{
+sed -e 's/-client$/-agent-pkcs11/' <"$0" | set agent
: communication
:
{
# Start the agent.
#
+$agent --simulate success 'pkcs11:?pin-value=123123' | set script
+sed -n -e 's/^OPENSSL_AGENT_PKCS11_PID=(.+);.+$/\1/p' <"$script" | set pid
+sed -n -e 's/^OPENSSL_AGENT_PKCS11_SOCK=(.+);.+;$/\1/p' <"$script" | set sock
sign = env - OPENSSL_AGENT_PKCS11_SOCK="$sock" $*
: sign
:
{
$sign --simulate success -inkey 'pkcs11:' >'signature' : simulate-opt
$sign -inkey 'pkcs11:' >'signature' : no-simulate-opt
}
: failure
:
{
$sign --simulate failure -inkey 'pkcs11:' 2>>EOE != 0
error: unable to sign using simulated private key
EOE
}
: wrong-key
:
{
$sign --simulate success -inkey 'pkcs11:object=key' 2>>EOE != 0
error: private key doesn't match
EOE
}
# Stop the agent.
#
-kill "$pid"
}
}
|