Devessier / ssl

Clone of openssl in C for 42 School
GNU General Public License v3.0
0 stars 0 forks source link

Implement DES commands #25

Open Devessier opened 3 years ago

Devessier commented 3 years ago

Implementing DES command necessitates to implement two different mechanisms first:

PBKDF

To have a working PBKDF, we need:

The steps to follow are:

  1. We get the password from stdin/argument (need a confirmation)
  2. We generate a salt using /dev/random
  3. We create HMAC SHA-256 algorithm, using SHA-256
  4. We implement PBKDF2 algorithm, using Salt, Password and HMAC SHA-256

To debug and test more easily, we will probably have to add a digest command HMAC SHA-256 and a parameter -debug to print IV and Key.

PBKDF RFC can be found there: https://tools.ietf.org/html/rfc8018#section-5.2. HMAC RFC can be found there: https://www.ietf.org/rfc/rfc2104.txt.

To use a better version of openssl, we had to follow those instructions: https://stackoverflow.com/questions/61938795/openssl-pbkdf2-option-no-longer-supported.

DES-ECB

The first DES version to implement is DES-ECB. We can find an algorithm definition there: https://csrc.nist.gov/csrc/media/publications/fips/46/3/archive/1999-10-25/documents/fips46-3.pdf. We can find an example implementation there: https://www.geeksforgeeks.org/data-encryption-standard-des-set-1/.

We will have to implement other block cipher modes of operation so we should structure carefully our code.

DES-CBC

We have to use another block cipher mode of operation, as described above.

Devessier commented 3 years ago

Quand on passe un sel et une clef à OpenSSL, mais pas de mdp, il n'y a pas de sel écrit sur la sortie standard. Essayer:

cat auteur | openssl enc -des-ecb -md sha256 -pbkdf2 -iter 10000 -K AABB09182736CCDD -S AABB09182736CCDD