Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdsn authored Feb 12, 2022
1 parent fd4bc94 commit 15a5b3f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `test.sh` file included in this repository is a simple Bash script which tes

To generate white-box Speck encryption implementations manually, you will need to execute the `main.py` file:
```
sage -python -m white_box_speck -h
$ sage -python -m white_box_speck -h
```
This will output the help dialogue with possible arguments, copied here for your convenience:
```
Expand Down Expand Up @@ -52,10 +52,10 @@ After executing the program with your arguments, 8 files will be generated in th

All of these programs accept two input words *as arguments* and output the result to standard output. Consequently, you can do something like this:
```
gcc -o inverse_input_external_encoding inverse_input_external_encoding.c
gcc -o inverse_output_external_encoding inverse_output_external_encoding.c
gcc -march=native -o speck default_white_box_speck.c
./inverse_output_external_encoding $(./speck $(./inverse_input_external_encoding $PLAINTEXT))
$ gcc -o inverse_input_external_encoding inverse_input_external_encoding.c
$ gcc -o inverse_output_external_encoding inverse_output_external_encoding.c
$ gcc -march=native -o speck default_white_box_speck.c
$ ./inverse_output_external_encoding $(./speck $(./inverse_input_external_encoding $PLAINTEXT))
```
This will properly chain the inverse input and output external encodings with the white-box implementation to present the expected ciphertext.

Expand All @@ -64,43 +64,43 @@ In general, the bit-packed code generation strategy is the most efficient overal

The performance of a specific strategy can be tested by providing an iterations argument to a `speck` executable. The following example will perform Speck encryption 1000000 times:
```
gcc -march=native -o speck default_white_box_speck.c
perf stat --detailed ./speck 1000000
$ gcc -march=native -o speck default_white_box_speck.c
$ perf stat --detailed ./speck 1000000
```

Additionally, we include a convenient script to test the performance of all strategies and compare them to a reference implementation:
```
./test_performance.sh 32 64 '1918 1110 0908 0100' 1000000
$ ./test_performance.sh 32 64 '1918 1110 0908 0100' 1000000
```
Note: this script only works for Speck implementations with block size 32, 64, and 128.

## Some examples

Generating a white-box `Speck32/64` implementation using only linear self-equivalences (just for demonstration purposes, linear self-equivalences are very insecure):
```
sage -python -m white_box_speck --block-size 32 --key-size 64 --self-equivalences linear 1918 1110 0908 0100
$ sage -python -m white_box_speck --block-size 32 --key-size 64 --self-equivalences linear 1918 1110 0908 0100
```

Generating a white-box `Speck64/128` implementation with debug logging enabled:
```
sage -python -m white_box_speck --block-size 64 --key-size 128 --debug 1b1a1918 13121110 0b0a0908 03020100
$ sage -python -m white_box_speck --block-size 64 --key-size 128 --debug 1b1a1918 13121110 0b0a0908 03020100
```

Generating a white-box `Speck128/256` implementation in the `out` directory:

```
sage -python -m white_box_speck --block-size 128 --key-size 256 --output-dir out 1f1e1d1c1b1a1918 1716151413121110 0f0e0d0c0b0a0908 0706050403020100
$ sage -python -m white_box_speck --block-size 128 --key-size 256 --output-dir out 1f1e1d1c1b1a1918 1716151413121110 0f0e0d0c0b0a0908 0706050403020100
```

## Attacks

As mentioned, the `attacks` directory contains proof-of-concept implementations of attacks to recover self-equivalence encodings and external encodings from a white-box Speck implementation. The attacks can be tested by running the Python scripts:
```
sage -python attacks/linear.py
$ sage -python attacks/linear.py
```
or
```
sage -python attacks/anf.py
$ sage -python attacks/anf.py
```

This will output the results of the attack (i.e. whether the master key and external encodings could be recovered), for each Speck parameter set.

0 comments on commit 15a5b3f

Please sign in to comment.