Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know of any sites where intermediate values of multiple crypto algorithms (not just the famous ones), including hashes, can be found? I don't just mean intermediate values of encrypting. I'm also looking for intermediate values of the key generation algorithms as well. Hopefully, the initial values can be changed, or at least are not just strings of 0's, since many algorithms use little endian notation, which doesn't appear in strings of 0's.

The previous sentence means:

The mars cipher works with little endian values. In ibms's test vectors, the values are 0000000000000.... so when I input my key into mars, I get {0,0,0,...,0}. Fine.

Now if the test vector were 1234..., now what happens? If there are intermediate values for the key/encrypt/decrypt algorithms, I would know if the test vector were already in little endian, or if I have to change it to ... 34 12?

share|improve this question
up vote 4 down vote accepted

Normally, test vectors, in particular test vectors for intermediate values, are to be found with whatever is the "official specification" for that algorithm. MARS has not been blessed with a standard (few algorithms are), so the "official specification" is what IBM distributes, in particular the MARS package (compressed archive).

This package contains the specification itself as a PDF file (in MARS/Algorithm/mars.pdf), sample implementations, and test vectors (in the MARS/Test_Values/ directory). In particular, have a look at the ecb_ivt.txt file, which contains some "intermediate values".

As a more generic rule, when faced with low-quality or inexistent test vectors ("low-quality" meaning, e.g., that there are some hexadecimal bytes but without clear endianness rules), the usual method is to find a "reference implementation" and sprinkle printf() statements throught its code, so as to get the intermediate values. I recommend using the Java code, which, in practice, will run you into much less trouble than any C code (that's the benefit of the strictness of the Java platform).

The NESSIE project was a big effort at analyzing many cryptographic algorithms, and it produced a large amount of test vectors for all those algorithms. This is a good source (but MARS was not submitted as "NESSIE candidate" so no luck there, in the case of MARS).

If all else fails, you can always send an email to the function author. Most function authors are researchers who will gladly help you out.

On the question of endianness, in particular in C, I strongly recommend against trying to play games with the memory representation, such as using a union between a sequence of bytes and an integer type. Such games limit portability and, more importantly, tend to break in awful ways in the presence of an optimizing compiler (because of strict type aliasing analysis). Instead, use generic encoding and decoding "functions", which you can later on optimize with inline functions and macros, and possibly inline assembly, if you detect a machine and compiler on which you know a smarter and cheaper implementation is possible. As an illustration, have a look at sphlib, which is a library implementing many hash functions in C and Java. In the C code, all the endianness "smartness" is concentrated in the sph_types.h file, which defines uniform names for the integer types and encoding/decoding functions (e.g. sph_dec32be() for 32-bit big-endian decoding).

share|improve this answer
thanks for the suggestions. i thought that my mars encrypt/decrypt implementation was correct, but because there was no intermediate key expansion example (only generated subkeys, which i somehow couldnt manage to get), i could not figure out where i programmed the key expansion code wrong. – calccrypto Jul 15 '11 at 16:30
i just looked through some of NESSIE's stuff, and it seems that the website hasnt been updated in quite some time. some of the links to test vectors are broken :( – calccrypto Jul 15 '11 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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