120 likes | 144 Views
SEC Configuration Tool. Tianyu Qi. Packages Needed. Python (2.7) with hashlib tpm2-tss cmake And packages those above depend on. Components. SEC-configure.py Python script file, the front-end of the tool.
E N D
SEC Configuration Tool Tianyu Qi
Packages Needed • Python (2.7) with hashlib • tpm2-tss • cmake • And packages those above depend on.
Components • SEC-configure.py Python script file, the front-end of the tool. • SEC-worker Compiled and linked executable file written by C, the back-end of the tool • README.md Manual of the tool
Command Description • python SEC-configure -P <Passphrase> -S <AuthValue-of-Sealing-Key> -G <Hash-Algorithm> -B <component 1>,<component2> … -O* <AuthValue-of-object> -H <Handle-of-Sealing-Key> -R <Directory-of-config-file> -D <Directory-of-SABLE> • Require administrator authorization in Windows and sudo in Linux.
Command Description (Cont.) • Parameters: • -P: SECsecret • -S: Password of sealing key (used in TPM2_Load) • -G: Hash algorithm (SHA1 or SHA256, use SHA256 if not specified) • -B: Directory/of/boot/modules (separated by “,”) • -O: Password of sealed object (used in TPM2_Unseal, optional, use value of “-S” if not specified) • -H: Handle of the persist object. • -R: Directory/to/save/this/configuration/file (save to current directory if not specified) • -D: Directory/of/SABLE
Assumptions SEC configuration tool should work based on following assumptions: • User has installed tpm2-tss. tpm2-tss libraries are in /usr/local/lib. User can provide the handle and the name of sealing key object. • User will use same hash algorithm in configuration tool and sable. • SEC-configure.py and SEC-worker are in the same directory • SABLE will hash the same boot modules in the same order with what user hashed in configuration. This is guaranteed by user who need to modify 40_custom in /etc/grub.d correctly. Details about modify grub is described in manual of sable.
Procedure • Check if proper authority is granted, if tpm2-tss library is accessible, if SEC-worker is in current directory, and if sable-AMD, as well as given boot modules, are accessible by using aforementioned parameters. (Output error message if either one condition is not satisfied, then terminate) • Parse the received parameters, hash sable, get the result digest for PCR17; then hash boot modules, get result digest for PCR19. (No error should be thrown in this step, because all parameters are valid after step 1) • Invoke SEC-worker. (From this step, all works are done in background)
Procedure (Cont.) • SEC-worker will accept and parse following parameters from SEC-configure.py: • -H: parentHandle (handle of persist object) • -P: parentAuth (auth value of persist object) • -S: digest of Seventeenth PCR (PCR17) • -N: digest of Nineteenth PCR (PCR19) • -p: objectAuth (auth value of SEC object) • -t: objectSecret (SEC secret) • SEC-worker initialize tcti (use tcti device), enhanced system api (one kind of tpm2 command api provided by tpm2-tss)
Procedure (Cont.) • SEC-worker invoke following commands in order: • TPM2_StartAuthSession, start a trial session Strial • TPM2_PolicyPCR(Strial,digestPCR17) • TPM2_PolicyPCR(Strial,digestPCR19) • TPM2_PolicyLocality(Strial,LOC_TWO) • TPM2_GetPolicy(Strial), get the policy digest digestpolicy • TPM2_Create, get private portion and public portion of created object • SEC-worker write parent handle (sealing key object name), parent name (sealing key object name), private portion, public portion, digest read from PCR17 and digest read from PCR19 into SEC-config.dat, and save it to the specified directory.
Format of SEC-config.dat • The file is written in key-value pairs. With hash digests written in ASCII characters. • For each record, key and value are separated with “:”, and each record ends with a “\n” (including the last record). • Keys are: “handle”, “private”, “public”, “name”, “PCR17”, “PCR19” (without quotes). • No sequential order requirements for records. • E.g: handle:<handle>\nprivate:<private>\npublic:<public>\nname<name>\n
Parsing config on SABLE side • SABLE will use parseConfig package to extract configuration from SEC-config.dat • struct configContext will hold config data, include parentHandle, private, privateSize, public, publicSize, name, nameSize. • In post launch stage, after tis_init(), sable will get config file from boot modules (should be the last one). Invoke parseConfig() to parse configuration file. • If sable fails to get any of those configs, an exception will be thrown.