WEBVTT

00:00.000 --> 00:00.540
All right.

00:00.540 --> 00:01.560
Hello, everyone.

00:01.800 --> 00:03.400
I go by Infocalypse.

00:03.400 --> 00:07.620
This is my talk, Cracking Chaos, Making, Using, and Breaking Pseudo-Random Number Generators.

00:07.820 --> 00:10.480
It is my first time speaking, so in accordance...

00:20.420 --> 00:20.960
Great.

00:20.960 --> 00:22.500
Nothing like whiskey at noon, right?

00:23.920 --> 00:24.840
All right.

00:24.840 --> 00:28.280
So we're going to start off with some preliminaries.

00:28.800 --> 00:30.280
What is randomness?

00:30.280 --> 00:31.940
And it's kind of hard to define.

00:33.020 --> 00:38.320
So there's a whole lot of debate over this in the physics community, so I am not even going to try because that is not what I do.

00:38.320 --> 00:42.940
But we are going to discuss some models of it and give some intuitive explainers, right?

00:42.940 --> 00:48.260
So we have what most people would consider to be true randomness, which is entropy, right?

00:48.260 --> 00:57.020
So if you're out at this casino playing some craps, rolling dice, we can all pretty much intuit that that is some kind of random behavior, right?

00:58.240 --> 01:01.100
The idea is that it's non-deterministic.

01:01.600 --> 01:05.460
So even if you have the same throw, things might not shake out the same.

01:06.480 --> 01:12.860
But for computation, since we're using deterministic machines, we have the random oracle model.

01:13.540 --> 01:18.640
So the easiest way to think about the random oracle model is like we have a gnome in a box, right?

01:19.300 --> 01:20.840
And this gnome has a book.

01:20.840 --> 01:22.920
He's got some, once again, dice in there.

01:22.920 --> 01:25.580
And there's a little hole that you can pass notes through.

01:25.580 --> 01:38.180
So you write something down on a note, you pass it through the box, give it to the gnome, gnome sees it, he's going to write down what was on the note, roll some dice, give you out a number, and then you're going to do that again, write a different note,

01:38.180 --> 01:43.920
pass it in the box, he's going to repeat the process, write down the number, or write down the note, generate a number, give it back out.

01:44.220 --> 01:50.340
But if you give him the first thing you wrote down again, what's going to end up happening is he's just going to look in his book and give you the same number.

01:50.640 --> 01:53.500
That is the very, very intuitive explanation of this.

01:53.500 --> 01:58.020
It is much more rigorous informal definition, but yeah.

01:59.120 --> 02:02.600
So and then the weakest definition we have is statistical randomness.

02:02.600 --> 02:06.840
And this is what most people will be familiar with if you've ever worked with PRNGs.

02:07.140 --> 02:10.120
This is your test suites like Die Hard or Test 201.

02:10.120 --> 02:15.760
This is where we're going to be testing, you know, does this look like random, do these look like random numbers?

02:15.760 --> 02:17.280
Does this make sense as random data?

02:17.340 --> 02:18.220
Statistically.

02:18.600 --> 02:22.680
But it is not as strong as an assertion as a random oracle.

02:24.560 --> 02:26.840
So we're going to start off with true randomness, right?

02:27.160 --> 02:30.600
It's an essential but expensive commodity on computers.

02:31.340 --> 02:33.760
We generate it a few different ways.

02:33.760 --> 02:35.620
The most common is system entropy.

02:35.620 --> 02:43.680
So this is going to be things that are mixed together, like mouse movements or load times.

02:43.980 --> 02:47.060
All kinds of fun system processes, usually.

02:47.820 --> 02:52.680
And that is what usually powers the randomness used in your OS.

02:52.680 --> 02:55.600
So like defrandom, wrandom, that's what seeds it.

02:55.600 --> 02:57.740
And historically, that's actually what was outputted.

02:58.260 --> 03:05.280
And then for more demanding scenarios, we have hardware random number generators, which is what you can see depicted up there.

03:07.200 --> 03:18.200
Essentially, they are little additions you can make to your machine that allow you to more efficiently sample randomness, usually from some kind of temperature or pressure or whatever it may be.

03:19.540 --> 03:22.760
So why do we care about true randomness?

03:22.980 --> 03:24.760
Well, one, statistics.

03:24.760 --> 03:27.720
It's the base for how we evaluate random number generators.

03:27.720 --> 03:31.740
And two, in the cryptographic case, it gives us some hardness assertions.

03:31.740 --> 03:38.580
If we have a random bit string, there's no more efficient way to guess it than brute force, because there's no underlying pattern, right?

03:38.580 --> 03:49.040
So if we have, say, 128-bit length bit string, you're expected to find the value in 2 to the 127 iterations, which is just not feasible if it's a truly random bit string.

03:50.360 --> 03:55.520
So that's where we get, like, our whole definition of what n-bit security is.

03:57.800 --> 03:58.560
All right.

03:58.560 --> 04:01.720
So next up, we're on insecure pseudorandom number generators.

04:02.220 --> 04:05.540
This is when we really only care about speed and statistical quality.

04:05.540 --> 04:08.000
We don't really care about hardness assertions.

04:08.420 --> 04:13.860
So in these cases, the promise of n-bit security, as I just discussed, does not usually hold up.

04:14.240 --> 04:18.500
So some examples to kind of ground this are...

04:18.500 --> 04:20.760
So we have some CVEs up here.

04:21.100 --> 04:25.720
We have the bug in Debian's OpenSSL, where their pseudorandom number generator...

04:28.020 --> 04:28.980
Good.

04:29.020 --> 04:29.720
Okay.

04:30.540 --> 04:39.820
So their pseudorandom number generator was weak, and it was not generating dynamic enough numbers, which made a lot of secrets predictable.

04:40.940 --> 04:46.480
So there's actually a whole CWE that classifies this, which is why they're both rated as 7.5s, but it was pretty severe.

04:46.480 --> 04:47.380
It was pretty gnarly.

04:47.540 --> 04:55.540
And then another example is Moodle, which is a PHP framework, was using mercen twisters for token generation to reset account passwords.

04:55.540 --> 05:09.960
So since mercen twisters are invertible, ta-da, I can just go ask to reset some arbitrary account, invert the generator, and now I know what's coming next, and so I know all the account generation codes going forward.

05:10.460 --> 05:13.500
So yeah, those are some examples.

05:13.680 --> 05:17.780
So now we're going to start talking about types of insecure pseudorandom number generators.

05:18.040 --> 05:24.020
So we will start off with, historically, one of the earliest, which are linear congruential generators.

05:25.760 --> 05:28.620
They are extremely simple.

05:28.660 --> 05:30.560
They can be fairly fast.

05:31.240 --> 05:32.940
They were prolific in early computing.

05:32.940 --> 05:35.500
You don't really see too many of them anymore, which is a good thing.

05:35.840 --> 05:41.680
But if you are going to find one, it's typically going to be on some kind of legacy system, because these are old generators.

05:43.740 --> 05:47.000
So the way they work is we have a little recurrence here.

05:47.000 --> 05:52.740
We have X of N plus 1 equals A times X of N plus C Magillo M.

05:53.420 --> 05:58.480
So the maximal period on these is typically considered to be M, or about M, rather.

05:58.480 --> 06:04.360
So we have three forms of them that we'll be briefly discussing, and one we're going to be going into a bit more detail on, because it's interesting.

06:04.680 --> 06:09.720
So we have the case where the additive is zero, and the modulus is prime.

06:10.180 --> 06:13.360
These will give you a near maximal period, but they're pretty slow.

06:14.660 --> 06:17.300
So they're not too often used.

06:17.400 --> 06:22.080
And then we have the case where the additive is once again zero, and M is a power of two.

