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

Add benchmark for public and private key parsing #4793

Merged
merged 3 commits into from
Mar 28, 2025

Conversation

randombit
Copy link
Owner

Plus various optimizations driven by this

@randombit randombit requested a review from reneme March 26, 2025 13:15
@coveralls
Copy link

coveralls commented Mar 26, 2025

Coverage Status

coverage: 91.514% (-0.02%) from 91.533%
when pulling 2390aa9 on jack/pk-parsing-bench
into 399720d on master.

@randombit randombit force-pushed the jack/pk-parsing-bench branch from f90edeb to 2390aa9 Compare March 26, 2025 22:36
…SN.1 case

For every other constructor we are willing to assume the bit length is public;
this just pessimizes the case when the key is loaded from PKCS8
Historically this function made some attempts to be constant-time-ish (despite
not being constant time at all), largely because it was the only implemented
division algorithm. Now we have dedicated constant time division algorithms
which are used for secret data; we can readily assume the inputs to
vartime_divide are public.
@randombit randombit force-pushed the jack/pk-parsing-bench branch from 2390aa9 to bc97a9b Compare March 28, 2025 12:47
Comment on lines +283 to +289
for(size_t k = 0; k != 2; ++k) {
if(division_check_vartime(qjt, y_t0, y_t1, x_j0, x_j1, x_j2)) {
qjt--;
} else {
break;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code is a bit cleaner without the upper bound

😁

Suggested change
for(size_t k = 0; k != 2; ++k) {
if(division_check_vartime(qjt, y_t0, y_t1, x_j0, x_j1, x_j2)) {
qjt--;
} else {
break;
}
}
for(size_t k = 0; k != 2 && ! division_check_vartime(qjt, y_t0, y_t1, x_j0, x_j1, x_j2); ++k, --gjt);
BOTAN_DEBUG_ASSERT(!division_check(qjt, y_t0, y_t1, x_j0, x_j1, x_j2));

... I'm not sure. 😅

Copy link
Owner Author

Choose a reason for hiding this comment

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

I am sure that is fucking hideous :)

@randombit randombit merged commit c3f147f into master Mar 28, 2025
41 checks passed
@randombit randombit deleted the jack/pk-parsing-bench branch March 28, 2025 21:56
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.

3 participants