How do I choose the best 3*3 s-boxes?

I've read about 20 papers about the criteria for choosing best $n \times n$ s-boxes.

Now, I've got two problems:

1. How to generate $2^{24}$ s-boxes, and
2. how to test them considering the criteria.

Any help is appreciated.

-
Welcome to Cryptography Stack Exchange. The second part "how to test" depends greatly from your criteria. Could you add some examples to your question? – Paŭlo Ebermann Jul 14 '13 at 18:27
for example differential uniformity or differential spectrum – Saeidmscs Jul 14 '13 at 21:22

If you are looking specifically for $3 \times 3$ S-boxes, you might want to take a look at the printCipher specification since it uses one. You can trust the people who chose it to have picked the best one.

If you still want to go for the generation, keep in mind that many S-boxes have identical cryptographic properties (differential uniformity/spectrum, non-linearity, walsh spectrum, etc): they are so-called CCZ-equivalent. For instance, when looking for optimal $4 \times 4$ optimal S-boxes, only 16 "really" different ones were found (see "On the Classification of 4 Bit S-Boxes", the thought process of the authors would also help you by the way), I.e there are only 16 different interesting CCZ-equivalence classes. Thus, you would not need to check all $2^{24}$.

-
Thanks but the problem is its code. i have some novice idea about the code and i've found some useful notes in "Generating Pseudo random S-Boxes – a Method of Improving the Security of Crypto systems Based on Block Ciphers" but that's not enough. – Saeidmscs Jul 14 '13 at 21:25

The answer is: it depends upon the cipher. You cannot design a S-box in isolation; the S-box properties need to be crafted together with the design of the block cipher, to make sure they work well together.