summaryrefslogtreecommitdiffstats
path: root/tpm-tools/initandverify/Sign_Verify_test.sh
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-03-30 20:27:32 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-30 20:27:32 +0000
commit183342f64c1574968a5ae08a6d0486f688d395e3 (patch)
tree3ea2086e1af58f999eee0b52f58ce72dc57b5bbc /tpm-tools/initandverify/Sign_Verify_test.sh
parent337e67515bb081df614ae7e8313c904499e3505f (diff)
parent76f424e841653b899504d8064f1055f8c114985d (diff)
Merge "tpm tools for the below functionalities"
Diffstat (limited to 'tpm-tools/initandverify/Sign_Verify_test.sh')
-rwxr-xr-xtpm-tools/initandverify/Sign_Verify_test.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tpm-tools/initandverify/Sign_Verify_test.sh b/tpm-tools/initandverify/Sign_Verify_test.sh
new file mode 100755
index 0000000..660dff9
--- /dev/null
+++ b/tpm-tools/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
+