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

Audit findings #3

Merged
merged 5 commits into from
Jun 12, 2024

Conversation

relatko
Copy link
Collaborator

@relatko relatko commented Jun 4, 2024

No description provided.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@relatko relatko changed the base branch from develop to merging-with-onflow-latest-development-branch June 5, 2024 06:40
src/crypto.c Outdated
@@ -185,7 +185,7 @@ zxerr_t crypto_sign(const hd_path_t path,
sizeof(messageDigest),
&messageDigestSize));

if (messageDigestSize != 32) {
if (messageDigestSize != CX_SHA256_SIZE) {
Copy link

@tarakby tarakby Jun 5, 2024

Choose a reason for hiding this comment

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

  • I think the audit report pointed to replacing the 32 on this line. However, I don't agree with the report suggestion. There should be a new defined constant CX_SHA3_256_SIZE (also equal to 32). SHA256 refers to SHA-2, while here we are working with SHA-3

  • The line modified in this PR should actually remain 32, or should be replaced by another new constant (the elliptic curve order size), otherwise the check doesn't make sense from a cryptographic perspective. In this specific case, all constants happen to be 32 and the code passes, but if we evolve the code to support more curves/hashing, the code would become incorrect (EDIT: after thinking more on this, it can be fine to check against the expected hash output only, if the later signing function checks for curve/hash compatibility)

Copy link

@tarakby tarakby Jun 5, 2024

Choose a reason for hiding this comment

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

I can make a minor suggestion PR in a few hours to clean up the magic numbers from a cryptographic point of a view. It would only improve the code readability, but wouldn't have any functional change on the current code.

Copy link

Choose a reason for hiding this comment

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

here is my suggestion PR: #4

@relatko relatko force-pushed the audit_findings branch 2 times, most recently from efffc6d to 4dff0a0 Compare June 6, 2024 17:03
@relatko relatko merged commit 0c12067 into merging-with-onflow-latest-development-branch Jun 12, 2024
38 checks passed
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.

2 participants