# WiSecKey取得DAC ## 流程圖  1. call api https://inesapi.certifyiddemo.com/v2/auth 取得token (1). https://ines.certifyiddemo.com/admin/application 取得API Access Keys (2). 再利用app_cert.pem、app_key.pem,當作認證取得token 2. 使用得到的token進行其它操作 * API:Issue certificate (新增cert) * API:Get certificate details by ID(查找cert) 3. 透過API取得的資訊再經過pkcs12 解密即可取得Private Key Step example: (1) openssl base64 -A -in 20230926.txt -d -out pkcs12.bin (2) openssl pkcs12 -in pkcs12.bin -password pass:12345678 -nocerts -out privkey.pem -nodes (3) openssl ec -in privkey.pem -text 4. 得到資料,完成 5. 參考資料 * https://ines.certifyiddemo.com/ * https://inesdev.certifyiddemo.com/ # BL602 ## 概述 * Matter裝置加入Matter網路具DAC(Device Attestation Certificate)證書及私鑰,產生DAC則需要PAA(Product Attestation Authority)、PAI(Product Attestation Intermediate Certificate)等2把金鑰,由PAA產生PAI,再由PAI產生DAC。 * PAA存於DCL(the Distributed Compliance Ledger);PAI証書與DAC証書及私鑰存於Matter裝置中。  * 另外,Matter裝置在CSA(Connectivity Standards Alliance)認證通過後會發放CD(Certificate Declaration)證書,生產時存於Matter裝置內,藉以將CD上傳至DCL確認PAI為合法金鑰與否。 ## Matter裝置認証流程  * Device discovery 透過BLE、WiFi搜尋Matter裝置 * Connect to device (PASE) PASE(Passcode Authenticated Session Establishment ) 是基於SPAKE2+的簽章和金鑰交換,即發起Commissioning的設備(Commissioner)通過Passcode對Matter裝置(Commissionee)進行認証,基於該交握雙方完成認證和金鑰確認。 而Commissioner發現Commissionee後,即開始PASE的加密通道建立。 * Get Commissionee information 當建立上PASE加密通道,Commissioner 將從Commissionee 讀取一些基本訊息,例如Basic Information Cluster 中的VID、PID、產品名稱設備序號等。 * Regulatory config 同時,Commissioner 會對Commissionee 進行一些常規資訊配置,例如地點(室內、室外)或地區資訊。 * Commissionee attestation 之後Commissioner 會完成對Commissionee 的設備認證,該流程主要是驗證這是是否為合法的Matter裝置。主要步驟是從裝置取得Device Attestation Certificate (DAC) 和Product Attestation Intermediate (PAI) ,之後完成憑證鏈的驗證,即透過DCL 取得的根憑證完成PAI 憑證的驗證,然後透過PAI 完成DAC 憑證驗簽。然後使用DAC 中公鑰用以同裝置進行簽章/驗簽挑戰。當然過程中也會對VID 、PID 資訊就行驗證。 * Certificate Signing Request (CSR) 再後面Commissioner 會發送憑證簽章請求給Commissionee 讓其準備金鑰對,用以完成後續的NOC憑證簽發,這裡NOC即後續Fabric 內單播通訊Certificate Authenticated Session Establishment (CASE) 的重要憑證。 * Add Node Operational Certificate (NOC) Commissioner 一旦完成NOC憑證簽發會通過AddNOC進行安裝。 * Network provisioning 對於WiFi 設備或Thread 設備,這裡通過ScanNetworks,AddOrUpdateWifiNetwork 和ConnectNetwork 完成網路的存取。乙太網路設備(網路線)不需要該步驟。 * Operational discovery 一旦Commissionee 完成如上的網路設定和Commissioner 在同一個網路(區域網路/Thread 網路)。Commissioner 開始透過DNS-SD 開始尋找剛加入的Commissionee 裝置。這裡的發現主要就是發現IPv6 位址,一旦知道了IPv6 位址,就可以開始後續的CASE安全會話建立。 * CASE session establishment Commissioner 一旦發現了新設備,開始透過CASE 進行安全會話的建立,PASE 和CASE 安全機制類似,主要是透過如上步驟安裝的NOC憑證進行雙向認證,然後透過ECDH 協商會話金鑰。 * Commissioning complete 完成所有Commissioning 步驟。 ## 套用WiSecKey金鑰 ### 1. 從WiSecKey下載PAA\PAI\DAC ### 2. 修改程式碼 * 自有VID、PID 若已有特定的VID及PID的話,則修改"src/platform/bouffalolab/common/FactoryDataProvider.cpp"與"src/platform/bouffalolab/common/FactoryDataProvider.h" | 金鑰\證書 | 程式碼 | |:--------------- | -------------------------- | | PAI證書 | Pai_Cert_Array | | DAC證書 | Dac_Cert_Array | | DAC私鑰 | Dac_PrivateKey_Array | | CD | Chip_Test_CD_130D_f001_der | * 使用Matter測試VID 本次測試WiSecKey測試使用Matter測試用VID,所以修改的地方與自有VID及PID不同,分別於: src/credentials/examples/ExamplePAI.cpp | 金鑰\證書 | 程式碼 | | ------- | ------------------------------ | | PAI証書 | kDevelopmentPAI_Cert_FFF1 | | PAI公鑰 | kDevelopmentPAI_PublicKey_FFF1 | src/credentials/examples/ExampleDACs.cpp | 金鑰\證書 | 程式碼 | | ------- | ----------------------------------- | | DAC證書 | kDevelopmentDAC_Cert_FFF1_801F | | DAC公鑰 | kDevelopmentDAC_PublicKey_FFF1_801F | | DAC私鑰 | DevelopmentDAC_PrivateKey_FFF1_801F | * 使用Matter測試VID時,若是裝置認証須加入CD驗証加須再修改如下: src/credentials/examples/DeviceAttestationCredsExample.cpp | 金鑰 | 程式碼 | | ------ | ----------------- | | CD證書 | kCdForAllExamples | src/credentials/tests/CHIPAttCert_test_vectors.cpp | 金鑰 | 程式碼 | | ------- | ---------------------------------- | | PAA證書 | sTestCert_PAA_FFF1_Cert_Array | | PAA公鑰 | sTestCert_PAA_FFF1_PublicKey_Array | * 使用Matter測試VID時,若只驗DAC而不驗CD時,chip-tool須加入"--bypass-attestation-verifier true"跳過CD認証。 * 使用Matter測試VID時,由於裝置與chip-tool的CD和PAA程式碼會共用,所以要驗CD時,裝置與chip-tool都要編譯。 ## 自我練習 請參考[Create Matter device test certificates](https://developers.home.google.com/matter/test/certificates)作法,產生PAA \ PAI \ DAC \ CD。 ## 參考資料 * [Connectivity Standards Alliance Distributed Compliance Ledger and the IoT](https://csa-iot.org/wp-content/uploads/2022/09/DCL_Whitepaper.pdf) * [Working with the CHIP Tool](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/matter/chip_tool_guide.html) * [Attestation](https://developers.home.google.com/matter/primer/attestation) * [Matter Device Attestation](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/matter/end_product/attestation.html) * [Matter 系列之 Device Attestation](https://notes.leconiot.com/device_attestation.html) * [Commissioning](https://developers.home.google.com/matter/primer/commissioning) * [Matter 系列之 Commissioning](https://notes.leconiot.com/commissioning.html) * [Matter network commissioning](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/matter/overview/commissioning.html#ug-matter-network-topologies-commissioning) * [IP commissioning](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/ip_commissioning.md) * [CHIP Certificate Tool](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/matter/README.html) * [Create Matter device test certificates](https://developers.home.google.com/matter/test/certificates) * [Enable Matter in smart home solutions using EdgeLock SE05x/A5000](https://www.nxp.com/docs/en/application-note/AN13445.pdf) * [PEM, DER, CRT, and CER: X.509 Encodings and Conversions](https://www.ssl.com/guide/pem-der-crt-and-cer-x-509-encodings-and-conversions/) * [Base64 to Hex](https://base64.guru/converter/decode/hex)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.