There Is Beauty in Cybersecurity: Bare Bones RSA in Rust

--

I really love creating code in Rust, but while there are lots of libraries around to integrate, there’s a real lack of practical examples of code. Personally, I have never been a believer in learning from generic code, such as ordering an online pizza, and much prefer to use real-life (and interesting) code. So, let’s dive in, and implement one of the most beautiful (and important) things in Cybersecurity: the RSA method.

The method

The RSA method is a thing of beauty. It has a public key and a private key, and where we can encrypt with one of these keys, and decrypt with the other one. In practice, we use often use it to prove identity, create digital signatures, and in encrypting data.

Last year, we were so lucky when Len Adleman - the ‘A’ in RSA method — outlined some of the history around its creation:

With RSA, we first generate two random prime numbers (p and q) and then produce a modulus of:

n=pq

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.