MTK for Google AttestationKey介绍
參考:
1、googole文檔:《Keymaster2—Attestation Key Provisioning》
2、MTK文檔:《AttestationKeyToolUserGuide_3.0.pdf》
AttestationKey用途:
Keymaster2 extends the capabilities of hardware-backed key storage on Android devices. One
of the features is key attestation, allows Android apps and off-device entities to determine if the
keys are hardware backed.
For devices that have Google Mobile services, Google will provide the the keys to partners to
download from the Android Partner Front End (APFE)
(1)、可以判斷device是否支持硬件keymaster;
(2)、Google合作伙伴可以從APTEE中下載使用;
拋開問題看本質,什么是google attestationkey?
attestationkey就根據當前手機型號(id),相關google申請的一組keybox,然后將keybox拆分成若干組key, 每組包含ECDSA和RSA,每組key寫入到手機的安全內存中.
當google GSM app或第三方APP需要使用時,調用keymaster接口,使用該key進行簽名認證等
MTK的設計:
那么我們申請到keybox,要拆分keybox,然后將key組(ECDSA和RSA)寫入到手機的安全區域中。這其中的設計思想就是,我們要怎樣保護key組(ECDSA和RSA)的安全性?
以下是MTK的設計
詳細的代碼在:aosp/trusty/vendor/mediatek/proprietary/source/trusty-app/kmsetkey
集成/客制化/調試:
1、使用腳本,生成Kkb、Pkb、Kkb_pub、Kkb_priv四個文件:
#!/bin/bashfunction format_file() {local filename=$1local tmp="temp"mv $filename $tmplen=$(ls -l $tmp | awk '{print $5}')let len-=1dd if=$tmp of=$filename bs=1 count=$lenrm $tmp }openssl genrsa -out Kkb_pri.pem 2048 openssl rsa -inform PEM -in Kkb_pri.pem -outform DER -out Kkb_pri openssl rsa -text -in Kkb_pri.pem -pubout | head -n 20 | tail -n18 > tempfile rm Kkb_pri.pemfor (( i=0;i<10;i++ )) dosed 's/ //' -i tempfile donedd if=tempfile of=Kkb_pub skip=3 bs=1 && rm tempfile format_file Kkb_pubopenssl rand -hex 32 > Kkb format_file Kkbecho "00" > tempfile format_file tempfileopenssl rand -hex 128 > tempfile2 format_file tempfile2cat tempfile tempfile2 > Pkbrm tempfile tempfile22、使用Splitter2.6(Splitter)工具,拆分keybox
輸入申請到的keybox xml文件,如:
2017-11-22_06-11-44.643_UTC.attest_keyboxes.1511331105487.output
輸出:keybox_0000000000.bin — keybox_0000000009.bin
3、使用Splitter2.6(Mix Composer)工具,加密googlekey
輸入:keybox_0000000000.bin
輸出:kb_0000000000.bin (寫到手機的安全區域的就是這個文件)
4、使用keytool(EncSW)工具,使用Pkb將Kkb_pub加密成EKkb_pub, 并將Pkb\EKkb_pub數組寫入到代碼中:
加密后,生成要給array.c數組,里面包含Pkb和EKkb_pub
5、寫入kb_0000000000.bin文件到手機安全區域:
(1)、可以使用CA命令:
kmsetkey_ca -i data/vendor_de/kb_0000000000.bin
(寫入成功的log)
<6>[ 127.502402] -(0)[210:teei_switch_thr][TZ_LOG] uTSecMan| ta verification is def-disabled <6>[ 127.503482] -(0)[210:teei_switch_thr][TZ_LOG] uTSecMan| <6>[ 127.504200] -(0)[210:teei_switch_thr][TZ_LOG] SST_S | rpmb cap alloc success <6>[ 127.505152] -(0)[210:teei_switch_thr][TZ_LOG] SST_S | vfs cap alloc success <6>[ 127.506090] -(0)[210:teei_switch_thr][TZ_LOG] kmsetkey| google keybox rpmb solution, VERSION:1.0 <6>[ 127.509383] -(0)[210:teei_switch_thr][TZ_LOG] kmsetkey| ~~~~~~ kb_store enter ~~~~~~ <6>[ 127.532984] -(0)[210:teei_switch_thr][TZ_LOG] kmsetkey| =====keybox verify success=====(2)、可以使用MTK提供的工具:
SP_META
總結
以上是生活随笔為你收集整理的MTK for Google AttestationKey介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [crypto]-90-crypto的一
- 下一篇: MTK:oemlock介绍