[OTBN] Integrate compression option for imem and dmem#30163
Open
siemen11 wants to merge 5 commits into
Open
Conversation
Contributor
|
interesting idea. kindly, what is the code size overhead of the addition. I'd assume significantly smaller than the saving. |
Contributor
Author
We require an additional ~400 bytes for the decompression algorithm but save ~7000 bytes |
cd68be9 to
506e010
Compare
506e010 to
0f5b321
Compare
Contributor
Author
|
Some quick overview for the choice of compression algorithms provided by Gemini:
Currently, LZ4 was chosen since it saves already quite a bit and it would be the least invasive in speed or RAM usage |
7c46b9d to
6c530c1
Compare
Update python versions using gen-python-requirements.sh Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
c2200af to
673988c
Compare
Contributor
Author
|
Collateral is that otbn_sca and otbn_fi have to use only drivers/otbn (compressed binaries) and not otbn_dif (uncompressed binaries) |
Remove dif_otbn from the dependencies in pentest, instead use crypto/drivers/otbn. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Add lz4 to the python dependencies. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Add the lz4 decompression algorithm. This algorithm costs around 400 bytes. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
Use LZ4 to add a compression option in otbn_binary (activated by setting compress = True). If this is set, the imem and dmem of the otbn application are compressed before they are stored. By default, binaries are not compressed. Change the otbn.c and otbn.h in the cryptolib to use LZ4 from lib/base in order to decompress the loaded imem and dmem from an application. The compression option is therefore mandatory in the cryptolib (lib/crypto), however, the applications from silicon_creator (using silicon_creator/lib/drivers/otbn.c/h) still use the uncompressed version (and will not work with the compressed version). This option saves the cryptolib ~7000bytes while increasing ~400bytes to load LZ4.c while providing backwards compatability for the boot. Concerning the CRC: The CRC for the imem/dmem is calculated before compression. For loading to OTBN, the OTBN is given the CRC of the uncompressed payload before and checks itself the CRC of what it receives. I.e., the CRC still provides end-2-end protection. Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
673988c to
7a55643
Compare
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use LZ4 to add a compression option in otbn_binary (activated by setting
compress = True). If this is set, the imem and dmem of the otbn
application are compressed before they are stored.
By default, binaries are not compressed.
Change the otbn.c and otbn.h in the cryptolib to use LZ4 from lib/base
in order to decompress the loaded imem and dmem from an application.
The compression option is therefore mandatory in the cryptolib
(lib/crypto), however, the applications from silicon_creator (using
silicon_creator/lib/drivers/otbn.c/h) still use the uncompressed version
(and will not work with the compressed version).
Concerning the CRC: The CRC for the imem/dmem is calculated before
compression. For loading to OTBN, the OTBN is given the CRC of the
uncompressed payload before and checks itself the CRC of what it
receives. I.e., the CRC still provides end-2-end protection.