06:22.900 --> 06:25.240
These are non-maximal periods, usually.

06:25.260 --> 06:26.100
Well, not usually.

06:26.100 --> 06:28.100
They are always non-maximal periods.

06:28.440 --> 06:29.880
But they are fast.

06:30.120 --> 06:32.920
Once again, nobody really uses them, because non-maximal periods.

06:32.920 --> 06:40.320
And the next case, which is the one we're going to be discussing more deeply, is when the additive is not equal to zero, and M is a power of two.

06:40.400 --> 06:43.180
These are both maximal period, and they are fast.

06:46.080 --> 06:51.680
So linear congruential generators are unfortunately not statistically sufficient.

06:52.340 --> 06:56.840
They are easily, easily, easily detectable by spectral test failure.

06:57.340 --> 07:05.060
So for people that have used statistical test suites before, you'll probably recognize that name.

07:06.000 --> 07:19.180
And they also follow something called Marsaglia's theorem from George Marsaglia, which states that when you plot the outputs from a linear congruential generator in higher dimensions, so as we can see there, it's three dimensions, they lie in planes or hyperplanes.

07:19.180 --> 07:29.560
So from that picture there, you can clearly see those are outputs from a linear congruential generator, pretty weak one, and so the planes are quite distinct.

07:31.700 --> 07:33.840
So how do we break these?

07:35.420 --> 07:40.400
Through the same means and reasons why they suck statistically, we're going to break it.

07:40.560 --> 07:52.400
So we're going to walk through the general approach, and then we will showcase both a of numerical recipes, and then also a visualization in 3D of Marsaglia's theorem.

07:54.020 --> 07:56.640
So let's walk through this real quick.

07:56.640 --> 07:59.220
So given several outputs, you need at least five.

07:59.220 --> 08:02.780
You're going to form pseudo-Hankel matrices of that form.

08:03.820 --> 08:15.400
And you're going to calculate the determinant of these matrices and enumerate the greatest common divisor of them, which will give you a multiple of the modulus or the modulus itself, if you're really lucky.

08:16.160 --> 08:35.560
You can usually deduce what the modulus is just knowing the types of these generators, but if you can't, try and get at least one more output, do it again, same operation, except D2 with D3, and then take the GCD of the results in value of D1, D2, and D2,

08:35.560 --> 08:40.640
D3, and usually that's more than enough to actually nail down the modulus.

08:41.680 --> 08:46.980
So once we've got M, we're going to go through the simple case, because there's a bit of complexity with these.

08:47.380 --> 08:49.680
We are going to look for the multiplicand A.

08:50.940 --> 09:02.820
So what you want is the difference of the second output and the first output, and M to be coprime, because that gives us an easy, nice formulation for the multiplicand.

09:03.340 --> 09:09.460
Otherwise, we get to solve linear Diophantine equations, so it's less fun, but it is doable.

09:10.020 --> 09:14.440
We're not going to talk too much about that, though, because I only have so much time.

09:15.020 --> 09:27.920
So given the simpler case, we're just going to enumerate A according to that equation given right there, product of O3 minus O2 times the inverse of O2 minus O1 modulo M.

09:29.880 --> 09:35.220
And then all you have to do to find C is just set up that last equation.

09:35.220 --> 09:37.060
It's pretty easy to break these.

09:37.060 --> 09:38.520
It's very fast.

09:38.700 --> 09:42.580
And we will actually see that right now.

09:42.860 --> 09:48.400
So we have... this is a linear congruential generator.

09:48.400 --> 09:49.980
There's two of them here.

09:49.980 --> 09:55.940
We're breaking RANQD1, and then we're visualizing a much weaker one, because it's a lot easier to see the planes.

09:57.060 --> 09:59.980
So I know crypto demos are everyone's favorite thing.

09:59.980 --> 10:01.300
It's very exciting.

10:05.100 --> 10:06.740
But... sorry for the lag there.

10:06.740 --> 10:09.640
I wrote this on a much more powerful computer.

10:11.280 --> 10:13.780
So in the console there, we can see the outputs.

10:13.780 --> 10:15.040
We can see the determinants.

10:15.040 --> 10:20.500
We can deduce what the characteristic is.

10:20.760 --> 10:22.420
We test if it's co-prime.

10:22.420 --> 10:23.260
It is.

10:23.280 --> 10:27.200
We're able to pull out A, C, and then we can just invert the seed.

10:27.200 --> 10:37.020
And then in our lovely spinning cube, we can see as it spins that sometimes the dots will all line up in those planes.

10:37.300 --> 10:41.760
And that's exactly what a Mersogli's theorem would expect and what makes these breakable.

10:42.120 --> 10:46.320
So I think that should be enough for that demo.

10:46.740 --> 10:49.440
And we are now on to linear feedback shift registers.

10:49.440 --> 10:51.200
This is another classic, classic generator.

10:51.200 --> 10:52.540
You still find these today.

10:53.060 --> 10:54.360
Mostly in embedded.

10:54.360 --> 10:58.960
But they make use of bitwise arithmetic for fast pseudorandom bits.

10:59.100 --> 11:02.020
Once again, they have multiple forms.

11:02.020 --> 11:06.940
We are going to be discussing the Fibonacci form because it is the easiest to explain.

11:07.860 --> 11:11.420
And also usually what you see more on the hardware side of things.

11:11.600 --> 11:15.320
Depicted up there, you can see a visualization of one.

11:17.540 --> 11:23.800
So Fibonacci generators work by selecting inputs, which in the typical nomenclature is called a tap.

11:24.920 --> 11:26.400
Corresponding to a binary polynomial.

11:26.840 --> 11:36.740
If it's polynomial in the given field, which is usually a length of register, the period will be maximal, equal to 2 to the n minus 1, where n is the degree of the feedback polynomial.

11:37.940 --> 11:43.900
So we're going to actually just kind of walk through an iteration of one because once you see it, you go, oh, that's really easy.

11:45.060 --> 11:46.020
So here's our seed.

11:46.020 --> 11:49.600
We have 0, 0, 1, 1, 0, 1, 0, 1.

11:49.600 --> 11:53.260
And then we have our feedback polynomial, x to the 7 plus x to the 6 plus 1.

11:54.800 --> 12:00.100
The way that the actual generators work is it's flipped.

12:00.420 --> 12:01.420
Sorry, questions.

12:01.420 --> 12:03.040
There's a question and period at the end.

12:05.940 --> 12:11.740
So we're going to have an output bit of 1, which is the last bit.

12:12.240 --> 12:17.060
We're going to take the 6th and the 7th, which is actually the 7th and the 8th because of the 1.

12:17.720 --> 12:19.780
And we are going to exclusive or them.

12:19.780 --> 12:21.680
So 0s or 1 is 1.

12:22.220 --> 12:23.580
And we stick that in the beginning.

12:23.580 --> 12:24.700
Ta-da.

12:24.700 --> 12:25.900
Linear feedback shift register.

12:28.800 --> 12:32.640
So they're pretty simple, but they are very fast.

12:32.640 --> 12:33.640
They're very efficient.

12:33.640 --> 12:36.280
But they are, once again, very weak.

12:36.380 --> 12:39.640
They notably fail two tests for distinguishing.

12:39.640 --> 12:42.520
Obviously the linearity test, which the LCT also fails.

12:42.540 --> 12:47.920
And the binary matrix rank test that is extremely distinguishing with linear feedback shift registers.

12:48.800 --> 12:52.620
But with the way you break these, it's an algorithm called BrilleCamp Massey.

12:52.620 --> 12:53.680
We won't be diving into it.

12:53.680 --> 12:55.260
Once again, I only have so much time.

12:55.540 --> 12:58.180
But it's more prudent to just try BrilleCamp Massey.

12:58.180 --> 13:06.040
If you get a short linear feedback shift register as a result of BrilleCamp Massey, congrats, it was a linear feedback shift register and you just inverted it.

13:06.040 --> 13:11.980
If you get one that's about half the length of the input that you gave it, probably not a linear feedback shift register.

13:13.820 --> 13:15.720
So next up we have Mersenne twisters.

13:15.720 --> 13:18.640
This is one of the most popular generators out there.

13:18.720 --> 13:20.720
It is the default in Python.

13:20.720 --> 13:22.800
It is all over the place.

13:22.920 --> 13:27.520
It is built off of a laundry list of previous stuff, generalized feedback shift registers.

13:27.520 --> 13:30.860
Then you have twisted generalized feedback shift registers, rationalized.

13:31.200 --> 13:34.740
And then you have the Mersenne twister, which comes after that.

13:34.960 --> 13:38.720
So it's generated by, once again, yet another relation.

13:39.420 --> 13:42.320
Sorry, the cursor made that a little ambiguous.

13:43.320 --> 13:51.860
So what it's essentially doing is it's manipulating its own internal state to form words through both concatenation and exclusive ORs.

13:52.300 --> 13:59.060
And then it performs a matrix multiplication at the end, which comes from the twisted generalized feedback shift register.

14:00.980 --> 14:06.620
So they are pretty high quality pseudo random number generators, which is why they're the default everywhere.

14:07.600 --> 14:16.100
They have an obscenely long period, at least with Mersenne twister 19937, of 2 to the 19937 minus 1.

14:16.100 --> 14:27.880
They have a state width of 624 32-bit words, and it is equidistributed up to 624 dimensions after tempering, which is the final part of the Mersenne twister algorithm.

14:28.200 --> 14:34.600
There with the depiction we can see from the original paper the specification for MT19937.

14:36.440 --> 14:39.460
It is very strange.

14:39.460 --> 14:41.040
That paper is very strange.

14:42.780 --> 14:51.780
So the thing with Mersenne twister is it's a lot harder to detect than the previous algorithms, because there's multiple, multiple different variants.

14:51.780 --> 14:56.820
But since MT19937 is by far the most prolific, we're going to discuss detecting that one.

14:56.820 --> 15:09.780
It fails two statistical tests, notably in the test U01 big crush suite, which both have to do with equidistribution in very, very high dimensions, which is what Mersenne twister fails at.

15:09.780 --> 15:16.840
So if you can test in dimension higher than 623, you'll start to see that Mersenne twister deteriorates in equidistribution.

15:17.960 --> 15:34.100
In the older versions, there was also a pretty infamous warm-up period where if you had a really low Hamming weight, so not a lot of 1s in your seed, it would take a pretty good while to spin it up to get a correct number or a statistically correct number of 1s for randomness,

15:34.100 --> 15:37.420
but this has been fixed in newer versions, so it's not a surefire way.

15:37.980 --> 15:40.720
So how do we invert Mersenne twister?

15:41.300 --> 15:44.260
I mentioned earlier the tempering technique.

15:44.260 --> 15:46.340
What it is is basically just a matrix multiplication.

15:46.340 --> 15:50.600
It's a type of output whitening to make sure it has the statistical qualities we want.

15:51.040 --> 15:56.680
The matrix that we do this with is non-singular, therefore it is invertible.

15:56.740 --> 16:04.500
So we just invert the tempering matrix, which is public, apply it to outputs, we collect 624 of them, and now we've cloned state.

16:04.500 --> 16:09.880
So you can now predict all the future outputs of a Mersenne twister just by doing that.

16:10.880 --> 16:14.420
So don't use it in security-sensitive context.

16:16.500 --> 16:20.020
Now on to our last insecure generators.

16:20.020 --> 16:22.220
We have counter-based PRNGs.

16:22.220 --> 16:26.680
These are pretty new, and they take inspiration from block ciphers in counter mode.

16:27.300 --> 16:31.300
They typically use deliberately weakened cryptographic primitives and techniques.

16:31.300 --> 16:39.200
They are extraordinarily fast as a result of optimizations, and sometimes hardware equipment for it.

16:39.460 --> 16:45.440
The most common reference you'll see for these kinds of generators is the Random123 library, which was published by D.E.

16:45.440 --> 16:45.910
Shaw.

16:46.240 --> 16:52.260
It includes three generators, which are ARS, 3FRY, and PHYLOX.

16:52.280 --> 16:58.720
ARS is based off of a weakened AES, 3FRY is weakened 3FISH, and PHYLOX is a completely original product.

16:58.720 --> 17:04.660
So these generators have gotten quite popular pretty recently.

17:04.660 --> 17:05.530
They're used everywhere.

17:06.020 --> 17:09.800
We have them in curand, we just got it in C++ 26.

17:10.600 --> 17:16.100
NumPy, Intel's OneAPI, HPC stuff, and there are many, many more.

17:16.560 --> 17:26.460
These are pretty notable because they all passed the most stringent, or usually most agreed upon to be the most stringent test we have for statistical tests, which is TestU01's big crush.

17:26.460 --> 17:29.440
And all of these passed in their official variants.

17:29.780 --> 17:31.220
They have obscenely long periods.

17:31.220 --> 17:34.280
Once again, it's about 2 to 128, at least per D.E.

17:34.280 --> 17:35.100
Shaw's numbers.

17:35.600 --> 17:39.700
However, given they use cryptographic primitives, some people make the assumption that they are cryptographic.

17:39.700 --> 17:40.320
They are not.

17:40.320 --> 17:46.160
They have no cryptanalysis has been done of them, and there is no claims of security made by D.E.

17:46.160 --> 17:46.700
Shaw.

17:46.700 --> 17:49.400
So keep that in mind if you ever want to use these.

17:50.120 --> 17:54.900
We're going to talk about PHYLOX today, because it is what I have by far the most experience with.

17:54.900 --> 18:00.020
I am currently doing great battle with Red Hat employees to get it merged into lib standard C++.

18:00.760 --> 18:03.820
So yeah, it's fun.

18:03.820 --> 18:05.180
Almost there, almost there.

18:06.440 --> 18:10.600
So once again, it is a completely original product of random 1, 2, 3.

18:10.600 --> 18:12.160
It's their own device.

18:12.340 --> 18:16.840
So it's a hybrid Feistel network substitution structure.

18:16.860 --> 18:18.940
It has multiple forms.

18:19.260 --> 18:22.580
There's multiple 32-bit forms and multiple 64-bit forms.

18:22.580 --> 18:30.340
And then the 2 you see in the front or the 4 you see in the front has to do with the internal state counter.

18:30.340 --> 18:33.100
There's not really a state in this, but it's the width of the counter.

18:34.380 --> 18:37.040
Once again, all the official variants pass big crush.

18:37.100 --> 18:41.980
And this is the most common generator you'll see from random 1, 2, 3 by far.

18:43.440 --> 18:48.640
We're going to discuss PHYLOX 4 by 32, 10 specifically in more detail.

18:48.640 --> 18:53.000
You can actually see PHYLOX, the implementation there.

18:53.000 --> 18:59.020
I know it might be a little grainy, but yeah, that's the main loop of PHYLOX.

19:00.460 --> 19:07.240
So this wonderful little graph is my mock-up of how PHYLOX works.

19:07.820 --> 19:11.940
So C0, 1, 2, 3, that's our state.

19:12.680 --> 19:18.360
It's essentially just, in this case, a 128-bit word broken up into four limbs.

19:19.820 --> 19:26.180
Those of you familiar with PHYSTL networks will see that we're swapping C0 and C2 in the very PHYSTL pattern.

19:27.400 --> 19:30.580
And then C1 and C3 are substituted.

