aboutsummaryrefslogtreecommitdiffstats
path: root/tpm-util/initandverify/Sign_Verify_test.sh
diff options
context:
space:
mode:
authorarunkumarsit <arunkumarsit@gmail.com>2018-03-30 10:43:06 -0700
committerArun kumar Sekar <arunkumarsit@gmail.com>2018-03-30 11:01:04 -0700
commit3d5e48d877919ec8d33e1d1ee3682fb1f0bc0532 (patch)
tree316857ab79c37f3c7425ecdae2a536740800aaef /tpm-util/initandverify/Sign_Verify_test.sh
parent183342f64c1574968a5ae08a6d0486f688d395e3 (diff)
Folder name changed from tpm-tools to tpm-util
Change-Id: Ica9eca7f32fac0757a9c1718c1e5ec7c922ca8cd Issue-ID: AAF-207 Signed-off-by: Arun kumar sekar <arunkumarsit@gmail.com>
Diffstat (limited to 'tpm-util/initandverify/Sign_Verify_test.sh')
-rwxr-xr-xtpm-util/initandverify/Sign_Verify_test.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tpm-util/initandverify/Sign_Verify_test.sh b/tpm-util/initandverify/Sign_Verify_test.sh
new file mode 100755
index 0000000..660dff9
--- /dev/null
+++ b/tpm-util/initandverify/Sign_Verify_test.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+echo "hello world.." > hello_tpm.txt
+
+# Load the Child context in TPM
+rm -f ChildKeyName ContextChild
+tpm2_load -H 0x81000011 -u outPub -r outPriv -n ChildKeyName -C ContextChild
+
+echo "tpm2_hash -H o -g 0x00B -I hello_tpm.txt -o hello_tpm_hash.bin -t outTicket"
+rm -f hello_tpm_hash.bin outTicket
+tpm2_hash -H o -g 0x00B -I hello_tpm.txt -o hello_tpm_hash.bin -t outTicket
+echo ""
+
+echo "tpm2_sign -c ContextChild -g 0x000B -m hello_tpm.txt -s hello_tpm.sig"
+rm -f hello_tpm.sig
+tpm2_sign -c ContextChild -g 0x000B -m hello_tpm.txt -s hello_tpm.sig
+echo ""
+
+echo "tpm2_verifysignature -c ContextChild -g 0x000b -m hello_tpm.txt -s hello_tpm.sig -t tk.sig"
+rm -f tk.sig
+tpm2_verifysignature -c ContextChild -g 0x000b -m hello_tpm.txt -s hello_tpm.sig -t tk.sig
+echo ""
+
+echo "Extracting signature from TPM format"
+echo "dd if=hello_tpm.sig of=hello_tpm.sig.raw bs=1 skip=6 count=256"
+rm -f hello_tpm.sig.raw
+dd if=hello_tpm.sig of=hello_tpm.sig.raw bs=1 skip=6 count=256
+echo ""
+
+echo "openssl dgst -verify public.pem -keyform pem -sha256 -signature hello_tpm.sig.raw hello_tpm.txt"
+openssl dgst -verify public.pem -keyform pem -sha256 -signature hello_tpm.sig.raw hello_tpm.txt
+echo ""
+
+rm -f hello_tpm_hash.bin outTicket tk.sig
+