Return to Video

Chaoskey_A_Hardware_Random_Number_Generator_for_Everyone.webm

  • 0:00 - 0:03
    Good morning everyone
  • 0:03 - 0:05
    Hopefully you're here for the
    same reason I am,
  • 0:05 - 0:08
    to drink coffee - I mean,
    to talk about random numbers.
  • 0:08 - 0:13
    This is not the first time that a talk
    about this particular project
  • 0:13 - 0:16
    has happened at DebConf, in fact
  • 0:16 - 0:20
    two years ago in Portland
    Tom Marble gave a talk
  • 0:20 - 0:27
    about the need for having good
    sources of entropy
  • 0:27 - 0:32
    and why it was that Keith and I had
    begun a project to build a good
  • 0:32 - 0:36
    high-quality hardware random
    number generator.
  • 0:36 - 0:40
    It so often happens in life we get a
    little distracted between then and now
  • 0:40 - 0:46
    but if we jump to the very end we're at
    the point where we have finally
  • 0:46 - 0:48
    got to a design that we really like
  • 0:48 - 0:53
    We're in the middle of an initial,
    significantly-sized production run
  • 0:53 - 0:57
    of the devices. Unfortunately best-laid
    plans and all that - we had hoped
  • 0:57 - 1:02
    to be here with the production units,
    and I guess at this point we're still two
  • 1:02 - 1:06
    or three weeks away from actually
    being through that first production run.
  • 1:06 - 1:10
    So we have a handful of devices we
    can show people today - we might even
  • 1:10 - 1:14
    try to demo before we're done - but we
    don't have huge quantities of them
  • 1:14 - 1:16
    to sell yet, which I'm sorry about.
  • 1:16 - 1:19
    It's a little unfortunate that that's how
    things have worked out.
  • 1:19 - 1:24
    So I guess the first thing I would say
    is if you want more
  • 1:24 - 1:28
    of a theoretical backround on the
    point of random numbers
  • 1:28 - 1:32
    and why they're important in
    our computing lives
  • 1:32 - 1:35
    I would recommend that you go back
    and find the video
  • 1:35 - 1:39
    of the talk that Tom Marble
    gave at DebConf in 2014.
  • 1:39 - 1:43
    We don't have the time or the inclination
    to try and repeat all of that today.
  • 1:43 - 1:47
    This is going to be much more about
    the actual thing that we've designed and built.
  • 1:47 - 1:51
    But I think a little bit of background
    is probably worthwhile.
  • 1:51 - 1:55
    The fundamental thing is that
    cryptographic security
  • 1:55 - 1:57
    really depends on a robust source of entropy.
  • 1:57 - 2:01
    This is because cryptographic security
    depends on our ability to
  • 2:01 - 2:05
    have keys that people can't trivially
    guess, and various other things.
  • 2:05 - 2:10
    Entropy is the notion of a source of
    randomness that can be
  • 2:10 - 2:14
    applied and taken advantage of
    in the rest of the system.
  • 2:14 - 2:19
    In Linux systems, our source of entropy
    is usually this pool
  • 2:19 - 2:24
    that's inside the kernel, and where it gets
    its entropy from varies.
  • 2:24 - 2:28
    But if you don't have some other
    explicit source of random numbers
  • 2:28 - 2:32
    on the system, it's coming from things
    like the timing of keystrokes
  • 2:32 - 2:37
    or disk operations and things like that
    which are reasonably random.
  • 2:37 - 2:42
    But it's unfortunately the case that most
    of the computers we have and use
  • 2:42 - 2:45
    don't have a robust hardware
    source of randomness.
  • 2:45 - 2:47
    Lots of other people have worked
    on this before -
  • 2:47 - 2:50
    some of the devices that I'm sure
    some of you in this room
  • 2:50 - 2:53
    have stumbled over are things
    like the Entropy Key.
  • 2:53 - 2:57
    That was a lovely device - I had one
  • 2:57 - 3:00
    - past tense, unfortunately, because
    like so many things
  • 3:00 - 3:02
    I don't have it any more - but I used to.
  • 3:02 - 3:06
    Unfortunately those are no longer available
    and the design wasn't open
  • 3:06 - 3:09
    so there's no straightforward way
    for us to duplicate that.
  • 3:09 - 3:13
    There are other products which
    are interesting and have
  • 3:13 - 3:17
    various characteristics which we
    think are really cool
  • 3:17 - 3:20
    but for one reason and another
    they're just not quite exactly what
  • 3:20 - 3:24
    we were looking for.
    So the goals we had were:
  • 3:24 - 3:29
    First and most importantly we wanted
    a source of truly random bits
  • 3:29 - 3:32
    and I'll talk a little about what that
    means and show you
  • 3:32 - 3:36
    some of our measurements to try and
    prove that we think we've done
  • 3:36 - 3:38
    the right thing there.
  • 3:38 - 3:41
    Keith and I also really wanted this
    to be automatically useable
  • 3:41 - 3:45
    in Linux systems.
    One of the things that the Entropy Key
  • 3:45 - 3:48
    developers did a great job of was
    ensuring that those of us in Debian
  • 3:48 - 3:53
    had easy access to packaged software
    that was in the distro and you can
  • 3:53 - 3:56
    just install the right package and you have
    the pieces you need to make it all work
  • 3:56 - 3:58
    and that was really cool.
  • 3:58 - 4:01
    But when we started thinking about
    the things that we wanted to guarantee
  • 4:01 - 4:06
    and didn't feel the need to guarantee,
    and where the trade-off was in our design,
  • 4:06 - 4:10
    actually making it so that the Linux kernel -
    the upstream kernel - could just
  • 4:10 - 4:14
    do the right thing when it discovered one
    of these devices is present
  • 4:14 - 4:18
    seemed like such a simpler deal, and
    something that would make it
  • 4:18 - 4:23
    much more likely that more people would
    be able to actually take advantage of this.
  • 4:23 - 4:26
    Because we are who we are, it must
    be a completely open
  • 4:26 - 4:29
    hardware and software design, and in fact
  • 4:29 - 4:32
    when we get to the end of the talk and
    you see where we define things,
  • 4:32 - 4:35
    the schematics, printed circuit board
    artwork, bill of materials,
  • 4:35 - 4:39
    complete source code tree, all that
    is available on our web site right now
  • 4:39 - 4:42
    and in fact it has been for a while.
  • 4:42 - 4:46
    We want the device to be secure
    against software hacks.
  • 4:46 - 4:51
    What does this mean?
    Well, what we've built is a physical
  • 4:51 - 4:55
    device which plugs into a USB port
    and it has a micro-controller
  • 4:55 - 4:57
    that has code running on it.
  • 4:57 - 5:02
    When we initially produce the device
    we flash that with code.
  • 5:02 - 5:05
    If you want to re-flash it later,
    you can do this any time you want
  • 5:05 - 5:07
    over USB, using a utility which is
    already packaged in Debian
  • 5:07 - 5:10
    but: you have to take the plastic
    cover off the box
  • 5:10 - 5:13
    and you have to short two holes
    in the board together
  • 5:13 - 5:15
    in order to enable reflashing.
  • 5:15 - 5:19
    So nobody can randomly spoof
    your device by from some distance
  • 5:19 - 5:21
    reflashing - you know, if they
    break into your system -
  • 5:21 - 5:25
    they can't just re-flash your random
    number generator with some other code.
  • 5:25 - 5:29
    I guess they could re-flash something else
    with your random number generator code
  • 5:29 - 5:32
    but that's all getting a little whacky.
  • 5:32 - 5:37
    Our device, at least, can't just be broken
    through an attack - a remote attack -
  • 5:37 - 5:38
    on the software.
  • 5:38 - 5:41
    And we want it to be as
    inexpensive as possible
  • 5:41 - 5:45
    because again this is all part of
    believing that the world needs more entropy
  • 5:45 - 5:49
    and we'd like lots of people to be
    able to afford to use these.
  • 5:49 - 5:54
    So this is one of those devices where,
    on some level, if you get it right you
  • 5:54 - 5:55
    could charge an arbitrary amount of money
  • 5:55 - 5:59
    because people who want this want it,
    but from our perspective
  • 5:59 - 6:03
    it's really important to have these
    be as widely available as possible.
  • 6:03 - 6:07
    The one really big decision we made
    - and it goes into our thoughts
  • 6:07 - 6:10
    on open hardware - is that we
    are not trying to protect
  • 6:10 - 6:13
    and make this secure against
    hardware attacks.
  • 6:13 - 6:16
    Fundamentally, if someone has
    physical access to your device
  • 6:16 - 6:19
    we're not guaranteeing what
    happens after that.
  • 6:19 - 6:21
    In particular, as I've already mentioned,
  • 6:21 - 6:24
    if they have physical access they
    could re-flash it at a minimum
  • 6:24 - 6:27
    but they could also do other
    things to it as well.
  • 6:27 - 6:30
    That also means we've not done things
    to try and dramatically
  • 6:30 - 6:32
    environmentally harden the device:
  • 6:32 - 6:36
    we don't POT it, we don't do all that
    kind of stuff that people sometimes do
  • 6:36 - 6:39
    when they're trying to make things secure.
  • 6:39 - 6:44
    In terms of the actual hardware device,
    two or two-and-a-half years ago
  • 6:44 - 6:48
    I designed a prototype and I tried
    to do something really clever
  • 6:48 - 6:52
    in the design of the actual noise source
  • 6:52 - 6:55
    and as so often happens when you try
    to be a little bit clever
  • 6:55 - 6:58
    it didn't really work right the first time.
  • 6:58 - 7:01
    For a lot of reasons having to do with
    where we were and trying to build a house
  • 7:01 - 7:05
    and all of this, I got distracted and just
    didn't get back to it for a very long time.
  • 7:05 - 7:09
    Keith picked it up and all of
    the hardware work on this since then
  • 7:09 - 7:14
    has been pretty much led by Keith,
    with me and other folks chiming in
  • 7:14 - 7:15
    from time to time.
  • 7:15 - 7:18
    So I'm going to let Keith talk about the hardware.
  • 7:21 - 7:27
    So this is the device that we've built.
    It's a tiny little board
  • 7:27 - 7:32
    about the size of a USB plug
    - well, connector.
  • 7:32 - 7:38
    The design of the board was predicated
    on the box that I found.
  • 7:38 - 7:41
    When you start actually trying to build
    hardware it turns out
  • 7:41 - 7:46
    the hardest thing to do is try to find
    a box. A lot of people try and think,
  • 7:46 - 7:48
    "OK, I'm going to build a device, and then
    I'm going to find somebody
  • 7:48 - 7:50
    to manufacture an enclosure for me".
  • 7:50 - 7:54
    Well, if you're build a million of them,
    that's pretty plausible - I mean
  • 7:54 - 7:58
    look at Buddy Huang's articles
    on his adventures in getting injection
  • 7:58 - 8:01
    moulding for his laptop prototypes, right?
  • 8:01 - 8:06
    It was like, "OK, so in the ninety-ninth
    iteration of a machined metal enclosure
  • 8:06 - 8:11
    or mould, we eventually got the things to
    work", right, so that cost about
  • 8:11 - 8:13
    a bazillion dollars.
  • 8:13 - 8:16
    So we found this tiny little enclosure.
  • 8:16 - 8:19
    And I thought "OK, how can I get something
    to fit in this tiny little enclosure?"
  • 8:19 - 8:24
    Well, the first design that we did
    with the new noise source
  • 8:24 - 8:27
    fitted this size enclosure.
  • 8:27 - 8:31
    The reason for that is the processor
    is huge - look at the size of that processor.
  • 8:31 - 8:34
    It's almost a centimetre on a side.
  • 8:38 - 8:40
    And the funny thing is that very same
    processor is advertised
  • 8:40 - 8:45
    in a much more reasonable,
    plausibly-sized package.
  • 8:45 - 8:49
    So this package is about
    four millimetres on a side
  • 8:49 - 8:53
    and you can see it - oops,
    Bdale will go back
  • 8:53 - 8:56
    You can see the processor
    in the upper-right hand corner there,
  • 8:56 - 8:59
    it's about four millimetres square.
    And so I was actually able to lay out
  • 8:59 - 9:03
    the board to fit in this tiny little box.
    Which was pretty cool.
  • 9:03 - 9:06
    Because the problem with this box
    is that it's too wide
  • 9:06 - 9:08
    so if you have two USB connectors
    in your laptop next to each other
  • 9:08 - 9:10
    you can't use both of them
  • 9:10 - 9:12
    and that was, like, "well that's going to suck".
  • 9:12 - 9:14
    So I manage to get it to fit
    in this tiny little box.
  • 9:14 - 9:17
    The other interesting part
    of course is that Bdale's design
  • 9:17 - 9:22
    had a really fun noise source -
    a little zener diode, a reverse-biased
  • 9:22 - 9:25
    zener diode - and then of course
  • 9:25 - 9:29
    Bdale being an actual electrical
    engineer - unlike me - designed
  • 9:29 - 9:32
    an amplifier with a transistor in it,
    and I looked at that and said
  • 9:32 - 9:35
    "Ah, a transistor, scary!"
    (audience laughter)
  • 9:35 - 9:41
    I really did. Because getting
    a transistor to operate in a linear mode -
  • 9:41 - 9:46
    I understand that it's theoretically possible
    (audience laughter)
  • 9:46 - 9:51
    but my training in college
    on electrical circuits was
  • 9:51 - 9:55
    a single physics lab that involved op-amps.
  • 9:55 - 9:57
    So I know how to do op-amp stuff.
  • 9:57 - 10:01
    So I replaced his awesome transistor
    amplifier with an op-amp, because
  • 10:01 - 10:07
    that's what I'm capable of understanding,
    because I'm a wimp.
  • 10:07 - 10:10
    You know, software engineer trying
    to play hardware.
  • 10:10 - 10:16
    So there's an op-amp here, kind of
    in between the two holes.
  • 10:16 - 10:20
    And in the upper centre is
    the actual noise source,
  • 10:20 - 10:25
    a six-pin package with two transistors in it.
  • 10:25 - 10:29
    And in the lower right corner is a
    twenty-volt power supply,
  • 10:29 - 10:34
    so caution - if you open the device up,
    you could possibly shock yourself
  • 10:34 - 10:37
    with about a milli-amp at twenty volts.
  • 10:37 - 10:40
    Or fry your machine, if you feed
    twenty volts back into USB.
  • 10:40 - 10:44
    So it isn't as harmless
    a device as it looks.
  • 10:44 - 10:47
    I mean, I wish I could have put,
    like, a kilovolt on it
  • 10:47 - 10:50
    to really give you a warning.
  • 10:50 - 10:54
    There you go, physical security -
    it could attack you if you try to open it.
  • 10:54 - 10:55
    (laughter)
  • 10:56 - 10:59
    So the box now fits in
    this tiny little package.
  • 10:59 - 11:05
    The noise generator we actually lifted
    from the OneRNG - the New Zealand
  • 11:05 - 11:07
    team that's doing a noise source.
  • 11:07 - 11:10
    Is that where the noise source is from?
  • 11:10 - 11:11
    I think so, yeh.
  • 11:11 - 11:17
    So the left-hand side of the circuit
    is all just a twenty-volt power supply.
  • 11:17 - 11:19
    All those pieces.
  • 11:19 - 11:24
    And on the right of R3 - that's
    the noise generator.
  • 11:24 - 11:28
    It's really just two transistors in
    the bizzarest circuit you'll ever see.
  • 11:28 - 11:32
    Isn't that awesome?
  • 11:32 - 11:34
    It's actually the left-hand transistor
    that's the noise source -
  • 11:34 - 11:38
    the right-hand transistor is
    just giving a little bit of buffering.
  • 11:38 - 11:41
    So it's really just that connection
    between the emitter and the base
  • 11:41 - 11:45
    of that transistor.
    It's a reverse-biased P-N junction
  • 11:45 - 11:47
    generating noise, and then
    and emitter-follower
  • 11:47 - 11:50
    buffering and amplifying it
    just slightly.
  • 11:50 - 11:51
    And then we run that through a capacitor.
  • 11:51 - 11:53
    So out of that we get about
    ten millivolts of noise
  • 11:53 - 11:56
    and then we run that through an op-amp,
    amplify it and then through an ADC.
  • 11:56 - 12:01
    The awesome part is that when
    you just look at the output of that
  • 12:01 - 12:05
    from the ADC - here's a histogram of
    values from that, it's like
  • 12:05 - 12:11
    "Oh, that's a lovely little kind of
    perfect normal distribution of noise".
  • 12:11 - 12:14
    So you can actually see that we're generating
    a fairly nice distribution of values.
  • 12:14 - 12:18
    Of course this is not what you want
    if you want a random number, right?
  • 12:18 - 12:21
    Random numbers are
    not normally distributed.
  • 12:21 - 12:24
    If you want an evenly-distributed
    random number
  • 12:24 - 12:26
    you don't want normal distribution.
  • 12:26 - 12:29
    This is what a plot of about two thousand
    points looks like
  • 12:29 - 12:33
    and you can see that it's kind of
    biased towards the centre.
  • 12:33 - 12:38
    However, the good news is that
    if you just take this data
  • 12:38 - 12:39
    and run it through an FFT
  • 12:39 - 12:43
    you'll notice that the frequency
    response is nice and flat -
  • 12:43 - 12:45
    or chaotic, as the case may be -
  • 12:45 - 12:48
    run chaos through an FFT and
    you get chaos out.
  • 12:48 - 12:50
    But it's nice and flat, so
    we know that we don't have
  • 12:50 - 12:54
    a frequency response problem, which we
    did in the earlier circuit.
  • 12:54 - 12:58
    The big problem with my original
    design is that the biasing of the
  • 12:58 - 13:00
    reverse-biased zener was a little off
  • 13:00 - 13:03
    and as a result it was very susceptible
    to low-frequency noise
  • 13:03 - 13:08
    and there was a source of low-frequency
    noise about a millimetre away.
  • 13:08 - 13:11
    I would have fixed it eventually, maybe.
  • 13:11 - 13:14
    I did the cheap thing and applied an op-amp!
  • 13:14 - 13:17
    And now we have a working product
    - it's all good!
  • 13:17 - 13:19
    This is how we work together by the way -
  • 13:19 - 13:22
    we sort of, you know, give each other crap
    until somebody breaks down
  • 13:22 - 13:24
    and spends the time to fix something.
  • 13:24 - 13:25
    Well the awesome part is that
    Bdale has been very patient
  • 13:25 - 13:29
    at letting me design hardware - I think
    this is the fifth version of the board.
  • 13:29 - 13:33
    I'm a software guy, right?
    How do you do software design? You iterate.
  • 13:33 - 13:36
    And you know, release early and often.
  • 13:36 - 13:39
    But then every iteration takes - instead of
    ten minutes like a software iteration -
  • 13:39 - 13:43
    it takes like two weeks, because you have
    to send it off to the PCB fabrication place
  • 13:43 - 13:45
    and then the boards come back
    and you put parts on
  • 13:45 - 13:49
    and then you think, "Man, that was stupid!
    Why did I hook up that connection backwards?"
  • 13:49 - 13:50
    In software you just go change the software.
  • 13:50 - 13:54
    Hardware: two weeks later
    and you get to try again.
  • 13:54 - 13:57
    So I'm slowly learning how to do hardware
    but I'm still terrible at it.
  • 13:57 - 14:01
    So we built this noise source.
    We need to make sure it's actually random
  • 14:01 - 14:04
    because if you have something that looks
    random, and dump it in your computer
  • 14:04 - 14:07
    and it's not actually random, and
    actually turns out to be predictable,
  • 14:07 - 14:09
    then you've kind of lost already.
  • 14:09 - 14:13
    So there's a bunch of stuff that
    we've done on this thing.
  • 14:13 - 14:16
    There are the FIPS standards - which are
    hilarious, you should read
  • 14:16 - 14:18
    the FIPS standards on random numbers.
  • 14:18 - 14:22
    The FIPS 140-2 Standard for Random Numbers
    literally says,
  • 14:22 - 14:27
    "OK, just make sure that the chunk of data
    that you're sending never repeats".
  • 14:27 - 14:30
    That's the entire standard - all that
    it requires of random numbers
  • 14:30 - 14:33
    is that you never reproduce
    the same value twice.
  • 14:33 - 14:43
    Don't say "4444" - that's wrong -
    but "43214321": that's perfectly OK.
  • 14:43 - 14:50
    But the standard is... yeh, ridiculous.
    It's a federal standard.
  • 14:50 - 14:54
    So nobody actually falls to that
    lower standard that we're aware of.
  • 14:54 - 14:59
    But the point is that in the standard
    there's some discussion about
  • 14:59 - 15:01
    what it means to be random,
    that's not very useful,
  • 15:01 - 15:03
    and there's a bunch of discussion
    about sort of how do you know
  • 15:03 - 15:06
    that you have a device that's OK
    to actually use.
  • 15:06 - 15:09
    And some of those bits are useful.
  • 15:09 - 15:14
    In particular, when I first
    flash the device during production
  • 15:14 - 15:17
    I do a bunch of tests on it to make sure
    that the values are coming out random.
  • 15:17 - 15:20
    I do the FFT tests, I do a bunch
    of other tests to make sure
  • 15:20 - 15:23
    the circuit was constructed as we expect.
  • 15:23 - 15:26
    Because one of the big problems
    with physical hardware
  • 15:26 - 15:29
    is that you don't have perfect replication.
  • 15:29 - 15:33
    Actually the first - I made a bunch of
    these boards and got a bunch of parts
  • 15:33 - 15:38
    and built them all, only to discover that
    the parts supplier sent me the wrong parts
  • 15:38 - 15:40
    for the noise source.
    I don't know what they sent me
  • 15:40 - 15:43
    but it wasn't a transistor.
  • 15:43 - 15:51
    It was even the wrong package.
    And I still need to send the wrong thing
  • 15:51 - 15:54
    back to them so they can
    close up the final bill.
  • 15:54 - 15:56
    It was funny - I built the device
    and I plugged it in
  • 15:56 - 15:59
    and my production test said
    "No, that's broken".
  • 15:59 - 16:01
    I'm, like, "how can that be broken?"
    and I looked at the noise source
  • 16:01 - 16:04
    and it looked like, "oh, that's not
    actually generating random numbers
  • 16:04 - 16:06
    at all."
  • 16:06 - 16:08
    So we do a bunch of production tests
    which are extensive and make sure
  • 16:08 - 16:11
    the device operates with
    the right behaviour.
  • 16:11 - 16:13
    When the device powers on -
    the first time you plug it in -
  • 16:13 - 16:16
    we do some testing as a
    kind of real sanity check
  • 16:16 - 16:18
    (The production test is all
    in the source tree, right?)
  • 16:18 - 16:24
    We haven't quite finished it...
    I have some ideas about how it might work.
  • 16:24 - 16:27
    What we do with all of our products though
    is there are turn-on test scripts for them
  • 16:27 - 16:30
    including the rocket avionics stuff
    all in the source tree
  • 16:30 - 16:34
    so eventually when it's all folded
    in the right place, if you want -
  • 16:34 - 16:35
    I still have two weeks, right?
  • 16:35 - 16:37
    You still have two weeks.
    - Awesome.
  • 16:37 - 16:38
    Just-in-time software.
  • 16:38 - 16:42
    As with everything else we do,
    not just the hardware design
  • 16:42 - 16:45
    but how we go about turning them on,
    what our production test process is
  • 16:45 - 16:48
    all of that is also open, so
    if you want to look at it
  • 16:48 - 16:50
    and provide feedback or comments
    or suggest something different
  • 16:50 - 16:52
    you're always welcome to have input.
  • 16:52 - 16:55
    I've actually been working with a friend
    of mine who is a Professor
  • 16:55 - 16:57
    at Portland State where we had DebConf
    a couple of years ago -
  • 16:57 - 17:01
    he's got some students off generating
    some useful tests.
  • 17:01 - 17:06
    There is an interesting random number
    generator test - I don't remember the name
  • 17:06 - 17:11
    It's a huge long suite of tests that I've
    run on this thing and it passes that fine.
  • 17:11 - 17:17
    It says that there are 7.99992 bits
    of entropy per byte.
  • 17:17 - 17:19
    I don't know why it doesn't think
    there are eight, but I guess
  • 17:19 - 17:22
    getting all the way to eight is hard
    or something.
  • 17:22 - 17:23
    Random round-off there?
  • 17:23 - 17:25
    Yeh, random round-off, probably.
  • 17:25 - 17:28
    And then as the device is running it's
    constantly testing the data generated
  • 17:28 - 17:31
    to make sure that it looks pretty random.
  • 17:31 - 17:35
    What we're doing with that is currently
    I actually just make sure the normal
  • 17:35 - 17:41
    distribution looks like a bell-curve, looks
    reasonable and isn't spiky or something.
  • 17:41 - 17:45
    I want to do kind of a point FFT to make
    sure the frequency doesn't look
  • 17:45 - 17:49
    like you just have a sine wave , which
    is a common failure mode in the hardware
  • 17:49 - 17:54
    because if the transistor goes
    "catty-walkers" sometimes you just get -
  • 17:54 - 17:57
    you're just picking up noise from
    the environment and you get a sine wave out
  • 17:57 - 18:01
    which is not very random.
    So we do online tests, we do power on tests
  • 18:01 - 18:05
    and then we do production tests.
    That's how we're making sure it's random.
  • 18:05 - 18:08
    And you also mentioned that you're using
    the CRC generator to whiten? Or not?
  • 18:08 - 18:17
    Yes. Yeh, so as we said the noise right
    here is normally distributed - the values
  • 18:17 - 18:20
    that I'm getting out of the noise source
    source are randomly distributed.
  • 18:20 - 18:25
    What we discovered was that the middle
    eight bits are completely random
  • 18:25 - 18:30
    and as you can see these are about twelve
    or thirteen bits of data coming out
  • 18:30 - 18:35
    so that we get values from zero to 4096,
    centred around 2048.
  • 18:35 - 18:42
    So, how many bits is that? Thirteen bits?
    Twelve bits, OK.
  • 18:42 - 18:47
    So we have twelve bit values
    distributed around, but if you throw away
  • 18:47 - 18:51
    the top bit then the bottom eight bits
    are really quite flat.
  • 18:51 - 18:54
    We could have just used the bottom eight
    bits for our noise source
  • 18:54 - 18:57
    and that would probably would
    have worked fine.
  • 18:57 - 19:01
    What I did instead was the chip - as
    with many SoCs - has random extra
  • 19:01 - 19:05
    functional units, so one of the things
    it has is a CRC32 generator in hardware
  • 19:05 - 19:11
    so you dump data in and you pull data out,
    you know, one instruction in and one out
  • 19:11 - 19:17
    so I took all sixteen bits out of the
    the noise value that I read from the ADC
  • 19:17 - 19:20
    and I dump that in the CRC generator
    and pull eight bits out
  • 19:20 - 19:24
    and because I know that the noise source
    has at least eight bits of entropy.
  • 19:24 - 19:29
    I know that it's a valid thing to do,
    because whichever eight bits I pull out
  • 19:29 - 19:30
    they're going to be random.
  • 19:30 - 19:33
    So we're using that CRC to kind of
    whiten or flatten that data, so that
  • 19:33 - 19:35
    we get truly flat data.
    This is actually of course a plot from
  • 19:35 - 19:44
    the raw source, but if you look
    at the plot from the whitened source,
  • 19:44 - 19:47
    it's completely flat - all of the values
    are evenly distributed.
  • 19:47 - 19:50
    It's normally distributed randomness,
    which you can get into arguments
  • 19:50 - 19:52
    with people about whether it's
    really random, but what you seem
  • 19:52 - 19:58
    to really want in the cryptographic world
    is a uniform distribution of values
  • 19:58 - 20:00
    which are not predictable.
  • 20:00 - 20:09
    So to wrap things up, I already mentioned
    we have an initial production run of
  • 20:09 - 20:12
    a thousand of these currently underway.
  • 20:12 - 20:15
    I've been asked by a couple of people
    where we're having them built.
  • 20:15 - 20:21
    To explain just briefly, the micro-controller
    chip we chose is one from ST Micros that
  • 20:21 - 20:27
    we've used for some other things.
    It's a tiny little - this one's a Cortex 0?
  • 20:27 - 20:28
    Yeh.
  • 20:28 - 20:32
    And it has 32K of flash, and it has a
    tiny little in-built USB bootloader thing.
  • 20:32 - 20:36
    So we're actually having these
    manufactured in Shenzhen in the first run
  • 20:36 - 20:38
    and a lot of folks are "Oh my God, China,
    you're letting the Chinese touch your
  • 20:38 - 20:42
    crypto-related stuff."
    Well the answer is we're not having them
  • 20:42 - 20:46
    flash anything. The boards come to us
    and we're doing the flash and the
  • 20:46 - 20:50
    production tests. So I guess on some level
    of theoreticalness somebody could be
  • 20:50 - 20:54
    putting different chips in them than
    the ones we actually asked for and
  • 20:54 - 20:58
    spoofing us at a very deep hardware level.
    But I kind of doubt it.
  • 20:58 - 21:03
    Frankly at some point you have to decide
    where in this chain of importance versus
  • 21:03 - 21:07
    ridiculousness you want to fall.
    I certainly don't want to start with sand
  • 21:07 - 21:12
    and a heat source to make chips, so
    we think this is a pretty reasonable place
  • 21:12 - 21:17
    because we're not relying on anybody else
    to put the code in that's on the device
  • 21:17 - 21:19
    when we ship them.
    By the way, the reason that we think
  • 21:19 - 21:24
    we meet FIPS level 2 is that it has to be
    "tamper-evident", and you have to cut
  • 21:24 - 21:29
    the label to get the box apart, and it's
    almost impossible to cut these labels
  • 21:29 - 21:35
    without just sort of destroying them,
    so... eh, we think it's tamper evident.
  • 21:35 - 21:38
    It's certainly not tamper-proof.
  • 21:38 - 21:41
    We do expect to have this production run
    delivered to us in the next couple of weeks
  • 21:41 - 21:45
    - as I said we really just missed
    having them in time to be here.
  • 21:45 - 21:49
    We really had hoped to be here
    with a big bag of them
  • 21:49 - 21:51
    for anybody who's interested.
  • 21:51 - 21:56
    Oh, we decided to set the quantity one
    price at US $40
  • 21:56 - 22:00
    and then to discount for quantity.
    If people are interested in
  • 22:00 - 22:04
    real quantities of them, let me know
    and we can talk about that.
  • 22:04 - 22:10
    I have somewhere in my bag in my notebook
    a set of proposed quantity discounts.
  • 22:10 - 22:14
    Our goal here is really to make sure that
    people have access to high-quality
  • 22:14 - 22:18
    sources of entropy and we really hope
    this ends up being something
  • 22:18 - 22:21
    that lots of people are having.
  • 22:21 - 22:24
    We do have a few more of these which
    are sort of, you know, we had a small run
  • 22:24 - 22:29
    done by our manufacturer to validate
    their prodution processes.
  • 22:29 - 22:32
    We have a few more of those if
    somebody really desperately needs
  • 22:32 - 22:36
    to have one today. But because we
    only have a few, if you're really interested
  • 22:36 - 22:39
    the right thing to do would be to watch
    chaoskey.org, and we will change
  • 22:39 - 22:43
    the status at the top of that page
    to indicate when we have them for sale
  • 22:43 - 22:48
    and I'm happy to stick them in envelopes
    or boxes or whatever and send them out.
  • 22:48 - 22:52
    So with that, I guess we're pretty much
    done with the content part of this
  • 22:52 - 22:54
    and we'd be happy to take any questions.
  • 22:56 - 22:59
    (audience)
    I'll take fifty! (laughter)
  • 22:59 - 23:01
    We don't have that many with us today.
  • 23:01 - 23:06
    The one thing that I'm trying to do right
    now is to get the drivers in the Stretch kernel
  • 23:06 - 23:11
    but it's not in the stable kernel, so I
    need to backport the driver to the stable
  • 23:11 - 23:18
    kernel so the DSA folks will be happy.
    It's a completely separate driver, so
  • 23:18 - 23:23
    I can either construct just a package
    which has the driver that you could load,
  • 23:23 - 23:28
    or I could merge the patch into the current
    stable kernel and just deliver it as part
  • 23:28 - 23:33
    of the kernel package - does anybody
    have any preference?
  • 23:34 - 23:36
    Could you just use RNGD?
  • 23:36 - 23:39
    We don't need to use RNGD, it's
    built directly into the kernel.
  • 23:39 - 23:42
    We don't need any external applications.
  • 23:44 - 23:46
    Microphone please, aba.
  • 23:46 - 23:50
    OK, I am the first to take a microphone
    but the cameras can see me.
  • 23:50 - 23:54
    So does it work with the backports kernel
    because that might be enough?
  • 23:55 - 23:58
    The driver should just compile - it's
    just a USB driver, so there's nothing
  • 23:58 - 24:00
    magic in it.
  • 24:00 - 24:02
    But it is not in the stable
    kernel yet -
  • 24:02 - 24:04
    What version is the backports kernel?
    We don't know.
  • 24:04 - 24:06
    It's just basically the same as testing.
  • 24:06 - 24:10
    Oh, then it's already in
    the backports kernel.
  • 24:10 - 24:15
    I think that DSA wanted to have it in
    the stable kernel, yes?
  • 24:15 - 24:17
    Yes.
  • 24:17 - 24:20
    And Keith also mentioned that people
    have asked us, "well gee, you'll have your
  • 24:20 - 24:25
    own kernel driver?" Well, yeh, I guess,
    except he's already accepted a USB
  • 24:25 - 24:30
    VID/PID pair from somebody else who
    wanted to just use that driver with
  • 24:30 - 24:34
    their source of entropy. So if that
    ends up being a standard approach
  • 24:34 - 24:38
    people take for building more
    and diverse things.
  • 24:38 - 24:41
    And you recently took a change or are
    working on a change or something
  • 24:41 - 24:45
    so that the kernel will accept and blend
    data from multiple sources of hardware
  • 24:45 - 24:49
    randomness - in the past it's been,
    you know, pick the most random-looking
  • 24:49 - 24:51
    thing and use it -
  • 24:51 - 24:52
    No, the most recently-attached thing.
  • 24:52 - 24:56
    The most recently-attached thing. So
    we generally believe that another way
  • 24:56 - 25:00
    to sort of help you deal with the possible
    - so if somebody walked up and stuck
  • 25:00 - 25:04
    something random into your machine -
    ha ha, you see what I did there -
  • 25:04 - 25:08
    is that if you had a known good source
    of randomness on the machine already
  • 25:08 - 25:11
    and you were interleaving the bits
    that you get from all of them
  • 25:11 - 25:15
    it would just make it exponentially
    hard for anybody to really spoof
  • 25:15 - 25:17
    your random number generator.
  • 25:17 - 25:20
    And of course the kernel's been doing
    its own thing - I don't know
  • 25:20 - 25:23
    on any given day exactly what happens
    between the entropy pool and the bits
  • 25:23 - 25:26
    that are delivered by /dev/random and
    /dev/urandom.
  • 25:26 - 25:28
    That's been written about elsewhere -
    Greg Kroah-Hartman had an article
  • 25:28 - 25:31
    which was referenced by Tom Marble
    in his Portland talk.
  • 25:32 - 25:33
    Andy?
  • 25:34 - 25:38
    So, hardware RNGs are notorious for
    temperature stability problems.
  • 25:38 - 25:43
    First of all, are you monitoring
    temperature to determine whether
  • 25:43 - 25:45
    you are drifting?
  • 25:45 - 25:50
    And second, have you tested across
    temperature ranges?
  • 25:50 - 25:52
    It's been tested across some amount
    of temperature range
  • 25:52 - 25:58
    because Keith and I have entirely
    different environmental desires personally
  • 25:58 - 25:59
    (laughter)
  • 25:59 - 26:04
    He's in a couple of layers of jacket
    and I am not.
  • 26:04 - 26:12
    But no, we have not done that.
    We probably should.
  • 26:12 - 26:14
    Yes, it would be easy.
  • 26:14 - 26:19
    There is at least one temperature
    sensing point on this device already.
  • 26:19 - 26:20
    Isn't there?
  • 26:20 - 26:23
    I don't think so.
    I don't know if this one does or not.
  • 26:23 - 26:26
    It's a good question, Andy.
    I don't know the answer.
  • 26:26 - 26:30
    Certainly testing it across a broader range
    is not a terribly hard thing to do.
  • 26:30 - 26:35
    Again, it's completely open hardware
    design. We would love for all of you
  • 26:35 - 26:37
    to go take a look and tell us what a
    bunch of idiots we are.
  • 26:37 - 26:39
    Of course it would be nice if we'd sold
    at least a few of the thousand
  • 26:39 - 26:42
    before we found that out.
    (laughter)
  • 26:42 - 26:44
    OK, any other questions?
  • 26:46 - 26:52
    If you compare the Entropy Key, which has
    the EGD daemon, that would distribute
  • 26:52 - 26:57
    randomness and make it easier to transport
    randomness to a virtual machine
  • 26:57 - 27:00
    or something like that. Have you -
  • 27:00 - 27:04
    So if you have a kernel that has an
    essentially infinitely deep well of entropy
  • 27:04 - 27:07
    I would assume that you could figure
    out some way to happily pump
  • 27:07 - 27:11
    the bits to other machines. Using the same
    daemon and just saying "trust the
  • 27:11 - 27:15
    local kernel to have a lot of randomness",
    then...
  • 27:15 - 27:22
    And we can keep a full-speed USB
    pipe full, which is not quite
  • 27:22 - 27:27
    a megabyte per second in actual
    throughput. It's like a megabyte
  • 27:27 - 27:31
    per second-ish of randomness.
  • 27:31 - 27:34
    Our time is up, so thank you very much.
  • 27:34 - 27:38
    We appreciate your time and attention.
    (audience applause)
Title:
Chaoskey_A_Hardware_Random_Number_Generator_for_Everyone.webm
Description:

Bdale Garbee and Keith Packard present their open hardware design 'Chaoskey', a random number generator for everyone.

more » « less
Video Language:
English
Team:
Debconf
Project:
2016_debconf16

English subtitles

Revisions Compare revisions