× SPECIAL FORCES      |     LOCKSPORT      |     SCI FI      |     INSECTS      |     RECIPE      |     RED DEAD REDEMPTION      |     WOODWORKING      |     FISHING      |     SCI FY      |     CRIME STORIES      |     BIRDS      |     STYLE      |     TV      |     INTERESTING      |     ENVIRONMENT      |     STAR WARS      |     OLYMPICS      |     EASTER      |     GOD OF WAR      |     FOOD & DRINK      |     PHOTOGRAPHY      |     WEDDING      |     COLD WAR      |     WAR      |     CHRISTMAS      |     ARCHITECTURE      |     FITNESS      |     ART      |     TOYS      |     SKATEBOARDING      |     YOUR HOME      |     PSYCHOLOGY      |     RELIGION      |     HEALTH & WELLNESS      |     PETS      |     GUNS      |     MATH      |     BIOLOGY      |     WW1      |     BUSINESS      |     WORLD WAR 2      |     AUTOMOTIVE      |     STEM      |     GUITAR      |     AQUARIUM      |     HOMEBREW      |     KITCHEN      |     SPEECHES      |     KIDS      |     ECONOMICS      |     PROGRAMMING      |     REMOTE CONTROL      |     MINECRAFT      |     MOTORBIKES      |     VALENTINE'S DAY      |     MULTIPLICATION      |     LAWNCARE      |     GARDENING      |     PI DAY      |     LEGO      |     BLOCKCHAIN      |     COMPUTER SECURITY      |     SPORTS      |     CATS      |     MUSIC      |     FORTNITE BATTLE ROYALE      |     FARMING      |     ARTIFICIAL INTELLIGENCE      |     ROCKCLIMBING      |     RELAXING      |     CSGO      |     BABY      |     AVIATION      |     MENS STYLE      |     ANIMALS      |     SCIENCE      |     DOGS      |     SHOOTING SPORTS      |     MOVIES      |     OUTDOORS      |     BIKING      |     HISTORY      |     FASHION      |     FAR CRY 5      |     HALLOWEEN      |     STPATRICKS      |     CRYPTOCURRENCY      |     ENGINEERING      |     GEOPOLITICS      |     POLITICS      |     TECHNOLOGY      |     FUNNY      |     TRAVEL      |     MARTIAL ARTS      |     GAMBLING      |     GAMING      |     KNITTING      |     BEAUTY      |     PHILOSOPHY      |     ANCIENT WORLD      |     POTTERY      |     ARCHERY      |     THANKSGIVING      |     HOME REPAIR      |     CRAFTS      |     ORGANIZATION      |     BIG THOUGHTS

  • 00:07
    it can leak a lot of information.
  • 00:09
    For example because of variations on power consumption.
  • 00:13
    In this video I wanna explain what power analysis is, as well as showing you how I prepared an arduino nano board to perform this attack.
  • 00:25
    I'm sure you have heard about those stories where illegal marijuana farms are being busted because of unusual electricity usage.
  • 00:36
    It's not typical for any private home to suddenly use this crazy amount of electricity that a setup with dozens of heating lamps and air conditioning systems require.
  • 00:47
    So the authorities are just abusing a power analysis side channel to find potential illegal marijuana farms.
  • 00:54
    And that is basically what this is about.
  • 00:57
    You can imagine that a piece of hardware, or to be more precise a chip, draws different amounts of power depending on what operations are being performed.
  • 01:07
    So let's do an example.
  • 01:09
    Recently I made a video introducing RSA, which I'd recommend you to watch if you haven't yet.
  • 01:15
    But the important part here is that if you sign a message you basically encrypt a message with your private key that somebody with your public key can decrypt, thus verifying it came from you - the owner of the private key.
  • 01:29
    And RSA encryption works by exponentiation.
  • 01:32
    You take the message to the power of the private key modulos n.
  • 01:38
    And as a developer you now have to implement this math, luckily you have heard about a simple algorithm to perform this exponentiation.
  • 01:48
    The square and multiply method.
  • 01:51
    And this is how the pseudo code looks like: The important part here is, that you have a loop over each bit of the exponent.
  • 01:57
    And for every bit of the exponent you square the intermediate value.
  • 02:02
    But if the bit is a 1 you do an additional multiplication.power analysis of RSA origin
  • 02:07
    So if I just give you a list of square and multiply operations like this here: Square, square, square, multiply, square, multiply You can recover the bits of exponent that lead to these operations and thus the secret key.
  • 02:21
    So 0,0,1,1.
  • 02:22
    Now you can imagine that a multiply operation will have a different power consumption footprint than squaring.
  • 02:31
    Here is how such a power trace can look like.
  • 02:33
    And you can again figure out the operations and thus the bits.
  • 02:36
    Square, multiply, square, square, square multiply 1,0,0,1 Ok, theory is fine.
  • 02:42
    But how the heck do you do this in reality.
  • 02:45
    A processor can run really really fast, for example the arduino nano runs with 16 MHz.
  • 02:52
    Also the difference in power consumption must be really really tiny.
  • 02:56
    So you need something that can measure small variations very very fast.
  • 03:02
    So a digital oscilloscope seems like an obvious choice.
  • 03:05
    My RIGOL can capture data with up to 70Mhz, so that seems enough.
  • 03:11
    BUT there is one issue… if you didn't sleep in physics class you may realize now: “wait!
  • 03:18
    Does an oscilloscope not measure voltage, and we want to measure current?
  • 03:22
    The power consumption?
  • 03:23
    That doesn't work?” Well.
  • 03:26
    Ohm's law to the rescue.
  • 03:28
    Ohm's law states that the current through a conductor between two points is directly proportional to the voltage across the two points.
  • 03:35
    I guess easier to understand with this formula.
  • 03:39
    Current is equal to voltage divided by resistance.
  • 03:42
    Let's solve this equation for voltage, because the oscilloscope can only measure voltage.
  • 03:47
    Then we get voltage is equal to the current times resistance.
  • 03:53
    So when we have a fixed resistor sitting somewhere in our circuit and we measure the voltage accross it, then we realize that the voltage we measure is directly dependent on the current.
  • 04:07
    This means when the current changes, so the device under test draws more or less power, the voltage will change.
  • 04:14
    It must change.
  • 04:15
    Ohm's law tells us that.
  • 04:17
    Science, it works.. bitches.
  • 04:21
    So using a resistor to meassure the voltage and thus indirectly the current is called a shunt resistor.
  • 04:27
    Ohm's law also tells us that the bigger the resistor value, the bigger voltage difference we will measure.
  • 04:34
    But we can't just use an arbitrary big resistor, because then the voltage drop across the resistor will be too big and it's not enough to power the chip anymore.
  • 04:43
    But like 50 Ohm or maybe even 100 Ohm could still work with the Arduino.
  • 04:48
    So now that we know how to measure current, where do we place the resistor.
  • 04:53
    An easy solution would be to cut a USB cable and insert a resistor into the power line, but that wont work.
  • 05:01
    First of all, we will measure everything that draws power, including the LEDs and the other USB to Uart chip on there.
  • 05:10
    That's too much noise.
  • 05:12
    We want to be as close to the actual chip as possible.
  • 05:16
    We want to insert a resistor directly into the power line to the chip.
  • 05:22
    So we are going to lift the actual pin of the chip up, so we can insert a resistor in between the chip and the pcb.
  • 05:30
    Oh man I was so nervous.
  • 05:34
    First time doing this and.
  • 05:35
    If I screw this up, the competition will be over for me.
  • 05:39
    There is no replacement board.
  • 05:40
    I looked up the data sheet to be 100.000% sure I desolder the correct pin.
  • 05:46
    I even check with my multimeter to make sure the pins really match.
  • 05:51
    And I mark it with a marker.
  • 05:53
    I place it on a breadboard and use double sided tape to stick the breadboard to the workbench, so it doesn't slide away.
  • 05:59
    Then I take my soldering iron with a very pointy tip and another metal tool and try to push up the pin with it.
  • 06:06
    Like a lever.
  • 06:07
    The heat should make the solder liquid and I can bend it up.
  • 06:10
    That actually worked better than I expected.
  • 06:13
    So now that the pin is bent up, I want to insert this resistor.
  • 06:17
    This is really difficult to solder, very awkward angle and it's all so tiny.
  • 06:21
    But with a bit of flux I actually successfully solder it to the pad and the pin.
  • 06:27
    Moment of truth.
  • 06:28
    Does the device still work?
  • 06:30
    Plug it in.
  • 06:31
    Green LED is on.
  • 06:33
  • 06:34
    Then I realize that connecting directly the measurement equipment might not work so well, because the resistor has really stiff legs and you could easily break off the pin or pad if you handle it carelessly.
  • 06:46
    So I add two flexible wires on each side.
  • 06:50
  • 06:51
    This looks like a good setup.
  • 06:53
    You meassure voltage in a relative difference to eachother.
  • 06:56
    So for example you can place one end to GND, basically 0 V and the other end to AFTER the resistor.
  • 07:04
    Just for reference I also place one probe BEFORE the resistor.
  • 07:08
    Theoretically we should see a voltage drop accross the resistor depending on how much current you draw.
  • 07:14
    So when you overlay the two measurements you should see a slight difference.
  • 07:18
    So that's my first attempt.
  • 07:21
    But when looking at the oscilloscope measurement, I just see noise.
  • 07:24
    I would expect a lot more difference.
  • 07:27
    I didn't expect to find the crypto leaking part, but at least some variance in the consumption.
  • 07:33
    But it's all just noise and the differences sooo small.
  • 07:37
    What's going on?
  • 07:39
    Is my resistor too small?
  • 07:42
    Let's try a different measurement setup.
  • 07:44
    Like I said you measure voltage potential between two measurement points.
  • 07:49
    So nobody is stopping you from putting the ground part of the probe before the resistor, and the probe itsel afterwards.
  • 07:56
    This way you should meassure the voltage difference between these two points.
  • 08:01
    You just have to be very very very careful with ground loops.
  • 08:06
    If you plan to connect something that usually belongs to ground to something that is not ground, in thise case basically +5V it can be really dangerous.
  • 08:16
    If you plan to do this, research “ground loops”.
  • 08:20
    Luckily I read about this before so I knew I what I had to do.
  • 08:24
    I had to make sure the device under test and the measurement device don't share a common ground.
  • 08:30
    If the arduino is connected via the laptop to the same power strip as my oscilloscope is conencted too, they share the same ground line.
  • 08:39
    And when I then connected the oscilloscope ground to +5V I'd basically create a short circuit.
  • 08:46
    +5V flows directly into ground through the power strip.
  • 08:51
  • 08:53
    Something will die.
  • 08:54
    Hopefully no your expensive equipment.
  • 08:56
    But what you can do is run your laptop from battery.
  • 09:00
    Now there is no ground connection anymore.
  • 09:02
    So that's what I did.
  • 09:04
    And then I can connect the one single probe around the resistor.
  • 09:07
    I also thought it would be good to make a comparison meassurement with the real 5V, just to see if there are any differences.
  • 09:15
    Might help to validate if everything works.
  • 09:17
    So I attach the second probe and.
  • 09:20
  • 09:21
    What the fuck happened?
  • 09:22
    What did I do?
  • 09:23
    Magic smoked escaped from the device.
  • 09:24
    I panicked so much that I also accidentally broke off the resistor and thus ripped off the pin and pad.
  • 09:31
    This was probably game over for me.
  • 09:33
  • 09:34
    What went wrong?
  • 09:35
    I was so careful.
  • 09:37
    <heavy breath> After closer inspection I realise that despite careful and slow planning I fucking soldered the wrong pin.
  • 09:47
    I did not solder the resistor to the power input, I soldered it to a ground pin.
  • 09:53
    So when I connected the other probe to +5V I created a short circuit between +5V and ground through the probes.
  • 10:02
  • 10:03
    That's why I measured so much noise and rubbish.
  • 10:06
    There was no real signal there.
  • 10:08
    How stupid am I?
  • 10:09
    Well… After the initial shock and assessing the situation I figured out that the chip has another ground pin.
  • 10:16
    So I should be totally fine.
  • 10:17
    I just have to replace the destroyed diode on the other side and then solder a resistor to the correct pin.
  • 10:25
    Fuck me.
  • 10:27
    But this time I learned from my mistake.
  • 10:29
    I soldered female cable connectors to the pin instead, this way I'm able to switch out and try different resistors.
  • 10:36
    Also to make sure not to rip off the cables, I put a drop of hot glue on it to keep it in place and remove any tension from the delicate pins.
  • 10:46
    Unfortunately I don't have a proper SMD diode at hand, so I have to solder this frankenstein to it, but that's fine.
  • 10:53
    It works.
  • 10:54
    Another tip if possible, remove as many capacitors as you can.
  • 10:59
    Capacitors are like small super fast bateries.
  • 11:02
    They charge up, hold the charge and release it again if the voltage drops.
  • 11:06
    This is great to smoothen out a noisy power supply, but we actually want to measure these differences.
  • 11:13
    So I disconnect this capacitor by toombstoning it.
  • 11:16
    I also experimented with disconnecting the others.
  • 11:20
    It may make the board a bit more unstable, but should improve measurements.
  • 11:24
    It turned out later that it was probably not necessary, but at the time I had some problems I will explain next episode, which I thought it would solve.
  • 11:33
    But yeah, this setup looks much better now.
  • 11:36
    I can exchange resistors and I have the correct pin now.
  • 11:39
    So I should be all set to solve the first power analysis side channel challenge for the embedded hardware CTF easily.

RSA Power Analysis Side-Channel Attack - rhme2

Preparing an arduino nano board to perform a power analysis side channel attack and explaining how that can be used to break RSA. Also proof I can't count.

Community tags: computer_security     HOME     SIGN UP     CONTACT US