Skip to content

[crypto] Prepare for version increment - #30916

Open
siemen11 wants to merge 2 commits into
lowRISC:earlgrey_1.0.0from
siemen11:crypto_version_readiness
Open

[crypto] Prepare for version increment#30916
siemen11 wants to merge 2 commits into
lowRISC:earlgrey_1.0.0from
siemen11:crypto_version_readiness

Conversation

@siemen11

@siemen11 siemen11 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Cryptolib uses kOtcryptoLibVersion1 as version of the library and in key configs.
This commit adds a kOtcryptoLibVersion2 magic number.

We create a new API call otcrypto_lib_version() which returns the version of the library. We then switch all tests and internal cryptolib functions to use this call to automatically reference the current version.

Integrity was also rejecting keys which did not set the current version number, however, the library has to be backward compatible, so we removed the check. Later on, we can decide what to do on certain version numbers.

The documentation was also updated in this regard.

@siemen11
siemen11 requested a review from a team as a code owner August 4, 2026 13:59
@siemen11
siemen11 requested review from andrea-caforio, johannheyszl, nasahlpa and timothytrippel and removed request for a team and timothytrippel August 4, 2026 13:59
@siemen11 siemen11 added the CherryPick:master This PR should be cherry-picked to master label Aug 4, 2026
@siemen11
siemen11 force-pushed the crypto_version_readiness branch from 12b2b7a to ba3e0f8 Compare August 4, 2026 16:18
@siemen11 siemen11 added the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@github-actions github-actions Bot removed the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@siemen11 siemen11 added the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@github-actions github-actions Bot removed the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@siemen11 siemen11 added the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@github-actions github-actions Bot removed the CI:Rerun Rerun failed CI jobs label Aug 4, 2026
@siemen11 siemen11 added the CI:Rerun Rerun failed CI jobs label Aug 5, 2026
@github-actions github-actions Bot removed the CI:Rerun Rerun failed CI jobs label Aug 5, 2026
@siemen11 siemen11 added the CI:Rerun Rerun failed CI jobs label Aug 5, 2026
@github-actions github-actions Bot removed the CI:Rerun Rerun failed CI jobs label Aug 5, 2026

@nasahlpa nasahlpa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Siemen, I agree that it makes sense that CL has a single ground of truth (otcrypto_lib_version) rather than directly using kOtcryptoLibVersion1


static const otcrypto_key_config_t kEd25519PrivateKeyConfig = {
.version = kOtcryptoLibVersion1,
.version = kCryptoLibVersion,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems we are a bit mixing kCryptoLibVersion and otcrypto_lib_version(). Shouldn't we use the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks indeed messy, made it all otcrypto_lib_version

@siemen11
siemen11 force-pushed the crypto_version_readiness branch 2 times, most recently from 69e7b7b to 4491a5c Compare August 5, 2026 11:24

@johannheyszl johannheyszl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @siemen11 !

@siemen11
siemen11 force-pushed the crypto_version_readiness branch 4 times, most recently from 342230f to c068aa9 Compare August 5, 2026 16:49
@siemen11
siemen11 force-pushed the crypto_version_readiness branch 2 times, most recently from 8274242 to 5831c65 Compare August 6, 2026 08:52
@siemen11
siemen11 force-pushed the crypto_version_readiness branch 3 times, most recently from 8c26b47 to 9bedc61 Compare August 6, 2026 11:47
Cryptolib uses kOtcryptoLibVersion1 as version of the library and in key
configs.
This commit adds a kOtcryptoLibVersion2 magic number.

We create a new API call otcrypto_lib_version() which returns the
version of the library. We then switch all tests and internal cryptolib
functions to use this call to automatically reference the current
version.

Integrity was also rejecting keys which did not set the current version
number, however, the library has to be backward compatible, so we
removed the check. Later on, we can decide what to do on certain version
numbers.

The documentation was also updated in this regard.

Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
As we would move to higher version numbers for the library, we allow for
migration options to increment older key version numbers. As such, we
add to the documentation, add the api function (which is just a simple
function from now checking it is the current version), and the integrity
check checks whether we are on the current version and would reject if
it is not the case.

For clarity, only blinded keys have a version, unblinded keys do not.
The version is mainly there for masking.

Due to hardware keys using their version numbers as part of the
diversifier, we can not migrate those.

Signed-off-by: Siemen Dhooghe <sdhooghe@google.com>
@siemen11
siemen11 force-pushed the crypto_version_readiness branch from 9bedc61 to 19be08a Compare August 6, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CherryPick:master This PR should be cherry-picked to master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants