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

[top] Add AES unit #576

Merged
merged 4 commits into from Oct 25, 2019
Merged

[top] Add AES unit #576

merged 4 commits into from Oct 25, 2019

Conversation

vogelpi
Copy link
Contributor

@vogelpi vogelpi commented Oct 23, 2019

This PR adds the AES unit to the top-level of earlgrey.

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 23, 2019

Also pinging @rasmus-madsen and @martin-lueker to keep them in the loop.

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 23, 2019

Regarding DV: Basic functionality has been verified using a Verilator-based framework that is not in the tree currently. The real DV is work in progress by Rasmus.

@rasmus-madsen
Copy link
Contributor

Regarding DV: Basic functionality has been verified using a Verilator-based framework that is not in the tree currently. The real DV is work in progress by Rasmus.

Yes I am working on this, the current status is that I have been debugging a register issue that was rootcaused to a problem in the one of the autogen scripts. Weicai has solved the issue and I am in the process of rebasing my branch to get the updates.

next issue is there is no active support for multiregs as I understand it. but I will see if I can't get it to work.

Copy link
Contributor

@msfschaffner msfschaffner left a comment

Choose a reason for hiding this comment

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

LGTM, but I think @eunchan should give it a quick look as well.

@msfschaffner
Copy link
Contributor

LGTM, but I think @eunchan should give it a quick look as well.

Did you run a top-level simulation or FPGA build to check whether it impacts the existing functionality?

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 23, 2019

I ran FPGA synthesis to evaluate the cost of enabling support for AES-192 (currently around 25%) but I did not run simulations or the like. I guess CI will do both, right?

@tjaychen
Copy link

tjaychen commented Oct 23, 2019 via email

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 23, 2019

The OpenOCD test suite runs through as usual.

@tjaychen That's a good idea. I will implement and add a simple sanity test for the AES module.

Copy link
Contributor

@eunchan eunchan left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

I think @weicaiyang should be aware of this change as he is focusing on TL-UL crossbar DV.

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 24, 2019

I have created a driver for the AES unit and a test application. It works. What is missing is the intermediate layer, i.e., the actual HW crypto API that calls the AES driver/DIF underneath (similar to hw_hmac). Anyway, this does not belong into this PR here. I will create another one for the software, possibly a draft one since there is more urgent stuff around at the moment than implementing the crypto API for AES.

Bottom line: I would be happy to get this approved and merged, before it's getting stale.

@asb
Copy link
Member

asb commented Oct 25, 2019

With the reviews you have my impression is it's good to go in - perhaps with a final ok from @sjgitty? Or is there a particular review you're waiting on?

@msfschaffner msfschaffner self-requested a review October 25, 2019 01:22
Copy link
Contributor

@msfschaffner msfschaffner 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
Copy link
Contributor Author

vogelpi commented Oct 25, 2019

Thanks for approving @msfschaffner !

I wasn't waiting for a particular review, but wanted to first write a basic test that makes the core use the module. This test is now in the following draft PR: #627.

Given the high load of most people at the moment, I will no longer wait and merge now.

This commit changes the `clock_primary` field to `clk_i` and introduces
two parameters to define the `count` field of the multiregs.
This input port is usually not exposed to the IP interface but
statically driven inside the top-level IP wrapper.
This commit adds an assertion to check that outputs always have a known
value after reset.

This is related to #405.
@vogelpi vogelpi merged commit d453438 into lowRISC:master Oct 25, 2019
@vogelpi vogelpi deleted the add-aes-unit branch October 25, 2019 10:02
@cdgori
Copy link

cdgori commented Oct 28, 2019 via email

@vogelpi
Copy link
Contributor Author

vogelpi commented Oct 30, 2019

Hi @cdgori ,
there is already a similar example for HMAC to what I am doing in #627. This is independent of the actual DV. The idea is to have a quick sanity test to make sure the module is properly integrated into the top and accessible to software.

In the end, I think it would be useful to have such an example for every accelerator as it can also show how to actually use the module. However, if we want to provide examples, we might want to discuss first how software should interface the libraries and how to handle keys etc. Let's continue this discussion in in #627 or a separate issue.

@cdgori
Copy link

cdgori commented Oct 30, 2019 via email

@@ -19,7 +32,7 @@
starting encryption/decryption of the next block. Can only be updated
when the AES unit is idle.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you mention what happens if the engine is not idle?
"writes to the register while the engine is active are <dropped? cause error?>"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, it is just not safe to do. The current block will use the old value and next block will use the new/intermediate value if the key is not fully configured. I would like to change this according to what has been done for HMAC in #1014, i.e., ignore key updates while the unit is busy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The corresponding change is in PR #1053.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants