Generate and store Symmetric AES keys in TPM2

240 views Asked by At

I would like to generate 100s if not 1000s of AES-256 keys and store it in TPM or atleast maintained by TPM so that I can retreive the keys whenever I need and these keys should persist reboots.

tpm2_startup -c
        
tpm2_createprimary -C o -G rsa -g sha256 -c aesprim.ctx
        
for i in {1..100}; do
     tpm2_create -C aesprim.ctx -u aes_key_${i}.pub -r aes_key_${i}.priv -G aes256
     tpm2_load -C aesprim.ctx -u aes_key_${i}.pub -r aes_key_${i}.priv -n aes_key_${i}.name -c aes_key_${i}.ctx
done
    
for i in {1..100}; do
   tpm2_evictcontrol -C o -c aes_key_${i}.ctx
   tpm2_readpublic -c aes_key_${i}.ctx -o aes_key_${i}_pub.pem
done

With above commands, I am out of memory to store aes_key_${i}.ctx. Any help or pointers is appreciated.

0

There are 0 answers