Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tvla] Add histogram based TVLA #71

Merged
merged 34 commits into from
May 24, 2022
Merged

[tvla] Add histogram based TVLA #71

merged 34 commits into from
May 24, 2022

Commits on May 13, 2022

  1. Add histogram based TVLA.

    Signed-off-by: Vladimir Rozic <vrozic@lowrisc.org>
    vrozic authored and vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    b0908fa View commit details
    Browse the repository at this point in the history
  2. [tvla] Fix and improve leakage computation, add new argument

    This commit contains several changes:
    1. Fix leakage model computation. Previously, only the initial round and
       the first 9 regular rounds were computed. The final round couldn't be
       analyzed.
    2. Now, all bytes and all rounds are computed. Basically when computing
       a single byte, the other bytes come for free. Similarly, if round 10
       is needed, all other rounds need to be computed anyway.
    3. The computed leakage model is saved to disk as traces.npy and using
       a new command line argument can be loaded in a later run to re-use
       previous intermediate results and speed up the analysis.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    d91e55f View commit details
    Browse the repository at this point in the history
  3. [tvla] Parallelize leakage model computation

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    2a8d809 View commit details
    Browse the repository at this point in the history
  4. [tvla] Enable saving and loading trace files after conversion to int

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    1b9aef6 View commit details
    Browse the repository at this point in the history
  5. [tvla] Add new argument to specify ChipWhisperer project file

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    9931cc4 View commit details
    Browse the repository at this point in the history
  6. [tvla] Rename some function arguments

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    9e30d67 View commit details
    Browse the repository at this point in the history
  7. [tvla] Add new input arguments for specifying trace range

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    accdee2 View commit details
    Browse the repository at this point in the history
  8. [tvla] Create separate function for computing histograms

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    8d622eb View commit details
    Browse the repository at this point in the history
  9. [tvla] Use numpy.histogram2d function

    This gives a performance improvement of nearly 100x compared to the
    previous implementation based on nested for loops.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    4ff9899 View commit details
    Browse the repository at this point in the history
  10. [tvla] Compute all rounds, all bytes, add new argument for selection

    This commit modifies the histograms & t-test computation as well as
    the plotting to run for all rounds and all bytes by default. Using new
    command line arguments, the user can specify a single round and/or a
    single byte if needed. Plots for all computed t-test results are saved
    and the script now prints results in text format, highlighting in which
    rounds and bytes, leakage above the threshold has been detected.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    f57289c View commit details
    Browse the repository at this point in the history
  11. [tvla] Parallelize histograms computation

    This commit parallelizes the histograms computation across samples.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    b4de7d5 View commit details
    Browse the repository at this point in the history
  12. [tvla] Parallelize comptutation of t-test statistics

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    ef8fc71 View commit details
    Browse the repository at this point in the history
  13. [tvla] Save intermediate results, plots and temporary files under tmp/

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    564ea12 View commit details
    Browse the repository at this point in the history
  14. [tvla] Fix lint errors and warnings

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    085d0ec View commit details
    Browse the repository at this point in the history
  15. [tvla] Only compute var and sigma if required for selected T-test order

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    5452139 View commit details
    Browse the repository at this point in the history
  16. [tvla] Filter out noisy traces

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    eb902b6 View commit details
    Browse the repository at this point in the history
  17. [tvla] Use logging to simultaneously print to stdout and into a log file

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    9023537 View commit details
    Browse the repository at this point in the history
  18. [tvla] Handle empty sets

    In case either the fixed or random set is empty, the statistics can't
    be computed. This can happen e.g. if few traces are used only, or if
    using the hamming distance as sensitive variable and analyzing the
    initial round. In the latter case, the hamming distance can only be
    zero or non-zero if the corresponding key byte is zero or non-zero,
    respectively. Thus, either the fixed or the random set is empty.
    
    Previously we anyway computed the statistics producing meaningless
    results. With this commit, we don't try to compute the statistics
    anymore if either of the sets is empty and report this to the user.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    89ae257 View commit details
    Browse the repository at this point in the history
  19. [tvla] Optimize t-test computation

    This commit switches to a t-test function provided by scipy which
    operates on arrays. Also, the code around the t-test function is
    refactored to make better use of numpy.ndarrays, to reduce the amount
    of control code and to reduce the number of loops. All this allows for
    a speedup of 20x for the t-test computation.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    990e777 View commit details
    Browse the repository at this point in the history
  20. [tvla] TVLA support for general tests

    Added support for general fixed-vs-random TVLA.
    
    Signed-off-by: vrozic <vrozic@lowrisc.org>
    vrozic authored and vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    8c267c7 View commit details
    Browse the repository at this point in the history
  21. [tvla] Allow appending more data to previously generated histograms

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    1b55386 View commit details
    Browse the repository at this point in the history
  22. [tvla] Enable step-wise processing, add usability improvements

    The most important change of this commit is that it adds the option for
    step-wise processing of trace sets using the `-n` argument and related
    to that the capability to plot how the t-test values evolve with
    increasing number of traces. Other usability improvements include:
    - Filtered traces and the computed leakage are only saved to disk if
      the `-d` argument is provided.
    - Figures are only plotted and saved to disk if the `-f` argument is
      provided.
    - The t-test results can be written to disk using the `-d` argument.
      They can be loaded with the `-a` argument to only display results and
      plot figures if really needed. The results table is always printed.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    5be3231 View commit details
    Browse the repository at this point in the history
  23. [tvla] Integrate support for general fixed-vs-random TVLA into tvla.py

    This allows both specific AES TVLA (as we were doing before) and fixed-
    vs-random TVLA for AES and SHA3 using a single code base.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    3227625 View commit details
    Browse the repository at this point in the history
  24. [tvla] Fixes a bug when bulding the random set

    Fixes a way that a random set is constructed when running tvla
    general tests.
    
    Signed-off-by: vrozic <vrozic@lowrisc.org>
    vrozic authored and vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    681e8e2 View commit details
    Browse the repository at this point in the history
  25. [tvla] Fix specific AES TVLA

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    44a6433 View commit details
    Browse the repository at this point in the history
  26. [tvla] Increase ADC resolution for Husky

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    8ccb8e2 View commit details
    Browse the repository at this point in the history
  27. [tvla] Correct comment regarding general fixed-vs-random TVLA

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    b3d2869 View commit details
    Browse the repository at this point in the history
  28. [tvla] Add support for random-order measurements

    Add support for fixed-vs-random key TVLA when measurements are
    taken in random order (rather than alternating between fixed and
    random). The analysis works under the assumption is that the first
    trace in the project is generated using a fixed key.
    
    Signed-off-by: vrozic <vrozic@lowrisc.org>
    vrozic authored and vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    f664681 View commit details
    Browse the repository at this point in the history
  29. Make tvla script compatible with AES General Test: FvsR Key traces.

    Signed-off-by: Abdullah Varici <abdullah.varici@lowrisc.org>
    Abdullah Varici authored and vogelpi committed May 13, 2022
    Configuration menu
    Copy the full SHA
    f5ef143 View commit details
    Browse the repository at this point in the history

