Skip to content

Conversation

@ColtonWilley
Copy link
Contributor

Optimize FIPS CAST startup tests with per algo mutex handling for thread safe lazy CAST.

@ColtonWilley
Copy link
Contributor Author

jenkins retest this please

#define WP_CHECK_FIPS_ALGO(algo) \
do { \
if (wp_init_cast(algo) != 1) { \
WOLFPROV_ERROR_MSG(WP_LOG_COMP_PROVIDER, \
Copy link
Contributor

Choose a reason for hiding this comment

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

There could be a code size hit due to the frequency of these macros (mainly from duplicate logs). Is that ok?

Could convert to functions I suppose, but might make the caller size a bit less clean.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just move the log into wp_init_cast

/* Dispatch to algorithm-specific inner function */
switch (algo) {
#ifdef WP_HAVE_AES
case WP_CAST_ALGO_AES:
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation looks off in this switch

}

if (castAlgos[algo].init == 0) {
if (wp_lock(wp_get_cast_mutex(algo)) != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wp_get_cast_mutex is only called from this function, and this function already indexes into castAlgos[algo]. I'd say to use castAlgos[algo].mutex directly here.

* @return Initialization state (0 = not initialized, 1 = initialized).
* @return 0 if algo is out of range.
*/
int wp_get_cast_init(int algo)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function doesn't appear to be called

* @param [in] algo Algorithm category (WP_CAST_ALGO_*).
* @param [in] init Initialization state to set.
*/
void wp_set_cast_init(int algo, int init)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also seemingly not called

* @return 1 on success.
* @return 0 on failure.
*/
static int wp_rsa_init_cast_inner(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all the wrapper functions? Can we do the calls to wc_RunCast_* directly in the switch?

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