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

Error in RNG in mbedtls file #186

Closed
samryanuofl opened this issue Mar 14, 2024 · 1 comment
Closed

Error in RNG in mbedtls file #186

samryanuofl opened this issue Mar 14, 2024 · 1 comment
Assignees

Comments

@samryanuofl
Copy link

#if (CONFIG_EXAMPLE_MATTER) && (CONFIG_ENABLE_MATTER_PRNG)
int ret = crypto_init();
if (ret != SUCCESS)
{
printf("crypto_init() failed\r\n");
return ret;
}
ret = crypto_random_generate(output, output_len);
if (ret != 0)
ret = 0xac // CHIP_ERROR_INTERNAL
return ret;
#else

Missing semicolon at the end of this line causes a compilation error if this code is enabled.

ret = 0xac // CHIP_ERROR_INTERNAL 

Also, should there be context protection here? Like

device_mutex_lock(RT_DEV_LOCK_CRYPTO);
int ret = crypto_init(); 
if (ret != SUCCESS) 
{ 
   printf("crypto_init() failed\r\n"); 
   device_mutex_unlock(RT_DEV_LOCK_CRYPTO);
   return ret; 
} 
  
ret = crypto_random_generate(output, output_len); 
device_mutex_unlock(RT_DEV_LOCK_CRYPTO);
if (ret != 0) 
    ret = 0xac; // CHIP_ERROR_INTERNAL 

return ret;
#else
@xshuqun xshuqun self-assigned this Mar 18, 2024
@xshuqun
Copy link
Collaborator

xshuqun commented Mar 22, 2024

@samryanuofl Thanks for informing. PR has been created to fix the issue #188.
Please do check it, and close the issue if there is no further question on it.

@xshuqun xshuqun closed this as completed Apr 1, 2024
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

No branches or pull requests

2 participants