mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-08 20:53:34 +00:00
swtpm_setup: Prepare code for ECC primary storage key
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
2bafefe287
commit
60bee0c78c
@ -967,10 +967,7 @@ tpm2_createprimary_ek_ecc()
|
||||
{
|
||||
local flags="$1"
|
||||
|
||||
local req rsq exp res min_exp
|
||||
local flags="$1"
|
||||
|
||||
local req rsq exp res symkeydata keyflags totlen publen off1 off2
|
||||
local min_exp symkeydata keyflags totlen publen off1 off2 authpolicy
|
||||
|
||||
if [ $((flags & SETUP_ALLOW_SIGNING_F)) -ne 0 ]; then
|
||||
# keyflags: fixedTPM, fixedParent, sensitiveDatOrigin,
|
||||
@ -999,12 +996,37 @@ tpm2_createprimary_ek_ecc()
|
||||
off2=324
|
||||
fi
|
||||
|
||||
authpolicy='\\x83\\x71\\x97\\x67\\x44\\x84\\xb3\\xf8\\x1a\\x90\\xcc\\x8d'
|
||||
authpolicy+='\\x46\\xa5\\xd7\\x24\\xfd\\x52\\xd7\\x6e\\x06\\x52\\x0b\\x64'
|
||||
authpolicy+='\\xf2\\xa1\\xda\\x1b\\x33\\x14\\x69\\xaa'
|
||||
|
||||
tpm2_createprimary_ecc_params '\\x40\\x00\\x00\\x0b' "${keyflags}" \
|
||||
"${symkeydata}" "${publen}" "${totlen}" "${min_exp}" "${off1}" \
|
||||
"${off2}" "${authpolicy}"
|
||||
return $?
|
||||
}
|
||||
|
||||
tpm2_createprimary_ecc_params()
|
||||
{
|
||||
local primaryhandle="$1"
|
||||
local keyflags="$2"
|
||||
local symkeydata="$3"
|
||||
local publen="$4"
|
||||
local totlen="$5"
|
||||
local min_exp="$6"
|
||||
local off1="$7"
|
||||
local off2="$8"
|
||||
local authpolicy="$9"
|
||||
|
||||
local req rsp res
|
||||
local authpolicylen=$((${#authpolicy} / 5))
|
||||
|
||||
# Check the TCG EK Credential Profile doc for TPM 2 for
|
||||
# parameters used here
|
||||
|
||||
req='\x80\x02@TOTLEN-4@\x00\x00\x01\x31'
|
||||
# TPM_RH_ENDORSEMENT
|
||||
req+='\x40\x00\x00\x0b'
|
||||
req+='@KEYHANDLE-4@'
|
||||
# size of buffer
|
||||
req+='\x00\x00\x00\x09'
|
||||
# TPM_RS_PW
|
||||
@ -1019,10 +1041,9 @@ tpm2_createprimary_ek_ecc()
|
||||
# restricted, decrypt
|
||||
req+='@KEYFLAGS-4@'
|
||||
# authPolicy: size = 32 bytes
|
||||
req+='\x00\x20'
|
||||
req+='\x83\x71\x97\x67\x44\x84\xb3\xf8\x1a\x90\xcc\x8d'
|
||||
req+='\x46\xa5\xd7\x24\xfd\x52\xd7\x6e\x06\x52\x0b\x64'
|
||||
req+='\xf2\xa1\xda\x1b\x33\x14\x69\xaa'
|
||||
# authPolicy;32 bytes
|
||||
req+='@AUTHPOLICYLEN-2@'
|
||||
req+='@AUTHPOLICY@'
|
||||
req+='@SYMKEYDATA@'
|
||||
# scheme: TPM_ALG_NULL, curveID: TPM_ECC_NIST_P256
|
||||
req+='\x00\x10\x00\x03'
|
||||
@ -1038,7 +1059,10 @@ tpm2_createprimary_ek_ecc()
|
||||
sed -e "s/@KEYFLAGS-4@/$(_format "$keyflags" 4)/" \
|
||||
-e "s/@SYMKEYDATA@/$symkeydata/" \
|
||||
-e "s/@PUBLEN-2@/$(_format "$publen" 2)/" \
|
||||
-e "s/@TOTLEN-4@/$(_format "$totlen" 4)/")
|
||||
-e "s/@TOTLEN-4@/$(_format "$totlen" 4)/" \
|
||||
-e "s/@KEYHANDLE-4@/$primaryhandle/" \
|
||||
-e "s/@AUTHPOLICY@/$authpolicy/" \
|
||||
-e "s/@AUTHPOLICYLEN-2@/$(_format "$authpolicylen" 2)/")
|
||||
|
||||
rsp="$(tpm_transfer "${req}")"
|
||||
if [ ${#rsp} -lt $min_exp ]; then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user