Skip to content

Commit 4607488

Browse files
diabonasAndreas Fuchs
authored and
Andreas Fuchs
committed
test: use tpm2-tools 4.X
Since tpm2-tools 4.0 has been released, we can update our tests. tpm2-tools 4.0 also requires tpm2-tss 2.3, so bump that as well. Signed-off-by: Jonas Witschel <[email protected]>
1 parent e1bbabe commit 4607488

6 files changed

+39
-38
lines changed

.travis.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ dist: xenial
77

88
env:
99
matrix:
10-
- OPENSSL_BRANCH=OpenSSL_1_0_2-stable TPM2TSS_BRANCH=2.2.x TPM2TOOLS_BRANCH=3.X
11-
- OPENSSL_BRANCH=OpenSSL_1_1_0-stable TPM2TSS_BRANCH=2.2.x TPM2TOOLS_BRANCH=3.X
12-
- OPENSSL_BRANCH=OpenSSL_1_1_1-stable TPM2TSS_BRANCH=2.2.x TPM2TOOLS_BRANCH=3.X
10+
- OPENSSL_BRANCH=OpenSSL_1_0_2-stable TPM2TSS_BRANCH=2.3.x TPM2TOOLS_BRANCH=4.X
11+
- OPENSSL_BRANCH=OpenSSL_1_1_0-stable TPM2TSS_BRANCH=2.3.x TPM2TOOLS_BRANCH=4.X
12+
- OPENSSL_BRANCH=OpenSSL_1_1_1-stable TPM2TSS_BRANCH=2.3.x TPM2TOOLS_BRANCH=4.X
1313
global:
1414
- TPM2TOOLS_TCTI=mssim
1515
- PATH="${PWD}/installdir/usr/local/bin:${PATH}"
@@ -63,6 +63,7 @@ install:
6363
- git clone --depth=1 -b ${TPM2TSS_BRANCH} https://github.com/tpm2-software/tpm2-tss.git
6464
- pushd tpm2-tss
6565
- cp ../autoconf-archive-2017.09.28/m4/ax_code_coverage.m4 m4/
66+
- cp ../autoconf-archive-2017.09.28/m4/ax_is_release.m4 m4/
6667
- cp ../autoconf-archive-2017.09.28/m4/ax_prog_doxygen.m4 m4/
6768
- ./bootstrap
6869
- ./configure CFLAGS=-I${PWD}/../installdir/usr/local/include LDFLAGS=-L${PWD}/../installdir/usr/local/lib --disable-doxygen-doc
@@ -74,7 +75,7 @@ install:
7475
- git clone --depth=1 -b ${TPM2TOOLS_BRANCH} https://github.com/tpm2-software/tpm2-tools.git
7576
- pushd tpm2-tools
7677
- mkdir m4 || true
77-
- cp ../autoconf-archive-2017.09.28/m4/ax_code_coverage.m4 m4/
78+
- cp ../autoconf-archive-2017.09.28/m4/ax_code_coverage.m4 ../autoconf-archive-2017.09.28/m4/ax_is_release.m4 m4/
7879
- ./bootstrap
7980
# Some workarounds for tpm2-tools with -Wno-XXX
8081
- ./configure --disable-hardening CFLAGS="-I${PWD}/../installdir/usr/local/include -Wno-unused-value -Wno-missing-field-initializer" LDFLAGS=-L${PWD}/../installdir/usr/local/lib

INSTALL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
Integration tests also require:
1616
* expect
17-
* tpm2-tools 3.2 (or 3.X branch)
17+
* tpm2-tools 4.0 (or 4.X branch)
1818
* tpm_server
1919
* realpath
2020
* ss

test/rsasign_parent.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ echo -n "abcde12345abcde12345">mydata.txt
88
echo "Generating primary key"
99
PARENT_CTX=primary_owner_key.ctx
1010

11-
tpm2_createprimary --hierarchy=o --halg=sha256 --kalg=rsa \
12-
--context=${PARENT_CTX}
11+
tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=rsa \
12+
--key-context=${PARENT_CTX}
1313
tpm2_flushcontext --transient-object
1414

1515
# Load primary key to persistent handle
16-
HANDLE=$(tpm2_evictcontrol --auth=o --context=${PARENT_CTX} --persistent=0x81010001 | cut -d ' ' -f 2 | head -n 1)
16+
HANDLE=$(tpm2_evictcontrol --hierarchy=o --object-context=${PARENT_CTX} | cut -d ' ' -f 2 | head -n 1)
1717
tpm2_flushcontext --transient-object
1818