19:30.860 --> 19:36.020
In this case, operations take place over the ring Z2 to the 32Z.

19:36.520 --> 19:39.320
And it's multiplied with a unitary value.

19:39.380 --> 19:42.040
So you get a uniform output.

19:42.040 --> 19:44.860
It's infuriating, actually, to try and break this.

19:46.700 --> 19:50.760
But then with our triangles, that's where things kind of deviate.

19:51.080 --> 19:55.580
You have the mull-low operation, which is A times B mod 2 to 32.

19:55.580 --> 19:58.680
You take the low bits of the 64-bit word that's produced.

19:58.920 --> 20:01.740
And then mull-high, which is A times B right shift 32.

20:01.740 --> 20:03.660
It's just the high bits of the same operation.

20:03.980 --> 20:07.860
So with the triangles pointed up, that is a mull-high operation.

20:07.860 --> 20:09.880
With the triangles pointed down, that's a mull-low.

20:09.980 --> 20:13.900
And then you see the KSL, KSR, that is the key schedule.

20:13.900 --> 20:15.760
It's just an affine transformation.

20:16.660 --> 20:18.780
It's a very simple key schedule.

20:19.060 --> 20:24.060
If there are weaknesses that can be broken, it probably has to do with that.

20:26.520 --> 20:30.140
So we are going to move forward into flaws in detection.

20:31.380 --> 20:33.660
There is currently no differentiator for this.

20:33.660 --> 20:34.520
There's no way to tell.

20:34.520 --> 20:35.820
It's not uniformly random.

20:35.820 --> 20:36.740
There is no break.

20:36.900 --> 20:39.020
But this doesn't mean it's safe.

20:39.020 --> 20:42.680
Once again, this has not been formally cryptanalyzed by anyone, at least to my knowledge.

20:42.680 --> 20:45.100
This hasn't been studied.

20:45.100 --> 20:49.580
There's no claims of security from the manufacturer and the designers.

20:49.940 --> 20:53.100
So it is best to just avoid it in security sensitive context.

20:53.100 --> 20:54.120
Use something trusted.

20:54.120 --> 20:58.200
However, for your general randomness needs other than that, it's phenomenal.

21:00.280 --> 21:03.400
So we are now moving into the second part of the talk.

21:03.400 --> 21:05.000
And things get a little more complicated here.

21:05.000 --> 21:08.880
This is where we are talking about secure PRNGs or CSPRNGs.

21:08.880 --> 21:10.180
And this has to go be special.

21:10.180 --> 21:11.840
They call them DRBGs.

21:13.700 --> 21:19.220
These give us usually high quality pseudo randomness with additional hardness assertions.

21:19.220 --> 21:24.700
So basically what we typically do is we are willing to sacrifice speed in order to gain some kind of cryptographic hardness assertion.

21:24.740 --> 21:30.240
Because this is the backbone of the modern cryptographic stack.

21:30.840 --> 21:39.280
So all these algorithms are explicitly designed to be hard to invert or otherwise predict in order to keep that promise of end bit security that we talked about earlier.

21:39.560 --> 21:43.660
As we can see, my meme straight out of like 2018 up there.

21:44.540 --> 21:52.880
And then on the other side, we have the description of basically how Linux has worked since 2020.

21:53.180 --> 21:58.600
Where it will take system entropy, the other thing we talked about earlier, and feed it into cha-cha 20.

21:59.080 --> 22:03.600
And historically, and that becomes dev urandom and dev random.

22:03.600 --> 22:06.960
Historically they had different behavior and they would just output system entropy.

22:06.960 --> 22:12.400
But that had a lot of issues where you could either cause a DOS or you could get predictable random numbers.

22:12.400 --> 22:17.120
It just was a bad time, so they swapped over to just cha-cha 20, which is an example of a CSPRNG.

22:18.780 --> 22:20.660
We're going to talk about stream ciphers.

22:21.520 --> 22:22.540
Real quick.

22:22.540 --> 22:34.100
So these, it's a little weird seeing like symmetric crypto in a talk, but it's because basically all stream cipher is, is a cryptographically hard random number generator that you XOR the output of with your plain text.

22:34.100 --> 22:37.520
If we just ignore the plain text part of it, ta-da, we have a CSPRNG.

22:38.440 --> 22:41.860
We just use the key stream as a pseudo random number.

22:41.960 --> 22:50.940
If the key stream is predictable, the data isn't secure, so if you believe in stream ciphers, you believe in using them as CSPRNGs, the good news, they're usually really fast.

22:51.320 --> 22:57.060
Some examples of this are cha-cha 20, RC4, and Rabbit, which was from the E-stream competition.

22:58.480 --> 23:01.320
We're going to talk about cha-cha 20 and RC4.

23:02.720 --> 23:05.980
RC4 is a great example of what not to do.

23:07.080 --> 23:09.820
So it comes from RSA security.

23:10.060 --> 23:14.480
It's Revest cipher 4 or Ron's code 4, depending on who you ask.

23:14.480 --> 23:16.940
There's been a lot of issues found with this cipher.

23:17.540 --> 23:20.460
There's the second bit bias, which is what we're going to be talking about today.

23:20.460 --> 23:22.220
There's been some key schedule weaknesses.

23:22.460 --> 23:28.620
Historically it was used in TLS until it wasn't because people were breaking everything that had to do with it.

23:28.620 --> 23:31.980
It was specifically disallowed in RFC 7465.

23:31.980 --> 23:34.820
If you want to go read that, it is moderately entertaining.

23:36.620 --> 23:44.900
It's also historically been used as a CSPRNG in multiple systems, if I remember correctly, the BSD family used to use it as ARC4.

23:47.000 --> 23:50.220
But they no longer do that for reasons we're about to get into.

23:51.140 --> 23:53.700
So as I mentioned, we're talking about the second byte bias.

23:53.700 --> 23:56.680
Here is the initialization step of RC4.

23:56.680 --> 23:58.840
We have two pointers, I, J.

23:59.120 --> 24:01.200
And we have a generation loop.

24:01.200 --> 24:08.320
So some preliminary before this is we have some arbitrary size state S, which is just an array of numbers.

24:08.320 --> 24:11.820
It's a permutation, rather, of the list of N numbers.

24:12.440 --> 24:18.300
So you increment your pointer I, then J is added with S sub I.

24:18.680 --> 24:27.460
And then you swap the values and output Z as the index of S that S of I plus S of J is at.

24:28.480 --> 24:34.940
Pretty simple cipher, which is what made it kind of attractive for a lot of people when it first came out.

24:37.880 --> 24:42.640
But as with all good things, this thing did not work out well for us.

24:42.740 --> 24:49.300
So usually when we do statistical testing and the stuff I've discussed thus far, it's with statistical test suites.

24:50.980 --> 25:01.200
This passes pretty well for those, because what they do is they take large quantities of numbers over a very long period of time, and they perform tests on that.

25:01.620 --> 25:12.840
So what we're now going to talk about is polynomial sampling, which basically says if we have a whole bunch of streams and we're just looking at the early parts, can we distinguish this from true random quickly in polynomial time?

25:13.320 --> 25:14.740
The answer is yes.

25:14.740 --> 25:17.000
We can do it with greater than a 60% success rate.

25:17.000 --> 25:18.660
If I remember correctly, it's about 64.

25:18.660 --> 25:34.180
And what this is, is with RC4, there is a non-trivial increase in the probability the second byte will be zero, which is a statistical distinguisher, which is not good for random numbers.

25:35.940 --> 25:39.960
So some of you might be thinking, okay, can we mitigate that?

25:39.960 --> 25:41.080
It's just the second number.

25:41.080 --> 25:42.120
The answer is yes.

