eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 172 forks source link

EC keys: consolidate API for handling keys in TEE #2287

Closed cpetrov closed 4 months ago

cpetrov commented 5 months ago

The inTee option and the teeKeyHandle format provided a way to create keys in the TEE and export them as opaque handles. While this API made it transparent when a key is really stored in the TEE, it was not convenient in practice, as it required the application to conduct specific checks for hardware support on Android in order to decide whether to store the key in TEE or not.

This commit removes the inTee option. ECDSA and ECDH keys with extractable set to false are now generated in the TEE by the platform when the device supports it. When the device does not support it, the key is generated in software. In practice, this means that non-extractable EC* keys are always generated in TEE on iOS, and on Android only when the device supports it.

The "teeKeyHandle" format has also been removed. The exportKey method called for EC* keys with extractable set to false and the format "raw" now returns an opaque handle to the key in the TEE instead of throwing.