1919
# Generating a key underneath the persistent parent
@@ -25,7 +25,7 @@ cat mykey.pub
2525
echo "abc" | openssl pkeyutl -engine tpm2tss -keyform engine -inkey mykey -sign -in mydata.txt -out mysig -passin stdin
2626

2727
# Release persistent HANDLE
28-
tpm2_evictcontrol --auth=o --handle=${HANDLE} --persistent=${HANDLE}
28+
tpm2_evictcontrol --hierarchy=o --object-context=${HANDLE}
2929

3030
#this is a workaround because -verify allways exits 1
3131
R="$(openssl pkeyutl -pubin -inkey mykey.pub -verify -in mydata.txt -sigfile mysig || true)"

test/rsasign_parent_pass.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ echo -n "abcde12345abcde12345">mydata.txt
88
echo "Generating primary key"
99
PARENT_CTX=primary_owner_key.ctx
1010

11-
tpm2_createprimary --hierarchy=o --halg=sha256 --kalg=rsa \
12-
--context=${PARENT_CTX} --pwdk=abc
11+
tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=rsa \
12+
--key-context=${PARENT_CTX} --key-auth=abc
1313
tpm2_flushcontext --transient-object
1414

1515
# Load primary key to persistent handle
16-
HANDLE=$(tpm2_evictcontrol --auth=o --context=${PARENT_CTX} --persistent=0x81010001 | cut -d ' ' -f 2 | head -n 1)
16+
HANDLE=$(tpm2_evictcontrol --hierarchy=o --object-context=${PARENT_CTX} | cut -d ' ' -f 2 | head -n 1)
1717
tpm2_flushcontext --transient-object
1818

1919
# Generating a key underneath the persistent, password protected, parent
@@ -40,7 +40,7 @@ cat mykey.pub
4040
echo "abc" | openssl pkeyutl -engine tpm2tss -keyform engine -inkey mykey -sign -in mydata.txt -out mysig -passin stdin
4141

4242
# Release persistent HANDLE
43-
tpm2_evictcontrol --auth=o --handle=${HANDLE} --persistent=${HANDLE}
43+
tpm2_evictcontrol --hierarchy=o --object-context=${HANDLE}
4444

4545
#this is a workaround because -verify allways exits 1
4646
R="$(openssl pkeyutl -pubin -inkey mykey.pub -verify -in mydata.txt -sigfile mysig || true)"

test/rsasign_persistent.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@ echo -n "abcde12345abcde12345">mydata.txt
88
echo "Generating primary key"
99
PARENT_CTX=primary_owner_key.ctx
1010

11-
tpm2_createprimary --hierarchy=o --halg=sha256 --kalg=rsa \
12-
--context=${PARENT_CTX}
11+
tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=rsa \
12+
--key-context=${PARENT_CTX}
1313
tpm2_flushcontext --transient-object
1414

1515
# Create an RSA key pair
1616
echo "Generating RSA key pair"
1717
TPM_RSA_PUBKEY=rsakey.pub
1818
TPM_RSA_KEY=rsakey
19-
tpm2_create --pwdk=abc \
20-
--context-parent=${PARENT_CTX} \
21-
--halg=sha256 --kalg=rsa \
22-
--pubfile=${TPM_RSA_PUBKEY} --privfile=${TPM_RSA_KEY} \
23-
--object-attributes=sign\|decrypt\|fixedtpm\|fixedparent\|sensitivedataorigin\|userwithauth\|noda
19+
tpm2_create --key-auth=abc \
20+
--parent-context=${PARENT_CTX} \
21+
--hash-algorithm=sha256 --key-algorithm=rsa \
22+
--public=${TPM_RSA_PUBKEY} --private=${TPM_RSA_KEY} \
23+
--attributes=sign\|decrypt\|fixedtpm\|fixedparent\|sensitivedataorigin\|userwithauth\|noda
2424
tpm2_flushcontext --transient-object
2525

2626
# Load Key to persistent handle
2727
RSA_CTX=rsakey.ctx
28-
tpm2_load --context-parent=${PARENT_CTX} \
29-
--pubfile=${TPM_RSA_PUBKEY} --privfile=${TPM_RSA_KEY} \
30-
--context=${RSA_CTX}
28+
tpm2_load --parent-context=${PARENT_CTX} \
29+
--public=${TPM_RSA_PUBKEY} --private=${TPM_RSA_KEY} \
30+
--key-context=${RSA_CTX}
3131
tpm2_flushcontext --transient-object
3232

