nrf_crypto_allocator.h

Hi,

I have no "nrf_crypto_allocator.h" in Components. Can anyone help me where to find this file?

Parents
  • Hi, sure

    The cryptographic functions need some memory to operate with. This memory can be "allocated" to the crypto functions in various ways - statically to the stack, or dynamically, to heap memory. This is not specific to Nordic chips, you could read more about it here: https://www.geeksforgeeks.org/difference-between-static-and-dynamic-memory-allocation-in-c/

    Dynamic (heap) memory allocation uses some algorithm to find free memory and reserve it for your function. For some advanced users, it might be desirable to use a custom algorithm or mechanism to allocate memory. For those users, NRF_CRYPTO_ALLOCATOR can be set to 1 (User Macros). If this option is selected, the user has to provide their own functions for allocating memory, declared through nrf_crypto_allocator.h.

    But, as stated by my colleague in a similar case, option 1 (and therefore the header file) is usually not needed:/nrf_crypto_allocator.h: No such file or directory

    Please try setting NRF_CRYPTO_ALLOCATOR to 0, to use the default allocator.

    Or, if your previous colleague really found need to use a custom allocator, you will have to find out why they made this decision, and if it's still relevant, you should implement the functions NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK according to that need.

    I hope this clarifies things.

    Best regards,

    Raoul

Reply
  • Hi, sure

    The cryptographic functions need some memory to operate with. This memory can be "allocated" to the crypto functions in various ways - statically to the stack, or dynamically, to heap memory. This is not specific to Nordic chips, you could read more about it here: https://www.geeksforgeeks.org/difference-between-static-and-dynamic-memory-allocation-in-c/

    Dynamic (heap) memory allocation uses some algorithm to find free memory and reserve it for your function. For some advanced users, it might be desirable to use a custom algorithm or mechanism to allocate memory. For those users, NRF_CRYPTO_ALLOCATOR can be set to 1 (User Macros). If this option is selected, the user has to provide their own functions for allocating memory, declared through nrf_crypto_allocator.h.

    But, as stated by my colleague in a similar case, option 1 (and therefore the header file) is usually not needed:/nrf_crypto_allocator.h: No such file or directory

    Please try setting NRF_CRYPTO_ALLOCATOR to 0, to use the default allocator.

    Or, if your previous colleague really found need to use a custom allocator, you will have to find out why they made this decision, and if it's still relevant, you should implement the functions NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK according to that need.

    I hope this clarifies things.

    Best regards,

    Raoul

Children
No Data
Related