-
Notifications
You must be signed in to change notification settings - Fork 73
examples: tls client and server for new rustls #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
crates/rustls_provider/src/lib.rs
Outdated
| let millis = time.millis as u64; | ||
|
|
||
| // Create UnixTime from seconds and milliseconds | ||
| let total_millis = seconds * 1000 + millis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the Ree time can be manipulated, operations on it may overflow. Although the exact consequences are unclear, it would be safer to return None in such cases.
The original test certs expired at 2024 which causes "Cert Expired" error when testing tls server example.
When building tls_client and tls_server 32bit TAs, this error occurred: multiple definition of `__aeabi_fcmple' (`__aeabi_fcmpeq' and others) This means the __aeabi functions are defined both in Rustc compiler_builtins and optee libutils. Disable the CFG_TA_FLOAT_SUPPORT when building libutils is a easy approach without porting the compiler_builtins.
|
Reorganize the commits with all above comments resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements 🙌 Just a few minor comments that I think can still be addressed. All the rest LGTM.
|
LGTM. Thanks. |
This PR mainly updates the TLS client and TLS server examples to support Rustls 0.23.0+ (currently using
0.23.12).Upgrading Rustls and its dependencies will:
rustls,webpki, andring.Key Improvements in Rustls 0.23+
Rustls now supports:
This allows us to integrate directly with
optee-uteeAPIs without manually porting entire crates.After customizing the rng and time providers, Rustls can run in OP-TEE
stdTAs. (no-stdsupport is in future plan but not included here.)Crypto Provider
Available Rustls crypto providers: https://github.com/rustls/rustls?tab=readme-ov-file#cryptography-providers
Of course we can implement and maintain our own crypto provider for OP-TEE, but if there are existing providers available, it’s better to reuse them. We selected
ringandrustls-rustcryptoas our candidates.1.
ringproviderringfeature). (https://github.com/rustls/rustls/tree/main/rustls/src/crypto/ring)ring-provider-in-rustls→ring→getrandom.ring’sSystemRandomis not OP-TEE–compatible. (https://github.com/briansmith/ring/blob/main/src/rand.rs#L165)Would require changes to both
getrandomandring(orring-provider-in-rustls).2.
rustls-rustcryptoproviderrustls-rustcrypto→rand_core→getrandom.getrandommodifications. No changes to the provider code itself.Our decision is, port
getrandomto OP-TEE, then userustls-rustcryptoas the provider.Getrandom Porting
getrandomis a hardware RNG crate with multiple backends.rustls-rustcryptodepends ongetrandom 0.2(which is in maintenance mode), we maintain an OP-TEE-enabledgetrandominincubator-teaclave-crates(currently in my fork:git = "https://github.com/DemesneGH/incubator-teaclave-crates.git", I will open a PR and modify this url after it merged).getrandom 0.3.getrandomdepends onoptee-utee0.4.0, all other TLS TA modules also pinoptee-*crates to 0.4.0 to avoid build inconsistencies.Code Changes
tls_clientandtls_serverexamples using Rustls0.23.12. We chose this version because it is the one currently used byrustls-rustcrypto.rustls-providercrate undercrates/, used by TLS examples.CFG_TA_FLOAT_SUPPORT(see commit message for details).no-stdTLS examplesThey need the
no-stdRustls andno-stdcrypto backend. AFAIK:no-std(release notes), which requires further research for our usecase.rustcryptocrates already supportno-std.It is possible to have
no-stdTLS TAs, but this will require additional effort and investigation, so it remains a goal for future work.