# Mathematically / statistically “safe” way to differentiate between crypto and random blob?

I assume the United Kingdom will impose (as opposed to just talk about it) restrictions on crypto software that may be used within it's borders.

Me, quite the border clown (yes, I always bring a up to nine (only because I can't fit ten times 100ml plus containers into a 1000ml bag) re-sealable, see-through containers of pure tap-H2O, all of them put into a clear see-through, re-sealable plastic bag of no larger volume then 1 liter, to the airport, just to have them all individually sent through expensive-looking devices, checked for any impurities for my own safety, and only to empty all of them right after I have gotten them back from very grumpy border agents into my large mouth) and always having been a hardcore believer in the European Union and every person's unalienateable right to speak freely, privately and without any government intrusion; I would like to bring a USB thumbdrive with a few megs of /dev/random, generated by Linux with the help of a hardware PRNG, or just some concatenated hotbits.

I assume I will be questioned about the contents of the USB thumbdrive and will, truthfully, state that the contents are just random bytes. Depending on the amount of humor (in this case, humour) of the border agent I will spend some snuggly time in a holding cell thereafter.

What means do I have to prove, mathematically and statistically, that my random bits are indeed just that – random bits? What attacks (NIST-tools, chi-squared test, …) might the border agency run against my random bytes to try to prove their non-randomness? What software might he use? What software should he use?

Disclaimer: I am in no way affiliated with any nations government except casting my vote very four or five years. I might one day have to come back to this page from my suggly holding cell. See, officer, I told you.

• You're screwed. They won't believe you it's simple random bytes as good cryptography is completely indistinguishable from random except when you have the key. You can't prove that you don't have a secret password that may turn the random gibberish into meaningful data. For example you may have a TrueCrypt container on this device which is designed to look random without the right password(s). – SEJPM Aug 15 '15 at 19:00
• "(...)as good cryptography is completely indistinguishable from random except when you have the key." - Bruce Schneier keeps repeating this (as it is obviously true). Yet the question remains: Which tools would be used? – Christian Aug 15 '15 at 23:09
• @Christian What do you mean, which tools? You asked for a way to show that something isn't encrypted data, but is instead random. No such way exists. It doesn't matter what tools are used, because the only thing you can prove is "this is not random data, because here's me decrypting it." – cpast Aug 16 '15 at 0:32
• @cpast Which software do I have to run my bytes through to be sure they are, indeed, as random as possible? – Christian Aug 16 '15 at 7:56
• Which software do I have to run my bytes through to be sure they are, indeed, as random as possible? – Check crypto.stackexchange.com/a/18088/12164 – e-sushi Aug 16 '15 at 8:55

If anything can distinguish a blob of random data from an encryption of some (known) data (other than any intentionally added data formats, like a header or a length difference), the encryption algorithm is called broken. (This is one of the variants of the ciphertext indistinguishability criterion for ciphers.)

As there are several encryption algorithms which seem to fulfill this criterion, this means in reverse, no, you can't prove that some self-created blob of random data is really random.

A possible solution would be to have some third party generate the random data for you, and sign a confirmation that it is random. I'm not sure that there is such a service – while random.org offers random numbers (or bytes), I don't see something which can certify those. (One idea would be to store a transcript of the TLS connection by which you downloaded it, but that can also be faked.)

You can download pregenerated files from random.org – assuming random.org isn't part of your conspiracy, this should be good enough to prove you don't have encrypted data there. (But it would also be utterly useless to carry them around in your USB drive, other than to annoy the border guards.)

Another thing to keep in mind: Even if you have real random data with you (which you might previously have shared with someone else), you (or your partner) can later use this to encrypt plaintext (using a one-time-pad) to be sent over the Internet. So allowing you to bring random data into the country just opens the way for you to use encryption later.

• "So allowing you to bring random data into the country just opens the way for you to use encryption later." - So would any other, long-enough piece of data... – Christian Aug 15 '15 at 23:07
• @Christian : $\:$ No; there is no feasible-length string of zeros that $\hspace{2.37 in}$ "opens the way for you to use encryption later." $\;\;\;\;$ – user991 Aug 16 '15 at 1:44
• Regarding signed random numbers, you can get them from the NIST beacon... if you have a use for public random numbers. – otus Aug 16 '15 at 7:49
• @otus Since the site itself states not to use the beacon-generated data as secret cryptographic keys, I wonder what use would be left for them in the crypto arena. OTOH: re-reading your comment and reminding myself OP is a self-proclaimed border-clown, things might just make sense in a weird but funny way. I’m just glad not to work at some checkpoint… I’ld probably be running into my own facepalms all day long. ;) – e-sushi Aug 16 '15 at 8:44
• @e-sushi, that's been asked and answered here: crypto.stackexchange.com/questions/15225/… – otus Aug 16 '15 at 9:14