real random

B

Bill Cunningham

Richard Heathfield said:
In <[email protected]>, Bill Cunningham
I have seen you fail, recently, to add up a few numbers in a loop.
Being optimistic about your abilities is a good thing, however.

I have tended to separate algorithms from languages. Learning C is
different than an algorithm. But my mind comes and goes. I have seen many
here do as you as an expert have said don't do and that's cast. I try to
remember this as I go on. I read some code here and it's not all always much
better than mine. In your example of me not being able to write a loop I
have been confusing writing to to fill an array with zeros and code like
this; a slight difference.

int main(void){
int ar[128]={0};
int i;
for(i=0;i<128;++i)
printf("%i\n",ar);
return 0;
}

I hope you see the difference though it's not spaced. I guess here overall
what I've learned is that there are no real random numbers to computing.

Bill
 
B

BGB / cr88192

Richard Heathfield said:
The thing about "predictable" with regard to chaotic systems is that
one /doesn't/ have sufficient information.

<snip>

ok, a difference in terminology...

They usually aren't chaotic.

ok.



We've long since left C behind, and now if we're not careful we'll be
heading for a discussion of objectivism vs subjectivism.

<snip>

hmm... maybe...
 
N

Nobody

Actually the correlation between successive values is approximately
100%. It's just that it's really, really, really well obscured.

For all we know, the same could be true of quantum noise. Just because
nobody has found a pattern, it doesn't mean that there isn't one.
 
D

Default User

Nick said:
Sometimes I think you argue just for the joy of it.
Not that that's a bad thing...

Around here, not even an unusual thing. I'd say a fair chunk of the
posts here . . .




Brian
 
B

Beej Jorgensen

Bill Cunningham said:
Can anyone show me a skeleton code for *real* random numbers? Not just
using srand and rand that sometimes depends on the clock.

This slipped my mind until just now, but here's one software PRNG
suitable for crypto:

http://en.wikipedia.org/wiki/Blum_Blum_Shub

They're not *real* random numbers--it's just that predicting the random
number stream with this generator is computationally very difficult, so
it works well for crypto.

-Beej
 
R

Richard Bos

BGB / cr88192 said:
(satire...) "but, how can anyone think the US is not the entire world?..."

</satire>
But, how can anyone think that the UK is not a dependent territory of
the USA?

Richard
 
W

websnarf

Ok, so let us say that you have two scenarios.  In one you use your
keyfob as the seed for a PRNG and use its output as your random
stream.  In the second you use something like a cosmic background
radiation detector or whatever you imagine is going to give you a
truly random seed.
Now give me an algorithm for determining the difference between those
two outputs.  I.e., if I hand you one of the two streams (which I will
choose by a secret coin flip), you have to tell me which one I gave
you (assuming I could keep you from observing your own keyfob).  You
may use any resource you like including the NSA, and the manufacturer
of your keyfob.

The algorithm is trivial. [...]

*Sigh* ... I should have been more specific. I should have said "Find
an algorithm that you can actually *execute* in your lifetime". Of
course, this is the whole point -- yes an algorithm exists, but very
specifically it is supposed to take longer than anyone's lifetime on
the biggest computer network, etc., etc and the claim of its security
is that you cannot do better than that.
[...] Whether it's practical or not is a
different issue.  Consider a simple security token that just runs DES
in CTR mode against the timestamp value.

Well ok dude, you can't make it *that* easy on yourself. I would
expect, in fact, that they use something better than DES 56 and of
course they can't have all the client generators outputting the same
numbers, so they probably don't just run in counter mode, but insert a
prefix or suffix that uniquely identifies each one.

[analysis of this somewhat easy scenario snipped]

You skipped over the point where you had to actually deduce the key
from the final output -- something that's inordinately difficult if
you are reseeding at a rate higher than half the period of a long
period PRNG like the Mersenne Twister. I assume there is an approach,
but nothing comes to mind.
On the flip side I would assume a good token today would use something
stronger than single DES (which doesn't change the theoretical
approach, just makes it even less practical).

Right.
 
U

user923005

The algorithm is trivial. [...]

*Sigh* ... I should have been more specific.  I should have said "Find
an algorithm that you can actually *execute* in your lifetime".  Of
course, this is the whole point -- yes an algorithm exists, but very
specifically it is supposed to take longer than anyone's lifetime on
the biggest computer network, etc., etc and the claim of its security
is that you cannot do better than that.
[...] Whether it's practical or not is a
different issue.  Consider a simple security token that just runs DES
in CTR mode against the timestamp value.

Well ok dude, you can't make it *that* easy on yourself.  I would
expect, in fact, that they use something better than DES 56 and of
course they can't have all the client generators outputting the same
numbers, so they probably don't just run in counter mode, but insert a
prefix or suffix that uniquely identifies each one.

[analysis of this somewhat easy scenario snipped]

You skipped over the point where you had to actually deduce the key
from the final output -- something that's inordinately difficult if
you are reseeding at a rate higher than half the period of a long
period PRNG like the Mersenne Twister.  I assume there is an approach,
but nothing comes to mind.
On the flip side I would assume a good token today would use something
stronger than single DES (which doesn't change the theoretical
approach, just makes it even less practical).

Right.

I guess that on you will get the real experts to chime
in.

I do know that the Mersenne Twister is not recommended for crypto,
despite its excellent period and other desirable characteristics.
 
B

Bill Cunningham

Phil Carmody said:
Keith Thompson said:
jacob navia said:
Bill Cunningham a écrit :
Can anyone show me a skeleton code for *real* random numbers?
Not just using srand and rand that sometimes depends on the clock.

This is a good one.

/*
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
[192 lines deleted]

The code you posted appears to be an implementation of the Mersenne
Twister. My understanding is that it's a very good *pseudo*-random
number generator, but it doesn't generate truly random numbers
(nor can any algorithm).
Absolutely.

Bill: srand and rand themselves do not depend on the clock,
though the current time is often used as a seed. The Mersenne
Twister is likely to give you better pseudo-random numbers than
your implementation's rand(), but (a) they're still pseudo-random,
and (b) you still have to provide it with a seed.

(b) is _vital_. Most people who use and recommend MTs tend to simply
be wowwed by its period, and are completely ignorant about correct
use. They'll seed it with some low entropy source, and then generate
many thousands of incredibly predictable values. The correlation is
so strong that most time I see use of an MT I *presume* ignorance
about PRNGs.
<OT>
Take a look at /dev/random and /dev/urandom if your system provides
them.
</OT>

What are you *really* trying to accomplish?

Almost certainly something which does not require a true RNG. For
most hobby tasks, a blend of a few trivial (period 2^64-ish) PRNGs is
more than enough. George Marsaglia has published C sources for this.
(Sci.crypt seems a likely location for such info.)

Ok I'll look at this Mersenne geometry. I think I might of asked this
before but what about sedding something like srand with fractal image math ?

Would that be secure?

Bill
 
R

robertwessel2

The algorithm is trivial. [...]

*Sigh* ... I should have been more specific.  I should have said "Find
an algorithm that you can actually *execute* in your lifetime".  Of
course, this is the whole point -- yes an algorithm exists, but very
specifically it is supposed to take longer than anyone's lifetime on
the biggest computer network, etc., etc and the claim of its security
is that you cannot do better than that.


OTOH, tokens sold only a few years ago clearly did *not* meet this
criteria. BTW, my token design, except for the excessively short DES
key is perfectly valid - and if you did triple-DES instead, it would
make a fine token.

[...] Whether it's practical or not is a
different issue.  Consider a simple security token that just runs DES
in CTR mode against the timestamp value.

Well ok dude, you can't make it *that* easy on yourself.  I would
expect, in fact, that they use something better than DES 56 and of
course they can't have all the client generators outputting the same
numbers, so they probably don't just run in counter mode, but insert a
prefix or suffix that uniquely identifies each one.


Actually the approach is to set a different key on each token. And
you can seed the 32 bit counter with any value you want, the sever
that authenticates these just needs to keep track of both values. So
two token don't generate the same sequence even if they used the same
timebase.

You skipped over the point where you had to actually deduce the key
from the final output -- something that's inordinately difficult if
you are reseeding at a rate higher than half the period of a long
period PRNG like the Mersenne Twister.  I assume there is an approach,
but nothing comes to mind.

OK, we were talking about tokens, but...

Finding the actual key (or at least the current internal state, which
is close enough) is trivial for the brute force algorithm. In the
case of the example token, it just requires five consecutive samples
(or actually any five with known spacing). Just look at how the EFF
DES Cracker worked. For simplicity of discussion, assume the five
samples are consecutive. You iterate through all 2**88 possible
states to see if they produce the first 20-bit output. About one in a
million attempts will pass. Any that do pass you just tests states (n
+1), (n+2), (n+3) and (n+4) to see if the output from those states
matches the subsequent samples.

But reseeding occasionally does not deal with the theoretical problem
(although for MT brute force would be impractically slow by any
standard). Some 624 generated 32 bit random numbers is enough to
deduce the exact state with very high probability. And reseeding MT
that often is impractical. And since MT is not considered
cryptographically secure, I assume there's a *much* easier way to back
out the state from the 624 outputs. Many things that have been used
for random number generation can been reversed fairly easily, and with
drastically less output than their period - LFSRs are a favorite - you
need only a couple times as many output bits as the state (IOW twice
the length of the shift register or 2n, despite the period being
2**n-1) and they're easy to reverse. And even a function you hope is
cryptographically secure can turn out otherwise - again the original
RSA SecurID tokens* come to mind. And there have been numerous attack
on PRNGs - the famous crack of Netscape's SSL implementation (way back
in 95 or 96) was due to a flawed PNRG implementation. And just
because you can’t reverse your generator today, doesn’t mean you
couldn’t do it tomorrow.

I think the point is that it’s best not to assume that your "random"
data has any more entropy that you actually fed into it.


*Admittedly it's not a perfect attack, but with two months worth of
outputs (about 100,000), you have about a 10% chance of cracking the
Alleged SecurID Hash Function with 2**40 work.
 
N

Nick Keighley

For all we know, the same could be true of quantum noise. Just because
nobody has found a pattern, it doesn't mean that there isn't one.

if there were correlations between quantum variables ("hidden
variables")
then there would be other nasty consequences like non-locality (or
some
other stuff I can't remember off the top of my head)
 
K

Keith Thompson

Richard Heathfield said:
In


She? I assumed Chris meant Michael Palin, and that "she" referred to
the USA. So if he /didn't/ mean Michael Palin, who on earth could he
have meant? (I know. You'll all think I'm being disingenuous. But I'm
not. I really truly have no idea who you're talking about.)

Sarah Palin. The line about seeing Russia from her house was from
a satirical spoof; I presume that's why it was followed by a smiley.
Google if you're curious.
 
N

Nick Keighley

personally though, I believe that the universe is itself non-deterministic,

this is with the quantum thrown in?
however, I also believe that the past/present/future distinction is
ultimately meaningless, as all exist essentially at the same time,

who is going to win the 3:30 at Haydock?

I love the "at the same time bit"...

but the
process is essentially a sort of asymmetric "cone" WRT entropy, which
essentially forces us to "move" along in a single direction WRT time (AKA:
the past has not "gone away", and the future is not "being made", rather it
just seems like this is the case...).

when can acquire information about the past but not about the future.
The future is essentially unobservable and hence doesn't exist.
Although different observers may disagree about the exact ordering
of some events other events are unambiguously orderable. The Big Bang
occurred before anything in human history.

not that I believe in fatalism though, since, as I see this, this would be a
rather incorrect interpretation of the process (AKA: even if all of the
future and all of the past exist at the same time, there may exist far more
futures than there exist pasts,

again this makes for a huge distinction between past and future

or it could be that the universe has already
"collapsed" onto a single outcome, and as such the eventual "fate" of
everything is already been decided, but even as such, free-will and freedom
of outcome will at least "appear" to exist...).

"the experience of free will is a gift of ignorance
or a product of incomplete information"

or, stated in another way:
there is no "guiding hand of fate" to force any particular output, and
infact people have full free will, only that the entire future state (every
decision to ever be made, everything to ever exist, ...) may already exist,
only that they are invisible from the present state.

(or something like this...).

<snip>
 
N

Nick Keighley

it depends on task...

granted, for some tasks I have utilized the repeatability of PRNGs.
in many cases though, people want "actual" random numbers...

not as often as they think
 
C

Chris H

In message <[email protected]
s.com> said:
She never said that, jackass.

what she said was “you can actually see Russia from land here in
Alaska.â€


but given the other complete bollocks she talked most will believe she
said "my house" as it is credible.
 
N

Nick Keighley

Nick Keighley wrote:

Around here, not even an unusual thing. I'd say a fair chunk of the
posts here . . .

I was raised by lawyers and hence it seemed normal
behaviour from an early age
 
C

Chris H

In message <[email protected]
..com> said:
Yes, I know she made that true statement. That is why I replied.


Weak.

No she made so many mistakes and gaffs and was clearly so far out of her
depth it was quite believable she said "my house"

Actually outside the USA most people took it as a sign from McCain when
he had Palin as his running mate that he did not want to win the
election
 
D

Dik T. Winter

....
> I understood the original poster as asking for a good random number
> generator. If he wants something else, not using software, I thought he
> would have said so.

He wanted software, but he also wanted *skeleton code* for a *real* random
number generator that does not depend on the clock (i.e. is not seeded by
the clock).

The Mersenne twister you posted was neither skeleton code, nor did it not
depend on some seed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top