Git Product home page Git Product logo

gocw's Introduction

GO - ChipWhisperer

About

ChipWhisperer is an open platform for embedded hardware security research. CW was developed by Colin O'flynn.

CWLite

gocw is a re-implementation of CW software stack, written in go.

gocw main features:

  • Clean interface to CW capture device.
  • Self contained flash programmers for XMEGA and STM32F targets.
  • Web based UI to view captured power traces.
  • Efficient implementation of several power-analysis algorithms (DPA/CPA/Templates) using gonum.

Setup

  1. Get external git repositories:
$ git submodule init
$ git submodule update
  1. Get package dependencies:
$ go get -d ./...
  1. Generate enum strings, mocks, static file resources:
$ go get -u golang.org/x/tools/cmd/stringer
$ go get -u github.com/omeid/go-resources/cmd/resources
$ go get -u github.com/golang/mock/gomock
$ go install github.com/golang/mock/mockgen
$ go generate ./hardware ./...
$ go test github.com/google/gocw
  1. Build firmware files. See CW wiki for information on how to install the required toolchains.
$ mkdir build
$ cd build

# For STM32 targets run the following:
build$ PLATFORM=CWLITEARM cmake ..

# For XMEGA targets run the following:
build$ PLATFORM=CWLITEXMEGA cmake ..

build$ make

Smoke Tests

The tests under tests/ are e2e integration tests that verify gocw stack is working properly. Each test programs the target, sends requests over the serial based communication protocol, and verifies the firmware returns the expected output.

To run the tests, plugin CW device, and run:

$ go test ./tests/simple_serial_smoke_test.go -count 1 -v
$ go test ./tests/aes_smoke_test.go -count 1 -v
$ go test ./tests/ecdh_smoke_test.go -count 1 -v

Power Analysis Process

The following demonstrates how to use gocw to mount a correlation power analysis (CPA) on the first round of AES-128 running on the target device.

  1. Program the target device.
$ go run cmd/program.go -logtostderr -firmware build/firmware/tiny_aes.hex
  1. Capture 50 traces, 5000 samples per trace, starting from offset 0 from the trigger:
$ go run cmd/capture.go -logtostderr \
  -traces 50 -samples 5000 -offset 0 -output captures/aes_t50_s5000.json.gz
  1. Launch Web UI to view the captures:
$ go run viewer/server.go -port 8080 -dir captures

Browse to http://localhost:8080, and examine the power trace:

Main viewer window

Load new traces by clicking on the rows in the traces window:

Multiple traces

Zoom in by selecting a samples time region:

Trace selection

Zoomed in

The web UI monitors the captures directory for changes. We can run the server in the background go run viewer/server.go&, and new capture files will automatically be displayed on the captures window.

Captures window

  1. Run correlation power analysis to recover the key:
$ go run cmd/attack_sbox_cpa.go -logtostderr -input captures/aes_t50_s5000.json.gz
...attack_sbox_cpa.go:113] Loaded capture with 50 traces / 5000 samples per trace
...attack_sbox_cpa.go:165] Fully recovered key: 2b7e151628aed2a6abf7158809cf4f3c

Implemented Attacks

  • Correlation Power Analysis attacks the SBOX lookup of the first round of AES-128. Attack fully recovers the key from ~50 traces.

  • Differential Power Analysis attacks the SBOX lookup of the first round of AES-128. Attack fully recovers the key from ~500 traces.

  • ECDH Template Attack builds a power trace classifier that identifies when a EC multiplication operation resulted with a zero-coordinate point. Classifier successfully identifies traces in the validation set from training from ~150 traces.

Supported Hardware

gocw was only tested on ChipWhisperer-lite with XMEGA and STM32F targets. Contributions for additional hardware support are welcome.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

gocw's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.