#!/bin/bash set -eufx echo -n "abcde12345abcde12345">mydata.txt # Create an Primary key pair echo "Generating primary key" PARENT_CTX=primary_owner_key.ctx tpm2_createprimary --hierarchy=o --hash-algorithm=sha256 --key-algorithm=rsa \ --key-context=${PARENT_CTX} --key-auth=abc tpm2_flushcontext --transient-object # Load primary key to persistent handle HANDLE=$(tpm2_evictcontrol --hierarchy=o --object-context=${PARENT_CTX} | cut -d ' ' -f 2 | head -n 1) tpm2_flushcontext --transient-object # Generating a key underneath the persistent, password protected, parent tpm2tss-genkey -a rsa -s 2048 -p abc -P ${HANDLE} -W abc mykey cat > engine.conf </dev/null; then echo $R exit 1 fi