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

[sca] Add AES fixed-vs-random Data capture mode #20821

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

vrozic
Copy link
Contributor

@vrozic vrozic commented Jan 12, 2024

  1. The first commit modifies aes-fvsr-key-batch capture to be consistent with other captures and to update outdated comments.
  2. The second commit modifies LFSR functions to enable running multiple LFSR
  3. The third commit enables AES serial fixed-vs-random data capture
  4. The last commit does the same for uJSON

@vrozic vrozic force-pushed the aes-fvsr-data branch 2 times, most recently from 38191bd to 6262a0f Compare January 12, 2024 17:46
vrozic added a commit to vrozic/ot-sca that referenced this pull request Jan 22, 2024
New binaries generated from
lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
@vrozic vrozic changed the title [sca] Add fvsr Data mode to aes_serial [sca] Add AES fixed-vs-random Data capture mode Jan 22, 2024
@vrozic vrozic marked this pull request as ready for review January 22, 2024 12:10
@vrozic vrozic requested a review from a team as a code owner January 22, 2024 12:10
@vrozic vrozic requested review from jadephilipoom, nasahlpa and vogelpi and removed request for a team and jadephilipoom January 22, 2024 12:10
vrozic added a commit to vrozic/ot-sca that referenced this pull request Jan 23, 2024
Binaries are generated from
lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vrozic for working on this. I have some questions regarding the additional PRNG and the storing of the key (fixed and equal for both sets).

sw/device/sca/aes_serial.c Outdated Show resolved Hide resolved
sw/device/sca/aes_serial.c Outdated Show resolved Hide resolved
sw/device/sca/aes_serial.c Outdated Show resolved Hide resolved
sw/device/sca/aes_serial.c Show resolved Hide resolved
@vogelpi
Copy link
Contributor

vogelpi commented Jan 23, 2024

Note that so far I've reviewed the simpleserial side only. Let's first iterate on this and then carry the final changes over to the uJSON implementation. At this point, it will be good if also @nasahlpa can review.

@vrozic vrozic force-pushed the aes-fvsr-data branch 2 times, most recently from c1e6194 to e1133c7 Compare January 29, 2024 13:17
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these changes and explaining the need for the LFSR context. The simple_serial implementation looks good to me now modulo one question regarding reseeding the second LFSR.

Comment on lines +700 to +716
// Initial state of the prng
static const uint32_t kPrngInitialState = 0x99999999;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if this initial state could be provided via simpleserial. Because right now it's fixed at compile time. As this PR already alters the command, you could easily also add a second uint32 value with the LFSR seed. Do you think this would be feasible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now added a separate command aes_serial_seed_lfsr_order to re-seed the second LFSR.
This way, it's easier to handle from the ot-sca side. The user just needs to run this command after aes_serial_set_default_values and before aes_serial_fvsr_data_batch_encrypt.

I've also kept the default value of 0x99999999 in case that the user doesn't want to use this feature.

sw/device/sca/aes_serial.c Outdated Show resolved Hide resolved
Copy link
Member

@nasahlpa nasahlpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vrozic , I had a look into the uJSON code only - that looks good.
As we need to use the sival branch to build uJSON SCA-binaries, could you please add the CherryPick:earlgrey_es_sival label to this PR? This ensures that this PR also gets merged into the sival branch.

Support for the new uJSON command is not yet implemented on the ot-sca side? Just let me know if I can support you there, it would be good to keep host and device side functionality as close together as possible.

sw/device/tests/crypto/cryptotest/firmware/aes_sca.c Outdated Show resolved Hide resolved
@vrozic vrozic force-pushed the aes-fvsr-data branch 2 times, most recently from 5e9dcc7 to b934388 Compare February 2, 2024 12:07
@vrozic vrozic added the CherryPick:master This PR should be cherry-picked to master label Feb 2, 2024
@nasahlpa nasahlpa added CherryPick:earlgrey_es_sival This PR should be cherry-picked to earlgrey_es_sival and removed CherryPick:master This PR should be cherry-picked to master labels Feb 2, 2024
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 2, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
@vrozic
Copy link
Contributor Author

vrozic commented Feb 2, 2024

Thanks @vogelpi and @nasahlpa for the reviews. I've made the required changes.

Thanks @nasahlpa for explaining to me how to generate the binaries with the new process.
I've updated ot-sca PR 295 with the new binaries. Both serial and uJSON captures work on my local CW310 setup.

vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 2, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
This commit ammends AES fixed-vs-random key dataset capture:
1. Updates the outdated description of the PRNG used for data
   generation
2. Acknowledges command in aes_serial capture method. This change
   improves the stability of measurements.
3. Returns the full 16B ciphertect of the last encryption in the
   batch. This is changed from only sending the last 4 bytes.
   This change makes it consistent with other batch measurements,
   making the code easier to maintain.

Signed-off-by: Vladimir Rozic <[email protected]>
At the moment, a 32-bit SW LFSR is used for masking data shares
sent from IBEX to crypto-blocks (AES, KMAC, SHA3).
This commit adds a new context to this PRNG so that it can be used
for multiple purposes. This is needed to set the stage for
implementing aes-fvsr-data capture which makes use of this LFSR
to determine the order of measurements.
This commit also ammends all files that make use of the lfsr
functions.

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 7, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vogelpi vogelpi merged commit 8618394 into lowRISC:master Feb 8, 2024
32 checks passed
Copy link

github-actions bot commented Feb 8, 2024

Successfully created backport PR for earlgrey_es_sival:

vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 8, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 13, 2024
    Binaries are updated to support aes-fvsr-data capture.
    These binaries are generated from:
        https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

    This branch is created by checking out:
        https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
    and cherry-picking commits from OpenTitan PR #20821:
        lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Feb 23, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Mar 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Mar 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Mar 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Mar 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
vrozic added a commit to vrozic/ot-sca that referenced this pull request Mar 6, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request May 9, 2024
Binaries are updated to support aes-fvsr-data capture.
The simpleserial binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

The uJSON binary was created from lowRISC/opentitan@ecd6e47

Signed-off-by: Vladimir Rozic <[email protected]>
nasahlpa pushed a commit to nasahlpa/ot-sca that referenced this pull request May 9, 2024
Binaries are updated to support aes-fvsr-data capture.
These binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

Signed-off-by: Vladimir Rozic <[email protected]>
nasahlpa added a commit to nasahlpa/ot-sca that referenced this pull request May 9, 2024
Binaries are updated to support aes-fvsr-data capture.
The simpleserial binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

The uJSON binary was created from lowRISC/opentitan@ecd6e47

Signed-off-by: Pascal Nasahl <[email protected]>
nasahlpa added a commit to lowRISC/ot-sca that referenced this pull request May 9, 2024
Binaries are updated to support aes-fvsr-data capture.
The simpleserial binaries are generated from:
    https://github.com/vrozic/opentitan/tree/make-binaries-aes-data

This branch is created by checking out:
    https://github.com/lowRISC/opentitan/tree/earlgrey_es_sival
and cherry-picking commits from OpenTitan PR #20821:
    lowRISC/opentitan#20821

The uJSON binary was created from lowRISC/opentitan@ecd6e47

Signed-off-by: Pascal Nasahl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPick:earlgrey_es_sival This PR should be cherry-picked to earlgrey_es_sival
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants