Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

RandSeq is deterministic #61

Open
cxhernandez opened this issue Dec 14, 2015 · 4 comments
Open

RandSeq is deterministic #61

cxhernandez opened this issue Dec 14, 2015 · 4 comments
Labels

Comments

@cxhernandez
Copy link

According to the Go docs about the math/rand package:

The default number generator is deterministic, so it’ll produce the same sequence of numbers each time by default. To produce varying sequences, give it a seed that changes. Note that this is not safe to use for random numbers you intend to be secret, use crypto/rand for those.

So is RandSeq supposed to be deterministic?

@peastman
Copy link

It sounds like it, unless the seed value is being set somewhere first. What is that function used for?

@cxhernandez
Copy link
Author

I don't see a call to rand.Seed anywhere 😕

It's used here to generate some sort of authorization token, and again here to generate a unique stream ID.

@peastman
Copy link

If the only requirement for those tokens is that they be unique within a run of the server, that's probably fine. If they need to be unique across runs, then it's important to set the seed. And if they need to be cryptographically secure (impossible to predict), then that's the wrong random number generator to use.

@cxhernandez
Copy link
Author

If they need to be unique across runs, then it's important to set the seed.

I think to be absolutely safe this is what is required for the token, which is sent out to each client stream.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants