# Re: Secure permutation of a 1e8 element set

Thanks to everybody for the answers.

You simply will not find a secure permutiation, as you noted any permutation
could be simply stored in memory making it inherently weak. Based on that I
would choose RSA, it won't be secure,

Ok, I know it can't be secure in the usual sense.
But if I do any better, there would be no working database anymore.
RSA would be fine, but very slow, wouldn't it?

but it is not easy to implement efficiently, due to the computation of a
probability distribution with enough precision. In my own tests, I got
to the speed of about 0.3s per encryption, which is pathetic.

I think you have to decide on one maximum. If it does not reallymatter then
choose some RSA number and use his suggestion.

I'like to be able to encrypt any customer number I get,
and it must fit into the range.

You could always cook up a
Feistel cypher based on digits, not bits (use base 10 modulus addition as
the combiner).

Yes, I've got already a plan for it, maybe the addition, maybe some
lookup table with a precomputed permutation of 0..9 in each row.
Additionaly I could permute the digits.

There is a well known trick used in Schroeppel's Hasty Pudding Cipher
for permuting arbitrary integer ranges. The basic idea is that
you map to within the nearest higher power of two using bit twiddling,
and if the result falls outside the desired range, iterate the map
til you get within range. Since the map has a unique inverse you
can get the original number back by iterating the inverse map, again
until the result is within range.

A really nice idea. On the average I need to iterate less than twice,
right?

I posted some code here a while back for permuting 10 digit SSN's but
you should be able to adapt it straightforwardly to 8 digit numbers:

That's really easy, thank you.

The table would only be about 380MB.

There's an account number with two more digits.

That's probably a little unfair to permutations that one can store.
A arbitary permutation of 1e8 numbers is equivelent to a key size
of about 2513272986 bits, if you count the number of possible
mappings. If I gave you the values of (say) P[0], ... p[999], you
couldn't say much about p[1000], other than it wasn't any of the
previous values I'd given you.

Yes, this is exactly what I want.

OTOH, if you tried to use it as a more general block cipher, I guess
that might not be a very good idea because the block size would be
a bit small.

I'm really not going to do anything like this.

Once again, thanks to everybody.
.

## Relevant Pages

• Re: [QUIZ] Counting to 100 (#119)
... that could map a number n to each permutation of digits, ... digits, 1 to 19683 for 10 digits, etc. ... all possible orders for the elements in the array. ...
(comp.lang.ruby)
• Re: RSA ecnryption confusion
... RSA, then it is most probably you. ... "trapdoor permutation". ... -- A digital signature protocol. ... The conditions for RSA to be a trapdoor permutation (i.e. to realize ...
(sci.crypt)
• Re: RSA ecnryption confusion
... RSA, then it is most probably you. ... "trapdoor permutation". ... -- A digital signature protocol. ... The conditions for RSA to be a trapdoor permutation (i.e. to realize ...
(sci.crypt)
• Re: Feasibility of constructing backdoors in non-open-source RSA software
... RSA public key cryptography relies on the general computational ... implanted with backdoors by Mafia & Co. that render the factorization ... addition that k of its leading digits to ... Some people keep prattling on that crypto does ...
(comp.security.misc)
• Feasibility of constructing backdoors in non-open-source RSA software
... RSA public key cryptography relies on the general computational ... implanted with backdoors by Mafia & Co. that render the factorization ... The software contains a predetermined list of public keys and their ... addition that k of its leading digits to ...
(comp.security.misc)