# How is the MD2 hash function S-table constructed from Pi?

For fun, I'm learning more about cryptography and hashing. I'm implementing the MD2 hash function following RFC 1319 (http://tools.ietf.org/html/rfc1319). I'll preface by saying I know there are libraries, I know this is an old hash, and I do not intend to use this in anything real-world, so don't anyone freak out.

In learning about S-tables I notice MD2 uses an S-table based on Pi. What I don't understand, is how these numbers relate to Pi. And oddly, I can't find anywhere that describes it. The RFC just says:

This step uses a 256-byte "random" permutation constructed from the digits of pi.

In the reference code, there is the following comment:

Permutation of 0..255 constructed from the digits of pi. It gives a "random" nonlinear byte substitution operation.

Looking at the first few bytes:

41, 46, 67

I cannot see how you get these numbers from Pi. I've tried looking at the binary representation of Pi, and these numbers do not seem to match up with the first bytes of pi.

My usual Googling just leads me back to the RFC or other implementations which seem to copy the above comment exactly. No where can I find where the construction of this table from Pi is explained.

-

## migrated from stackoverflow.comNov 25 '13 at 12:19

This question came from our site for professional and enthusiast programmers.

@user8911 - they are not pi. the question is how the fractional part of pi is used to derive a permutation of 0...255 –  andrew cooke Nov 25 '13 at 16:09
Interesting question, I don't know the answer yet (and couldn't find it with some googling). Might be actually not a nothing-up-my-sleeve-number, but only pretending to be one ;-) –  Paŭlo Ebermann Nov 25 '13 at 20:10
The authors of Network Security: Private Communications in a Public World cast some doubt on whether this table is actually based on Pi. –  archie Nov 26 '13 at 0:30
Also note that RC2 (in RFC2268) also has a permutation supposedly based on the digits of $\pi$ in its key schedule. The final table in that RFC is also unexplained (and used in other algorithms from RSA as well). These were also never explained, AFAIK. –  Henno Brandsma Dec 10 '13 at 16:06
It's a mystery to me why no one ever asked the creator of that s-table. When weird things show up in RFCs, someone like me expects the crypto-pros to speak up and ask. But we have to remember that crypto-professionals were a bit rarer "back in the days". I'm probably expecting too much from the past. –  Trina Jan 7 at 21:38