diverta / onecard-fido

MIT License
0 stars 0 forks source link

[nCS更改対応] 暗号化関連の初期化処理を直列化する #774

Closed makmorit closed 1 year ago

makmorit commented 1 year ago

概要

nRF5340アプリケーションでは、暗号化関連の初期化処理を、別スレッドで実行させている部分[注1]が存在します。 この仕組みのため、永続化機能(Flash ROMにデータを保存する機能)の初期化がスキップされ、結果としてデータ保存処理がダウンしてしまう不具合が確認されています。

この不具合を解消するため、別スレッドで実行されている部分が完了してから、永続化機能初期化を含む次の処理ステップに進むようにする(=直列化する)よう、プログラムロジックを修正したいと思います。

[注1] ランダムベクターを生成する前処理としての、ランダムシードを生成する処理。具体的にはmbedtls_ctr_drbg_seedという関数が実行されます。ランダムベクターは、FIDO機能で共通鍵を生成する際に使用する乱数バイト配列です。

makmorit commented 1 year ago

対応結果の確認

1613c08 までの対応の結果、nRF5340アプリケーションにおける暗号化関連の初期化処理が直列化された事を確認いたしました。 また、#741 にて確認されたFlash ROM保存時の障害も発生しなくなった事を、合わせて確認いたしました。

ご参考

nRF5340アプリケーションの初期化処理時のログ出力を以下に掲載いたします。

【USBポート装着時】

*** Booting Zephyr OS build v3.2.99-ncs1 ***
[00:00:00.011,596] <inf> app_tiny_tft: SPI master #4 is ready
[00:00:00.011,627] <inf> app_tiny_tft: Tiny TFT device is ready
[00:00:00.011,627] <inf> app_usb_hid: Get USB HID device success
[00:00:00.011,901] <inf> app_usb: USB initialized
[00:00:00.012,908] <inf> usb_hid: Device connected
[00:00:00.016,021] <inf> usb_hid: Device suspended
[00:00:00.027,801] <inf> app_rtcc: RTCC device is ready (with default settings)
[00:00:00.029,602] <inf> app_crypto: Mbed TLS random seed initialized
[00:00:00.047,058] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.047,058] <inf> app_bluetooth: Bluetooth initialized
[00:00:00.047,088] <inf> app_bluetooth: Passkey for BLE pairing: 199881
[00:00:00.047,149] <inf> app_settings: Buffer size for reading data from storage: 1024 bytes
[00:00:00.114,135] <inf> usb_hid: Device resumed
[00:00:00.114,166] <inf> usb_hid: from suspend
[00:00:00.114,196] <inf> usb_hid: Device reset detected
[00:00:00.189,971] <inf> usb_hid: Device configured
[00:00:00.547,424] <inf> app_crypto_util: Random vector pre-generate success
[00:00:00.683,715] <inf> rtcc: RTCC is available. Current timestamp: 2023/04/10 17:33:05
[00:00:00.683,746] <inf> app_func: Secure device application (PCA10095_01) version 0.4.8 (104)

【USBポート非装着時】

*** Booting Zephyr OS build v3.2.99-ncs1 ***
[00:00:00.011,566] <inf> app_tiny_tft: SPI master #4 is ready
[00:00:00.011,596] <inf> app_tiny_tft: Tiny TFT device is ready
[00:00:00.011,596] <inf> app_usb_hid: Get USB HID device success
[00:00:00.011,810] <inf> app_usb: USB initialized
[00:00:00.027,709] <inf> app_rtcc: RTCC device is ready (with default settings)
[00:00:00.029,479] <inf> app_crypto: Mbed TLS random seed initialized
[00:00:00.046,936] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.046,966] <inf> app_bluetooth: Bluetooth initialized
[00:00:00.046,966] <inf> app_bluetooth: Passkey for BLE pairing: 199881
[00:00:00.047,058] <inf> app_settings: Buffer size for reading data from storage: 1024 bytes
[00:00:00.549,285] <inf> app_bluetooth: Advertising successfully started (Non-Pairing mode)
[00:00:00.549,591] <inf> app_crypto_util: Random vector pre-generate success
[00:00:00.684,417] <inf> rtcc: RTCC is available. Current timestamp: 2023/04/10 17:32:52
[00:00:00.684,478] <inf> app_func: Secure device application (PCA10095_01) version 0.4.8 (104)