25:42.120 --> 25:42.980
Yes, you absolutely can.

25:42.980 --> 25:46.160
You can just not output and skip a little bit, and you're good.

25:46.700 --> 25:50.900
The real question becomes, should we use a mitigated version of a flawed cipher?

25:50.900 --> 25:56.340
And the answer, at least in my opinion, is no, because usually where you find one issue, others follow.

25:56.340 --> 25:58.220
That's the basis of cryptanalysis.

25:58.220 --> 26:02.980
It's usually a very long trail where you find something and then a whole bunch of issues follow.

26:03.320 --> 26:04.820
So what should you use?

26:04.820 --> 26:10.560
Sorry, we have another demo of actually detecting the bias in RC4 and showcasing it.

26:10.860 --> 26:16.700
So once again, I wrote this on a much more potent computer, so it's going to take a second.

26:17.440 --> 26:18.880
There we go.

26:18.900 --> 26:23.900
So as you can see, that zero value is spiked well above the expected.

26:24.280 --> 26:25.620
Well above the expected.

26:25.960 --> 26:31.940
Which lines up with the second bias you would expect from the formal analysis.

26:33.260 --> 26:36.020
We did 100,000 streams there.

26:38.660 --> 26:40.020
All right.

26:40.020 --> 26:42.680
So now we're talking about ChaCha20.

26:42.680 --> 26:44.200
This is more of an aside.

26:44.200 --> 26:59.800
It is a very modern arc space cypher, which is and rotates or, developed by Daniel Bernstein to succeed his other cypher.

26:59.920 --> 27:03.540
It has a strong emphasis on side channel resistance.

27:04.540 --> 27:08.920
Best public cryptanalysis, as far as I know, is up to 7 out of 20 rounds.

27:08.920 --> 27:11.080
And it is used in TLS.

27:11.080 --> 27:13.780
Once again, it's used in Linux's DevUrandom, DevRandom.

27:14.200 --> 27:16.740
It's all around a better choice than RC4.

27:18.140 --> 27:19.020
Okay.

27:19.040 --> 27:23.180
So now we're on to our next variant, which are block cyphers in counter mode.

27:24.220 --> 27:35.760
This is a mode of operation for block cyphers where you're given a counter as your plain text instead of your actual data you're trying to encrypt and the output becomes zored with the actual plain text to create the cypher text.

27:35.760 --> 27:38.500
It makes it behave very similarly to a stream cypher.

27:39.140 --> 27:42.720
This also inspired the counter base PRNGs we discussed earlier.

27:42.720 --> 27:50.880
You can quite see it very directly with 3Fry and ours, which very much literally use the routines of 3Fish and AES.

27:51.900 --> 27:55.260
But the big difference here is we're actually using the full blown variants.

27:55.260 --> 27:56.620
So we're using secure primitives.

27:56.620 --> 27:58.080
There are hardness assertions.

27:58.080 --> 28:01.850
There you can see a lovely diagram showcasing counter mode.

28:04.300 --> 28:08.920
Now we're going to start talking a little bit about the NIST generators.

28:09.790 --> 28:11.750
NIST SP890 alpha.

28:13.100 --> 28:18.860
And it discusses all the approved CSPRNGs for use.

28:18.860 --> 28:21.440
And they have a generator of this form.

28:21.720 --> 28:23.920
It is called counter DRBG.

28:23.920 --> 28:24.930
Very creative.

28:25.920 --> 28:35.880
And it officially supports AES 128, 192, 256, and still triple DES, which they try to hide as 3DEA.

28:36.280 --> 28:37.550
Good job, NIST.

28:40.480 --> 28:44.780
So it can really, it really boils down to it's just counter mode.

28:44.780 --> 28:47.520
You just get some additional opportunities to inject entropy.

28:47.560 --> 28:51.280
And technically the framework itself works for any block cipher.

28:51.280 --> 28:55.380
But it's NIST, so they just support the official U.S.

28:55.380 --> 28:56.300
ones.

28:56.980 --> 29:00.080
So counter DRBG is practically secure.

29:00.080 --> 29:01.680
There are no practical breaks on it.

29:01.680 --> 29:08.380
However, there are academic breaks, which means there are theoretical breaks that mathematically work.

29:08.380 --> 29:13.000
They just are impractical to do in a specific amount of, in a feasible amount of time.

29:13.740 --> 29:17.640
It's really only a problem with triple DES, because of course it is.

29:17.640 --> 29:18.800
It's triple DES.

29:19.140 --> 29:24.600
Because of that really small block size, but it's really not an issue when you use AES, which is what you should be doing.

29:27.280 --> 29:42.410
As far as these forms of generators, Bruce Schneier and Ferguson developed one called Fortuna, which is what the BSD family now uses, which is typically considered a superior example to the NIST generator, but NIST is going to NIST.

29:43.820 --> 29:48.880
Now on to yet another NIST generator, hash-based CSPRNGs.

29:48.880 --> 29:52.840
These use the outputs of hash functions as random numbers.

29:52.840 --> 29:56.230
Up there we can literally see NIST's hash DRBG diagram.

29:58.060 --> 29:59.780
These aren't too common.

29:59.780 --> 30:01.140
You don't really see these that often.

30:01.140 --> 30:04.400
But they are of interest with the standardization of SHA-3.

30:04.400 --> 30:07.640
So SHA-3 uses a sponge construction.

30:08.220 --> 30:14.640
Which has now two proofs of indifferentiability from random oracle with very minimal assumptions.

30:15.180 --> 30:26.520
So what this means is that this, in theory, might be one of our best generators for random numbers, not performance-wise, but statistic quality and mathematically.

30:28.820 --> 30:33.280
So it's of note, and I'm really curious to see how that's going to shake out.

30:33.280 --> 30:37.220
There hasn't really been too much study on specifically this construction with SHA-3 yet.

30:37.220 --> 30:39.060
The NIST publication is quite old.

30:39.060 --> 30:42.240
So they only discuss SHA-2 and Merkle-Domgarde constructions.

30:43.600 --> 30:45.680
So we'll see how that goes.

30:47.740 --> 30:49.700
So these are also secure.

30:49.700 --> 30:54.140
There's not really any attacks that apply to them that are specific to this generator.

30:54.140 --> 31:00.220
It's just the usual stuff with Merkle-Domgarde constructions, your length extension attacks, all the usual shenaniganry.

31:00.760 --> 31:04.340
But they're usually not used too often because of speed.

31:04.340 --> 31:11.820
There's not really a good way, other than statistical testing, to assert their quality, their goodness as generators.

31:12.100 --> 31:24.260
But once again, since SHA-3 has been proven indifferentiable in both the classic and the quantum context as of like a month and a half ago, it's going to be really interesting to see how this develops.

31:25.980 --> 31:27.260
So, all right.

31:28.280 --> 31:32.880
We are on our last category here, which are number-theoretic generators.

31:32.880 --> 31:34.000
Now, this is...

31:35.260 --> 31:37.940
Nobody uses these for a very good reason.

31:37.940 --> 31:39.680
They're incredibly slow.

31:40.380 --> 31:42.420
But they are very interesting.

31:42.420 --> 31:44.940
So we have some examples here.

31:44.940 --> 31:48.460
We have BlumBlumShub, DuallyCDRBG, and the Blum and Cayley generator.

31:49.060 --> 31:57.600
And these get their hardness based on usually problems from number theory, similarly to how we do our asymmetric cryptography.

31:58.120 --> 32:00.680
So, as you can see, graduate techs in mathematics.

32:00.680 --> 32:02.320
Or, sorry, didn't graduate techs in mathematics.

32:02.320 --> 32:03.780
Introduction to that thing.

32:03.820 --> 32:05.260
But only for people who already know it.

