Ticket #6461 (closed enhancement: fixed)

Opened 14 months ago

Last modified 13 months ago

[with patch, positive review] Schaefer's Simplified Data Encryption Standard for educational purposes

Reported by: mvngu Owned by: somebody
Priority: major Milestone: sage-4.1.2
Component: cryptography Keywords: cryptography, DES, S-DES
Cc: malb Author(s): Minh Van Nguyen
Report Upstream: Reviewer(s): Martin Albrecht, William Stein
Merged in: Sage 4.1.2.alpha0 Work issues:

Description

This is a follow-up to #6164. The goal here is to implement the S-DES block cipher of Schaefer as described in the paper:

  1. Schaefer. A simplified data encryption algorithm. Cryptologia, 20(1):77--84, 1996.

This is a simplified variant of the Data Encryption Standard (DES) to be used for cryptography education.

Attachments

trac_6461-sdes.patch Download (58.6 KB) - added by mvngu 13 months ago.
based on Sage 4.1.1.alpha0

Change History

  Changed 14 months ago by mvngu

  • milestone set to sage-4.1
  • summary changed from Schaefer's Simplified Data Encryption Standard for educational purposes to [with patch, needs review] Schaefer's Simplified Data Encryption Standard for educational purposes
  • author set to Minh Van Nguyen

follow-ups: ↓ 3 ↓ 5   Changed 14 months ago by malb

  • summary changed from [with patch, needs review] Schaefer's Simplified Data Encryption Standard for educational purposes to [with patch, needs work] Schaefer's Simplified Data Encryption Standard for educational purposes

Review:

  • I assume that the specification implemented is correct, I didn't check against the paper, are there official test vectors?
  • The code looks good and is nicely documented (coverage: 100%)
  • __cmp__ expects you to return an integer (-1,0,1) and not True or False, cf.  http://docs.python.org/reference/datamodel.html
  • it is a bit confusing that P is often the plaintext (cf. C for ciphertext) and the permutation, but that might be a problem in the paper
  • it would be nice to have an sbox(n) function to return the S-Boxes 0 and 1
  • patch applies cleanly against 4.1.
  • reference manual builds without warnings and the result looks okay.
  • doctests pass on sage.math

Bottomline: positive review except some nitpicks.

in reply to: ↑ 2   Changed 14 months ago by mvngu

Replying to malb:

* I assume that the specification implemented is correct, I didn't check against the paper, are there official test vectors?

Unfortunately, I don't have access to the original paper by Schaefer, and neither do my institution. I relied on the note at

 http://bitterroot.vancouver.wsu.edu/cs427_Spring09/docs/sdes.pdf


* __cmp__ expects you to return an integer (-1,0,1) and not True or False, cf.  http://docs.python.org/reference/datamodel.html

Before switching to using __cmp__(), I used == for comparing objects. But then doing a == loads(dumps(a)) consistently returned False for me. Let me try it again.


* it is a bit confusing that P is often the plaintext (cf. C for ciphertext) and the permutation, but that might be a problem in the paper

Ah... the notes I referenced above uses IP to denote the initial permutation and IP^-1 for its inverse. Perhaps that is less confusing you think?


* it would be nice to have an sbox(n) function to return the S-Boxes 0 and 1

That can be done.

  Changed 14 months ago by malb

Changed 13 months ago by mvngu

based on Sage 4.1.1.alpha0

in reply to: ↑ 2   Changed 13 months ago by mvngu

  • summary changed from [with patch, needs work] Schaefer's Simplified Data Encryption Standard for educational purposes to [with patch, needs review] Schaefer's Simplified Data Encryption Standard for educational purposes

Replying to malb:

* I assume that the specification implemented is correct, I didn't check against the paper, are there official test vectors?

There are no official test vectors for simplified DES. Even the original paper by Schaefer doesn't contain any such vectors.

* __cmp__ expects you to return an integer (-1,0,1) and not True or False, cf.  http://docs.python.org/reference/datamodel.html

The latest patch trac_6461-sdes.patch now uses __eq__(). I have also modified the class MiniAES in sage/crypto/block_cipher/miniaes.py so it now also uses __eq__().

* it would be nice to have an sbox(n) function to return the S-Boxes 0 and 1

Done.

  Changed 13 months ago by was

  • summary changed from [with patch, needs review] Schaefer's Simplified Data Encryption Standard for educational purposes to [with patch, positive review] Schaefer's Simplified Data Encryption Standard for educational purposes

Looks good to me, and Martin says it's ok if it fixes the nitpicks, which I think it does.

  Changed 13 months ago by mvngu

  • status changed from new to closed
  • reviewer set to Martin Albrecht, William Stein
  • resolution set to fixed
  • merged set to Sage 4.1.2.alpha0
Note: See TracTickets for help on using tickets.