top | item 44012691

(no title)

rastignack | 9 months ago

Is not rustls a mix of c++, assembly and rust ?

I think it’s not a good indication of the success of the language.

discuss

order

jaas|9 months ago

In Rustls, TLS is implemented entirely in Rust. It uses aws-lc-rs [1] for cryptography, and aws-lc-rs uses assembly for core cryptographic routines, which are wrapped in some C code, which then exposes a Rust API which Rustls uses.

It's not practical right now to write high performance cryptographic code in a secure way (e.g. without side channels) in anything other than assembly.

[1] https://github.com/aws/aws-lc-rs

robmor|9 months ago

Is that right?

From the AWS-LC README: https://github.com/aws/aws-lc

> A portable C implementation of all algorithms is included and optimized assembly implementations of select algorithms is included for some x86 and Arm CPUs.

It also states that it kind of forked BoringSSL and OpenSSL.

You’re right though that most of the memory safety attack surface has been replaced with Rust.

rastignack|9 months ago

In rust with some C code, ok. How is the DER format parsed for example ?

Regarding crypto operations, I know as of now for rust projects assembly is a must to have constant time guarantees.

Maybe there could be a way with intrinsics and a constant-time marker, similar to unsafe, to use pure rust.

In the meantime I think there still is too much C code.

It’s a great step in the good direction by the way.

PoignardAzur|9 months ago

I wonder if it would be possible to implement a safe_asm macro in Rust?

Even if unrestricted asm is inherently unsafe, there's got to be a subset of instructions and operand types you can guarantee is safe if called a certain way.