Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RSA in Ruby for begginers

Matheus
November 09, 2018

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
Tweet

More Decks by Matheus

Other Decks in Programming

Transcript

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

    Developer Working with Ruby since 2012
  2. 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;
  3. 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
  4. 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
  5. Padding scheme "Hello" 72, 101, 108, 108, 111 1622, 52,

    1504, 1504, 411 1622, 0052, 1504, 1504, 0411 16220052150415040411
  6. 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