12
$\begingroup$

Being very new to C++ and cryptography, I finally managed to implement a version of the Vinegere algorithm. I would like to try something a bit more complicated. I have looked at AES and DES and others like them, but I was wondering if there is something simpler. Something that might use some of the same basic ideas as AES, but is much simpler. Some kind of block cipher maybe?

So I am asking for suggestions for a block cipher that is much simpler than AES, but more complex than a basic substitution algorithm. I have by the way looked into the method used in the Enigma-machines, but from what I understand they do "basically" the same as Vigenere.

$\endgroup$
9
  • 6
    $\begingroup$ Try TEA. It is simple, secure (except for related-key attacks, and limits inherent to its 64-bit block size), and acceptably fast for many uses. $\endgroup$
    – fgrieu
    Commented Jun 3, 2012 at 19:15
  • 4
    $\begingroup$ If it doesn't have to be a block cipher, RC4 would be a good one to look at. $\endgroup$
    – mikeazo
    Commented Jun 3, 2012 at 19:19
  • 2
    $\begingroup$ @fgrieu I'd recommend XTEA, it is as simple as TEA but, as far as we know, more secure. $\endgroup$ Commented Jun 4, 2012 at 15:01
  • $\begingroup$ @ChrisSmith: Why would XTEA be more secure than TEA? Except for related-key attacks and the fact that each key trivially has 3 other equivalent keys, reducing TEA's key space to 126 bits, I know no weakness of TEA. On the other hand, a casual reading of Meet-in-the-Middle Attacks on Reduced-Round XTEA seems to indicate that XTEA has less security margin than TEA in both the single-key and related-key settings. Not all revisions/extensions are improvements, and I feel TEA is more time-tested than XTEA is. $\endgroup$
    – fgrieu
    Commented Jun 4, 2012 at 19:40
  • $\begingroup$ @fgrieu thanks for the suggestion. This looks like exactly what I want. I have been reading in a book about the Feistel structure, the TEA looks like that. So that is probably a good place to start. $\endgroup$
    – Thomas
    Commented Jun 4, 2012 at 23:15

5 Answers 5

7
$\begingroup$

A simple block cipher would be Threefish (p. 11-13). It's a bit more complicated than RC4 or RC5 yet doesn't drive you insane with seemingly random design choices. It is presumably secure and was designed by experts but has not yet been reviewed extensively, so it shouldn't be used in sensitive applications yet (consider it an exercise).

You'll be able to implement the key schedule and the encryption/decryption functions, and if you use the PDF I linked above, it will be an excellent exercise in following a specification.

If anything, it's the technical details surrounding the implementations that can take you forever to fix, such as endianness concerns in particular (this isn't too much of a hassle for block ciphers but it did get in my way a few times when implementing hash functions).

PS: same name lol

$\endgroup$
6
  • 2
    $\begingroup$ I'm curious as to what you meant when you said "it is a priori secure." $\endgroup$
    – mikeazo
    Commented Jun 7, 2012 at 11:23
  • 1
    $\begingroup$ @mikeazo I meant that it's been designed by cryptography experts and has undergone some analysis. So we can expect it to be secure, however it would be wise to wait until the algorithm has undergone more extensive peer review (better be safe than sorry). Perhaps I should edit my answer to reflect that. $\endgroup$
    – Thomas
    Commented Jun 7, 2012 at 11:47
  • 1
    $\begingroup$ Probably the only "a priori secure" function we have is a OTP. $\endgroup$ Commented Jul 3, 2012 at 16:36
  • 1
    $\begingroup$ Bad choice of terms, I agree. I don't know why I wrote that. Make that "presumably". $\endgroup$
    – Thomas
    Commented Jul 3, 2012 at 17:13
  • 1
    $\begingroup$ I found threefish easy enough to implement directly from the specification. It's fun to do, and you can compare with the reference implementation afterwards. The only tricky part (where the designers themselves went wrong) is taking care of the little endianness of the various values (up to 128 bit going the wrong way). $\endgroup$
    – Maarten Bodewes
    Commented Oct 29, 2013 at 1:12
7
+50
$\begingroup$

As Thomas mentions, Threefish (especially Threefish-256) is reasonably straightforward to implement and has an excellent specification (and if you grab the Skein 1.3 SHA-3 submission, comprehensive test vectors with intermediate states to help debug the implementation as you go).

One of the Speck family of block ciphers (published by the NSA in The SIMON and SPECK Families of Lightweight Block Ciphers) would also be a good starting point - they're similar to Threefish in design approach, but simpler to implement, and the specification is well written (with good diagrams and pseudocode). Obviously given the newness of Speck, and its provenance I'd strongly suggest these are implemented as an exercise only.

There are a bunch of Speck variants (differing in block size and key size), so I'd recommend to pick one of the smaller ones to start with. Test vectors are a little light, and the spec is ambiguous about byte sequencing in input/output blocks, but you can use my Java implementation to test against or generate intermediate states to help debug.

$\endgroup$
6
$\begingroup$

There is a stream cipher called the Solitaire Cipher that is designed to be implemented by a human using only a deck of playing cards. It is very simple to memorize, use, and implement in code.

$\endgroup$
1
  • $\begingroup$ But AFAIK even weaker than RC4. $\endgroup$ Commented Jan 15, 2016 at 19:10
6
$\begingroup$

I think that a stream cipher would be the natural progression from a Vinegère, (before moving onto a block cypher).

ARC4 (also known as ArcFour, or RC4) would be my choice and there are good argument for that made by Arnold Reinhold over on http://ciphersaber.gurus.org/

$\endgroup$
1
  • $\begingroup$ RC4 indeed. There's even a rumor that it's designed for soldiers to remember by head and implement whenever given a PC and directly use it to encrypt/decrypt messages. $\endgroup$ Commented Oct 21, 2014 at 21:00
2
$\begingroup$

If one looks for smallest code, Tweetcipher might be interesting. There have been no third-party cryptanalysis, but it looks (for me) secure enough for exercise purpose.

$\endgroup$
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.