Re:A cryptographically secure bootloader for RISC-V in Rust
by ladyanita22 on Monday August 05, 2024 @10:56AM
(#41161956)
20% overhead doesn't look small at all for a language that's supposedly zero-overhead.
[ Parent
| on HN ]
Re:A cryptographically secure bootloader for RISC-V in Rust
by eviks on Monday August 05, 2024 @11:06AM
(#41162041)
It's zero overhead for zero extra functionality, here it seems they've added some
> Additionally, SentinelBoot employs public-key cryptography to verify the integrity of a booted kernel (digital signature), by the use of the RISC-V Vector Cryptography extension, establishing secure boot functionality.
Re:A cryptographically secure bootloader for RISC-V in Rust
by ladyanita22 on Monday August 05, 2024 @11:08AM
(#41162070)
Fair enough
Re:A cryptographically secure bootloader for RISC-V in Rust
by winter_blue on Monday August 05, 2024 @11:53AM
(#41162479)
The overhead is for doing computation (fr cryptographic hashing). No language has zero cost computation. Rust advertises what’s called zero-cost abstractions; which is a major improvement over many languages where abstractions can be expensive.
Re:A cryptographically secure bootloader for RISC-V in Rust
by ladyanita22 on Monday August 05, 2024 @12:40PM
(#41162932)
I thought the C version (U boot) did that as well. I guess it does not.
Re:A cryptographically secure bootloader for RISC-V in Rust
by f_devd on Monday August 05, 2024 @11:13AM
(#41162113)
I don't think the rust team would claim writing idiomatic safe rust code is always zero-overhead. Indexing into an array adds bounds checks which takes non-zero time. So by default you trade-off safety for performance to some degree; but this can be bypassed if needed, that's why you have unsafe.
For completeness, it's 0.1x the size with 1.20x the runtime, so these are not just language differences
Re:A cryptographically secure bootloader for RISC-V in Rust
by RsmFz on Monday August 05, 2024 @12:07PM
(#41162612)
I think the phrase is "zero-cost abstractions", meaning "Supposing you want bounds checks, you may as well use ours and not roll your own"
Re:A cryptographically secure bootloader for RISC-V in Rust
by ladyanita22 on Monday August 05, 2024 @12:39PM
(#41162922)
It's true that you can escape them though. There are some other small things (which AFAICT you can escape from to as well)
Re:A cryptographically secure bootloader for RISC-V in Rust
by estebank on Monday August 05, 2024 @02:15PM
(#41163834)
> Indexing into an array adds bounds checks which takes non-zero time.
* When done in such a way that the compiler cannot know the access is in-bounds. The same code in C would also need to perform bounds checks on access. If you do the same assertion you would in C checking that the indices are always less than the length, then Rust will not perform the bounds check because it detects it's unnecessary. Leveraging iterators is one idiomatic way of avoiding those bounds checks.