#rsa #security #encryption #crypto

no-std rsa_heapless

Pure Rust RSA implementation - heapless version

1 unstable release

0.1.0 Oct 6, 2024

#62 in #rsa

Download history 103/week @ 2024-09-30 57/week @ 2024-10-07 6/week @ 2024-10-14

166 downloads per month

MIT/Apache

125KB
3K SLoC

RustCrypto: RSA (No-Heap Fork)

This repo is a fork of the RustCrypto RSA crate

What's Different?

This fork is a proof of concept focused on removing heap usage and allocations. It's written for environments where memory constraints are tight, such as embedded systems or no_std contexts.

Key Features

  • No heap allocations: All operations run entirely on the stack.
  • Public Key Functions: Only public key operations like signature verification and encryption are implemented so far.
  • Pluggable BigInt: The BigInt implementation is swappable. It’s a type parameter in the RsaPublicKey<T>, where T must implement num_traits::PrimInt and some additional traits.

What's Missing?

  • Private Key Operations: Private key functions (like signing and decryption) are stubbed out.
  • A lot of tests: Most of the tests from original are stubbed out, as they rely on PEM key decoding functions that need heap.
  • No expectation of security: Only signature verification is probably okay to use.

Why This Fork?

It's a proof of concept to try how compact a RSA implementation can become. Currently tested on Cortex-M0, fitting into about 8Kb code space and requiring about 3kB stack at the minimum.

Dependencies

~2MB
~42K SLoC