32:05.260 --> 32:06.960
So that's kind of the tone we're taking here.

32:07.400 --> 32:11.280
Because I am not doing a lecture in abstract algebra.

32:11.280 --> 32:15.000
But we're going to start moving.

32:15.000 --> 32:18.400
So we're going to talk about BlumBlumShub and DuallyCDRBG.

32:18.400 --> 32:18.900
I know.

32:18.900 --> 32:19.760
Shocking.

32:20.900 --> 32:23.820
Yes, this algorithm is really named BlumBlumShub.

32:24.260 --> 32:27.180
It is very funny, but that is really what it's named.

32:28.060 --> 32:34.480
So this is based on the hardness, or the presumed hardness, rather, of the quadratic residuosity problem, or the QRP.

32:34.620 --> 32:50.920
It is, once again, a recurrence, x of n plus 1 equals x of n squared modulo n, where n is a large semi-prime comprised of two prime factors known as Blum primes, which just means that they are equivalent mod 4 to 3.

32:51.760 --> 32:56.120
So typically with this generator, for all this work, you get one bit of output.

32:56.120 --> 33:07.320
It's called a hardcore predicate, which is just a generic function that takes an n-length bit string and maps it to one bit in a matter such that it's hard to reverse or gain information about the original bit string.

33:09.720 --> 33:15.540
So I said I wasn't going to give too much of a lecture, but it's kind of necessary for these.

33:16.880 --> 33:27.240
So we're going to talk about the underlying problem of this, which is a quadratic residuosity problem, which is given a large semi-prime, just any semi-prime n, with large prime factors PQ.

33:27.240 --> 33:33.460
Consider the multiplicative group z sub n star.

33:34.080 --> 33:38.940
Half of the elements will have an r such that x is equivalent to r squared modulo n.

33:38.940 --> 33:41.210
The other half of the elements may have such an element.

33:42.640 --> 33:45.080
Determining if they do is presumed hard.

33:47.320 --> 33:56.400
So knowing the quadratic residuosity problem and the relation of blum-blum-shub, we're going to relate it to how BBS actually works.

33:56.400 --> 34:06.440
So given P is equivalent to Q is equivalent to 3 modulo 4, any given quadratic residue will have four square roots, exactly one of which is also a quadratic residue.

34:06.440 --> 34:09.960
This comes from Blum's original paper.

34:10.500 --> 34:16.760
Given a quadratic residue x, we are tasked to find the parity bit of the root of x that is also a quadratic residue.

34:16.760 --> 34:23.600
So even if you're able to solve for the roots, you must determine which one is the quadratic residue, which is precisely the quadratic residuosity problem.

34:23.600 --> 34:25.840
It's a very clean construction.

34:27.420 --> 34:40.940
If you believe me on this, once you get to this point, then you get hardness can be shown to be equivalent to factoring, sorry, which should relate it more to RSA for those that are a bit like, what's going on here?

34:42.180 --> 34:44.520
So, all right.

34:45.300 --> 34:48.660
Here is our last thing.

34:48.780 --> 34:50.200
This is the big one.

34:50.540 --> 34:52.540
Dual elliptic curve DRBG.

34:52.620 --> 34:55.420
A show of hands, who has heard of this one?

34:56.260 --> 34:57.040
Okay.

34:57.060 --> 34:57.880
Good.

34:58.400 --> 35:01.620
So some fun facts about dualistic DRBG.

35:01.620 --> 35:02.960
It was developed by the NSA.

35:03.740 --> 35:06.280
And it features something called the kleptographic backdoor.

35:07.660 --> 35:12.300
So remember that whole thing earlier where I said, the whole cryptographic stack?

35:12.300 --> 35:14.500
Yeah, the NSA went straight for the source.

35:14.540 --> 35:16.580
Because people don't usually look at these.

35:16.580 --> 35:19.500
Ciphers and asymmetric systems are much flashier.

35:19.620 --> 35:23.000
But these are what make all of those tick.

35:24.660 --> 35:30.000
This primarily is a great lesson on nothing up my sleeve numbers.

35:30.020 --> 35:34.520
Which basically says, if you have a random number in there, you should explain it in some way.

35:34.520 --> 35:39.420
It should be derivable from some publicly known constant or explainable in some way.

35:39.420 --> 35:44.920
Not just, I took a hash of this random string of values and it gave me that and I'm gonna use that now.

35:44.920 --> 35:45.740
That's bad.

35:45.920 --> 35:48.640
And that's exactly what dualistic DRBG did.

35:48.640 --> 35:51.000
To justify their use of the random numbers.

35:52.060 --> 35:56.440
So this one we're actually gonna walk through because it's important and it's pretty interesting.

35:57.640 --> 36:05.780
So let E be an elliptic curve of the form Y squared equals X cubed minus 3X plus B over a field of prime characteristic P.

36:05.900 --> 36:07.840
Basic elliptic curve definitions.

36:07.840 --> 36:11.020
We're gonna define two base points P and Q on the curve.

36:11.320 --> 36:14.360
And then here's all the functions of dually C.

36:14.360 --> 36:18.120
We have one that just extracts the X coordinate in affine coordinates.

36:18.600 --> 36:22.340
We have a truncation function that truncates N bits.

36:22.600 --> 36:25.280
Specifically the most significant bits of the generator.

36:26.220 --> 36:33.720
We have G sub P of X which just pulls the affine X coordinate of scalar multiplication of X and P.

36:33.720 --> 36:41.300
And we have G sub Q of X which truncates the affine output of scalar multiplication of X on Q.

36:42.740 --> 36:44.160
A little bit of a mouthful.

36:44.880 --> 36:54.060
By the standard, it additionally mandated use of one of the NIST curves if you wanted to get your FIPS certification and you had to use the specified base points P and Q.

36:54.060 --> 36:54.920
Had to, had to, had to.

36:54.920 --> 36:56.720
Otherwise you're not gonna get your certification.

36:57.340 --> 37:02.660
Notably it also mandates that you can only truncate 16 or 17.

37:02.660 --> 37:04.280
They give you some ambiguity there.

37:05.200 --> 37:06.340
Thanks, NIST.

37:08.720 --> 37:10.760
You have to truncate 16 or 17 bits.

37:10.760 --> 37:13.280
Once again, if you want that certification, which is essential.

37:16.040 --> 37:24.620
So the way dually CDRBG works, it makes some weird assumptions in order to get its security assertions.

37:24.620 --> 37:27.720
None of them are too typical other than elliptic curve decisional Diffie-Hellman.

37:28.140 --> 37:31.600
But we're not gonna go too deep into that.

37:31.600 --> 37:34.760
We're gonna talk about how the algorithm actually works.

37:34.760 --> 37:40.120
So we're gonna select a seed F, or sorry, S in Fs of P randomly.

37:40.620 --> 37:45.660
We're going to perform V is Gs of P of S to establish the first state.

37:45.660 --> 37:51.300
Remember Gs of P is the affine coordinate of scalar multiplication X on P.

37:52.360 --> 37:54.720
Then we are going, that becomes our first state.

37:54.720 --> 37:58.060
We're going to output a value by calling Gs of Q of V.

37:58.060 --> 38:01.500
So we're just gonna multiply state against our other point Q.

38:01.600 --> 38:05.720
Pull out the affine coordinate, truncate 16 bits, and that's your output.

38:06.240 --> 38:08.480
And then you just repeat.

38:10.620 --> 38:17.980
There you can see the outputs of elliptic scale multiplication on elliptic curve, and it looks quite chaotic.

38:18.180 --> 38:22.880
So that was the whole idea behind why it would make a good random number generator.

38:22.880 --> 38:24.720
Ironically, it really doesn't.