Commits on May 17, 2022

  1. [tvla] Adjust window ranges for ttest_step plots

    The inrease in sampling rate by 2x and the trigger offset needs to be
    accounted for when plotting these figures.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 17, 2022
    Configuration menu
    Copy the full SHA
    5fa4ad6 View commit details
    Browse the repository at this point in the history
  2. [tvla] Add support for uint16 trace files

    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 17, 2022
    Configuration menu
    Copy the full SHA
    2fd318e View commit details
    Browse the repository at this point in the history
  3. [tvla] Remove offset subtraction on converted traces

    This is not actually needed but may have a slightly negative impact when
    doing more than one step as the offset may vary with each step.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 17, 2022
    Configuration menu
    Copy the full SHA
    d6634fe View commit details
    Browse the repository at this point in the history
  4. [tvla] Fix bug in specific AES TVLA for only a subset of bytes/rounds

    Without this commit, it could happen that the wrong bytes/rounds would
    be selected for the final results/figure plotting step in case only a
    subset of bytes/rounds were analyzed.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi committed May 17, 2022
    Configuration menu
    Copy the full SHA
    0924069 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2022

  1. [tvla] Optimize performance and memory consumption of specific AES TVLA

    Previously, we were generating 9 histograms one for each possible
    Hamming weight of the sensitive variable. But the actual statistics
    are then computed by combining the 8 histograms for the non-zero Hamming
    weights (fixed vs. random). It this therefore more efficient to only
    generate 2 histograms in the first place. One for Hamming weight = 0 and
    one for Hamming weight > 0. Most importantly, this leads to a reduction
    in memory footprint of roughly 4.5x.
    
    Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
    vogelpi authored and alphan committed May 18, 2022
    Configuration menu
    Copy the full SHA
    8d30598 View commit details
    Browse the repository at this point in the history