Matheus
November 09, 2018
70

# RSA in Ruby for begginers

I gave this talk to people on XING Porto.

It talks about how RSA works and give some examples in plain Ruby.

## Matheus

November 09, 2018

## Transcript

3. ### About me XING # ProBusiness team (aka Spiderman Team) Backend

Developer Working with Ruby since 2012
4. ### Introduction Rivest, Shamir, and Adleman Public/private encryption algorithm Widely used

in the market
5. ### In order to understand how it works, let’s imagine something:

Alice and Bob want to.... How it works

9. ### Generating keys - p, q Must follow some rules: !

be different from each other; ! be random integers; ! be similar in magnitude; ! be prime; ! be very large. 2048 digits to be considered safe;

13. ### Carmichael’s totient function => lcm(p — 1, q — 1) Older specifications: (p — 1) *

(q — 1) Generating keys - totient

20. ### Padding scheme RSA implementations usually implements a structured padding before

encrypting A great padding scheme ensures that a message doesn’t turn into a predictable message structure PKCS#1, RSA-PSS
21. ### Padding scheme Simple padding scheme based on the string size

and bytes a % b is never higher than b every encrypted char must have the same size, if not, fill it with zeros
22. ### Padding scheme "Hello" 72, 101, 108, 108, 111 1622, 52,

1504, 1504, 411 1622, 0052, 1504, 1504, 0411 16220052150415040411

25. ### Downsides Choosing small values for p and q make the

algorithm faster, but it can be easily broken down RSA has a deterministic nature Padding schemes can be fragile