38:24.840 --> 38:30.360
But let's start talking about the trick for dually CDRBG.

38:30.360 --> 38:32.920
This is where things get a little interesting.

38:32.920 --> 38:36.860
So NIST curves all have a cofactor of 1, which means all the points are in the same group.

38:38.260 --> 38:44.060
So it's guaranteed there's some scalar value S, such that S times Q is equal to P.

38:45.360 --> 39:03.700
So if we are given a single output, so like a nonce or IV, you know, not to upset the English out there, and the base point that it was derived from A, which is once again public information, there must exist some scalar R such that A is equivalent to RQ.

39:05.100 --> 39:07.640
So we are going to set up our little equations here.

39:07.640 --> 39:13.000
We have SA equals SRQ because A is equal to RQ.

39:13.060 --> 39:18.640
We set SRQ is equal to RP because SQ is equal to P.

39:19.020 --> 39:20.480
And that's it.

39:20.480 --> 39:23.100
You've just backdoored the entire cryptographic stack.

39:23.580 --> 39:28.200
You're going to get the next state, so you're not going to get the exact state that it happened on.

39:29.040 --> 39:30.320
But you're going to get the next value.

39:30.320 --> 39:36.620
So say we do something like you generate an IV that's public.

39:38.180 --> 39:39.920
Now the NSA has a state.

39:40.040 --> 39:42.000
They're just going to dump it to their cluster farm.

39:42.000 --> 39:45.780
They're going to guess those 16 bits because that's trivial to do.

39:46.440 --> 39:49.120
And they are now backdoored everything.

39:49.120 --> 39:51.300
So sorry, I got a little ahead of myself.

39:51.440 --> 39:53.600
Since T is truncated, finding A is hard, right?

39:53.880 --> 39:55.380
No, it's 16 bits.

39:55.520 --> 39:58.680
So you just guess it, see if the X coordinate is out on the curve equation.

39:58.680 --> 40:00.740
Just use Tonelli-Shanks.

40:00.740 --> 40:04.000
Because remember, we're over a prime characteristic field.

40:04.000 --> 40:05.520
And you have your Y coordinate.

40:07.620 --> 40:12.100
So had this entered more common use, it would have broken everything.

40:12.440 --> 40:17.660
Thankfully, some people went a little ballistic about it.

40:17.660 --> 40:19.840
I remember there's Bruce Schneier.

40:19.840 --> 40:23.240
There's a quote saying that the backdoor was quite obvious.

40:23.960 --> 40:25.380
Okay, Bruce.

40:28.020 --> 40:33.880
The mechanism of why this was allowed to work is, once again, the unexplained points P and Q, right?

40:33.880 --> 40:41.920
It's this lack of explanation, these numbers that come from nowhere that enable these kinds of backdoors to exist.

40:42.480 --> 40:45.480
And back then, people really weren't auditing that kind of stuff.

40:45.480 --> 40:46.960
They trusted NIST.

40:47.600 --> 40:49.660
And this showed that that was a big mistake.

40:49.660 --> 40:58.300
Because the NSA had just hijacked and worked their way into NIST, pushed this through, and a lot of people were kind of confused about it.

40:58.300 --> 40:59.560
Because it wasn't a particularly good generator.

40:59.560 --> 41:00.960
It wasn't super performant.

41:01.160 --> 41:02.520
It had statistical issues.

41:02.520 --> 41:04.200
And yet, it still got pushed through.

41:06.740 --> 41:09.040
Now, hats off to the NSA.

41:09.380 --> 41:14.700
Finding their secret little backdoor value, that scaler that connects Q and P, is hard.

41:14.700 --> 41:15.900
It's the discrete log.

41:15.900 --> 41:18.060
So good luck finding it.

41:18.060 --> 41:20.060
Nobody's found it to date, as far as I know.

41:21.160 --> 41:25.280
But yeah, the fact that it still works is not great.

41:25.300 --> 41:28.400
It was part of Operation Bull Run or Project Bull Run.

41:30.520 --> 41:33.940
So we ended a little earlier than I intended.

41:33.940 --> 41:35.880
So I guess we're just gonna do Q and A.

41:36.180 --> 41:40.100
As far as all the sources for this, I wrote a paper.

41:40.100 --> 41:43.920
It's on GitHub, as well as implemented every generator I discussed here.

41:43.920 --> 41:44.920
It's on Python 3.

41:45.020 --> 41:48.400
So it should be easy to interpret and understand.

41:48.980 --> 41:50.420
Everything's annotated.

41:51.300 --> 41:56.700
Unfortunately, the repo is private, because the internet was uncooperative.

41:56.700 --> 41:59.160
But I will rectify that as quickly as possible.

42:00.980 --> 42:03.880
So yeah, I guess we'll move into Q and A a little early.

42:03.880 --> 42:08.420
I will also be at the CPV from 2 to 4.30 today.

42:08.420 --> 42:12.840
So right after the talk, I'm gonna head down there, and I'll be there until 4.30 volunteering.

42:13.680 --> 42:16.600
Otherwise, you can email me there.

42:17.560 --> 42:20.320
That is subscribed to a bunch of GCC mailing lists.

42:20.320 --> 42:26.960
If I don't respond, just bump it up in my inbox, and I will eventually see it amidst the swarm.

42:38.780 --> 42:41.460
Yeah, yeah, they're gonna go up on GitHub.

42:52.600 --> 42:59.260
Sort of, I'm not familiar with the direct relationship beyond the class.

42:59.260 --> 43:00.400
They're both presumed hard.

43:01.140 --> 43:10.660
The fact that QRP can be shown, at least with this construction, can be shown to be equivalent to factoring does imply that the relationship is there.

43:17.400 --> 43:19.280
It's... good question, actually.

43:19.280 --> 43:21.780
I don't... no.

43:21.780 --> 43:24.260
No, it's not proven to be hard.

43:24.260 --> 43:25.380
It's presumed hard.

43:31.520 --> 43:34.180
Oh, boy, I'll do my best.

43:34.180 --> 43:39.700
Blum-blum-shub, blum-blum-shub, blum-blum-shub, blum-blum-shub, blum-blum-shub, blum-blum-shub, blub-blum-shub, blub-blub-shub, blub-blub-shub.

43:39.700 --> 43:41.020
Oh, yeah, messed it up.

43:41.020 --> 43:41.540
All right.

43:50.770 --> 43:51.730
Thank you.

44:16.730 --> 44:22.430
So technically, yes, you can just hash whatever, presuming your hash function is good.

44:23.390 --> 44:25.550
And presuming it's once again salted, as you said.

44:25.930 --> 44:28.770
The issue with that is you're gonna lose a lot of performance.

44:29.510 --> 44:31.390
Hash functions are not super quick.

44:33.370 --> 44:39.150
So yeah, you could totally do that, but you're gonna get a pretty severe performance penalty.

44:40.490 --> 44:45.850
There are much better ways of doing it, but I understand why you're asking it from our talk yesterday, so...

44:51.540 --> 44:52.600
No, you're all good, dude.

45:03.260 --> 45:05.400
Yep, finite field of prime characteristic.

45:09.340 --> 45:13.460
It's just a NIST curve, so it's like the secp256, like, you can...

45:15.240 --> 45:16.560
On B?

45:17.320 --> 45:18.140
There is.

45:18.140 --> 45:18.620
There is.

45:18.620 --> 45:20.980
It's just a general description of the NIST curves.

45:21.160 --> 45:42.020
So if you go to the revoked version of SP890 alpha, you can actually see a specification precisely for dually CDRBG, and then you can go check the NIST specifications for their elliptic curves, and you can see exactly what parameters you would have used to actually implement dually CDRBG.

45:48.440 --> 45:49.720
All right.