33-
HANDLE=$(tpm2_evictcontrol --auth=o --context=${RSA_CTX} --persistent=0x81010001 | cut -d ' ' -f 2 | head -n 1)
33+
HANDLE=$(tpm2_evictcontrol --hierarchy=o --object-context=${RSA_CTX} | cut -d ' ' -f 2 | head -n 1)
3434
tpm2_flushcontext --transient-object
3535

3636
# Signing Data
3737
echo "abc" | openssl pkeyutl -engine tpm2tss -keyform engine -inkey ${HANDLE} -sign -in mydata.txt -out mysig -passin stdin
3838
# Get public key of handle
39-
tpm2_readpublic --object=${HANDLE} --opu=mykey.pem --format=pem
39+
tpm2_readpublic --object-context=${HANDLE} --output=mykey.pem --format=pem
4040

4141
# Release persistent HANDLE
42-
tpm2_evictcontrol --auth=o --handle=${HANDLE} --persistent=${HANDLE}
42+
tpm2_evictcontrol --hierarchy=o --object-context=${HANDLE}
4343

4444
R="$(openssl pkeyutl -pubin -inkey mykey.pem -verify -in mydata.txt -sigfile mysig || true)"
4545
if ! echo $R | grep "Signature Verified Successfully" >/dev/null; then

test/rsasign_persistent_emptyauth.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ echo -n "abcde12345abcde12345">mydata.txt
88
echo "Generating primary key"
99
PARENT_CTX=primary_owner_key.ctx
1010

11-
tpm2_createprimary --hierarchy=o --halg=sha256 --kalg=rsa \
12-
--context=${PARENT_CTX}
11+
tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=rsa \
12+
--key-context=${PARENT_CTX}
1313
tpm2_flushcontext --transient-object
1414

1515
# Create an RSA key pair
1616
echo "Generating RSA key pair"
1717
TPM_RSA_PUBKEY=rsakey.pub
1818
TPM_RSA_KEY=rsakey
19-
tpm2_create --context-parent=${PARENT_CTX} \
20-
--halg=sha256 --kalg=rsa \
21-
--pubfile=${TPM_RSA_PUBKEY} --privfile=${TPM_RSA_KEY} \
22-
--object-attributes=sign\|decrypt\|fixedtpm\|fixedparent\|sensitivedataorigin\|userwithauth\|noda
19+
tpm2_create --parent-context=${PARENT_CTX} \
20+
--hash-algorithm=sha256 --key-algorithm=rsa \
21+
--public=${TPM_RSA_PUBKEY} --private=${TPM_RSA_KEY} \
22+
--attributes=sign\|decrypt\|fixedtpm\|fixedparent\|sensitivedataorigin\|userwithauth\|noda
2323
tpm2_flushcontext --transient-object
2424

2525
# Load Key to persistent handle
2626
RSA_CTX=rsakey.ctx
27-
tpm2_load --context-parent=${PARENT_CTX} \
28-
--pubfile=${TPM_RSA_PUBKEY} --privfile=${TPM_RSA_KEY} \
29-
--context=${RSA_CTX}
27+
tpm2_load --parent-context=${PARENT_CTX} \
28+
--public=${TPM_RSA_PUBKEY} --private=${TPM_RSA_KEY} \
29+
--key-context=${RSA_CTX}
3030
tpm2_flushcontext --transient-object
3131

32-
HANDLE=$(tpm2_evictcontrol --auth=o --context=${RSA_CTX} --persistent=0x81010001 | cut -d ' ' -f 2 | head -n 1)
32+
HANDLE=$(tpm2_evictcontrol --hierarchy=o --object-context=${RSA_CTX} | cut -d ' ' -f 2 | head -n 1)
3333
tpm2_flushcontext --transient-object
3434

3535
# Signing Data
@@ -45,10 +45,10 @@ EOF
4545
fi
4646

4747
# Get public key of handle
48-
tpm2_readpublic --object=${HANDLE} --opu=mykey.pem --format=pem
48+
tpm2_readpublic --object-context=${HANDLE} --output=mykey.pem --format=pem
4949

5050
# Release persistent HANDLE
51-
tpm2_evictcontrol --auth=o --handle=${HANDLE} --persistent=${HANDLE}
51+
tpm2_evictcontrol --hierarchy=o --object-context=${HANDLE}
5252

5353
R="$(openssl pkeyutl -pubin -inkey mykey.pem -verify -in mydata.txt -sigfile mysig || true)"
5454
if ! echo $R | grep "Signature Verified Successfully" >/dev/null; then

0 commit comments

Comments
 (0)