45:50.280 --> 45:51.780
You have one more?

45:57.400 --> 45:58.340
Yeah, yeah.

45:58.340 --> 46:04.800
So a period with a pseudorandom number generator is essentially the length of values you'll get before it starts to repeat itself.

46:05.040 --> 46:05.460
Yep.

46:05.460 --> 46:11.280
So you really... a large period is very desirable in these generators.

46:11.280 --> 46:17.720
Commerce and Twister goes a little extreme with that, but yeah, it's a very desirable trade.

46:34.340 --> 46:46.300
So I don't know the specifics of that hash function, but if it is a good hash function, meaning it is pre-image resistant and collision resistant, then it should be good enough to use as a CSPRNG.

46:50.440 --> 46:51.360
Oh, okay.

46:51.360 --> 46:53.160
No, I am familiar, actually.

46:53.160 --> 46:56.540
So it's the... that was the winner of the NIST lightweight standard.

46:56.540 --> 46:57.960
Yeah, you're fine with that.

46:57.960 --> 46:59.520
It's built on the sponge construction.

46:59.520 --> 47:00.520
It's been tested.

47:00.660 --> 47:01.580
Good to go.

47:08.100 --> 47:15.780
So, yes, I did a class on cryptography as an undergrad.

47:15.780 --> 47:17.480
It was a grad level class.

47:18.140 --> 47:20.400
That's where I got really interested in it.

47:21.340 --> 47:23.060
And I've just kind of kept going.

47:23.060 --> 47:28.440
But I would definitely say if you want to advance in this field, most of it is in academia.

47:30.420 --> 47:32.280
Both fortunately and unfortunately.

47:32.880 --> 47:41.100
So, yes, I would definitely recommend if you want to go be a professional cryptographer, at least on the theory side of the house, definitely go to school.

47:42.120 --> 47:43.040
What's up?

47:46.940 --> 47:48.740
You know, UNLV, shout out.

47:50.420 --> 47:52.400
Let's see, good crypto programs.

47:52.640 --> 47:55.060
Stanford, they got Bono over there .

47:55.060 --> 47:57.020
They got UChicago.

47:57.020 --> 47:58.400
That's where Bernstein's at.

47:58.400 --> 47:59.140
What's up?

47:59.920 --> 48:00.760
Yeah, CMU.

48:00.760 --> 48:02.900
They have a good crypto program.

48:02.920 --> 48:04.940
Basically, it's who you'd expect.

48:12.050 --> 48:15.790
Definitely as of right now, far more on the computer science aspect of it.

48:16.410 --> 48:21.430
I work with the math, but I am not like a mathematician formally.

48:21.430 --> 48:22.370
So not even close.

48:22.370 --> 48:27.630
Like I had an algebraic geometer come up to me yesterday, and he was talking about pairing based cryptography.

48:27.630 --> 48:32.650
And I could keep up for like, I don't know, we didn't even share names.

48:32.650 --> 48:34.510
He just went straight to the point.

48:35.670 --> 48:37.810
And I was like, what, like two minutes were good?

48:37.810 --> 48:40.570
And then after that, I'm like, okay, whoa, back up.

48:40.570 --> 48:41.530
I know how to do it.

48:41.530 --> 48:43.790
I don't know what's going on behind that.

49:03.230 --> 49:04.030
Yep.

49:05.930 --> 49:14.510
So that actually brings me to a point that actually got cut, because in my practice runs of the talk, it took the full 50 minutes that they were like, you should use.

49:15.270 --> 49:16.370
Discussion of quantum.

49:16.370 --> 49:20.290
The reason, so first of all, I'll discuss the implications of quantum for this.

49:20.290 --> 49:22.230
It only breaks our number theoretic generators.

49:22.230 --> 49:23.030
Everything else is fine.

49:23.190 --> 49:24.530
As far as we know.

49:25.190 --> 49:28.030
So yeah, the ones that nobody uses are broken.

49:28.110 --> 49:28.690
Great.

49:29.910 --> 49:42.510
But so the application of quantum randomness is the whole idea is that is the, depending on, once again, your interpretation of physics, that is the source of randomness.

49:42.570 --> 49:46.030
And so it is as good of random as you're actually going to get.

49:46.790 --> 49:59.070
Downside is it's super expensive and there's no practical reason to spend that much compute just to get a random number when we already have a ton of systems that are very well equipped to do it for you much more cheaply.

49:59.070 --> 50:05.750
It is interesting, at least in my opinion, in the academic sense exclusively.

50:11.080 --> 50:12.280
Yeah, TRNGs.

50:19.290 --> 50:22.770
So TRNGs are great.

50:22.770 --> 50:24.990
If you can go get one, get one.

50:25.470 --> 50:27.730
But they're not super common.

50:27.730 --> 50:29.650
There's a website, I forget what it's called.

50:29.690 --> 50:32.470
It's got some horrible name, actually.

50:32.690 --> 50:36.990
But it's a guide on how to build your own true random number generator at home.

50:37.130 --> 50:43.170
If for the extra paranoid, because that's usually who buys true random number generator, so hardware RNGs.

50:44.390 --> 50:46.970
Because you never know if the one on Amazon's backdoored.

50:48.170 --> 50:52.090
But yeah, I would say get one.

50:52.090 --> 50:56.170
They're useful, especially if you have concerns about system entropy.

50:56.170 --> 51:00.930
But realistically, it's probably just a good fallback.

51:01.170 --> 51:08.430
Because system entropy, as we discussed, especially are you on Linux or Windows or Mac?

51:08.430 --> 51:08.670
Okay.

51:08.670 --> 51:11.370
I actually don't know what OSX uses.

51:12.910 --> 51:15.030
No clue what OSX uses.

51:15.030 --> 51:22.550
I would presume they're either copying some of the BSD stuff or Linux.

51:22.550 --> 51:29.800
So yeah, it should be okay.

51:29.800 --> 51:33.200
I mean, Apple's usually pretty on top of that stuff.

51:33.200 --> 51:35.140
So I'd just buy it as a backup.

51:35.140 --> 51:35.760
They're good to have.

51:35.760 --> 51:36.380
They're cool.

51:36.380 --> 51:39.680
But I wouldn't be super concerned if you don't have one.

51:48.650 --> 51:52.790
Oh, I don't know specifically about that chip.

51:57.890 --> 51:58.730
Oh, okay.

51:58.730 --> 51:59.630
You work with them.

52:01.090 --> 52:01.870
Okay.

52:07.070 --> 52:10.790
Yeah, so cha-cha is actually great on ARM.

52:10.950 --> 52:22.510
Because specifically you don't have to deal like the most other, the common one is people do weird stuff like, oh, we're just going to use the ASNI instructions and that's my random number generator.

52:22.510 --> 52:23.130
Great.

52:23.150 --> 52:26.210
If you're not on x86, just get bent, I guess.

52:27.370 --> 52:29.730
But cha-cha is really good for that.

52:29.730 --> 52:34.890
I can't speak to the efficacy of the ARM architectures, TRNGs or any specific chips.

52:35.810 --> 52:46.230
It would be careful because there are a lot of LFSRs sliding around, especially in cheaper stuff, because they're just dirt simple and they're really easy.

52:46.330 --> 52:51.890
I know a lot of the, like, cheaper DMR radios all use LFSRs.

52:51.890 --> 52:54.690
It's not great, but...

52:59.710 --> 53:00.770
All right.

53:02.270 --> 53:03.510
Good to go.

53:09.790 --> 53:10.430
Yep.

53:10.430 --> 53:12.970
Just as a reminder, I'm going to be in the CPV until 430.

53:12.970 --> 53:20.190
So if you want to go ask a question in private or whatever it may be or you just want to talk crypto, I will be there for a few hours.

