This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

error in mbedtls_ecp_gen_keypair()

Hello,

I am using nRF52840, SDK16 & SoftDevice140.

I am integrating pm_init()(Peer Manager) into my project and I am getting error 0xFFFFB180 from mbedtls_ecp_gen_keypair(). I looked out for the problem and find this thread which says there may be a problem of mbed libraries.

I am already using AES-ECB-256 encryption (mbedtls library) in my code. I don't think so but to be sure, can that be a cause of this error?

Kindly help me out!

Parents
  • Hi,

    I do not immediately see the link. Do you have a piece of code you can upload that reproduces this on a DK?

  • I don't have any different code because I am ported my code to the design of our custom board. But for this problem, I have just copied the peer_manager_init() from ble_app_hrs example.

    Before adding that I had already added crypto libraries for another purpose and as mentioned earlier, I needed 256-bit encryption so instead of using CC310, I am using mbedtls library. So all the crypto libraries were already there to support peer_manager_init().

    Now when I run, I get the error 0xFFFFB180 in mbedtls_ecp_gen_keypair() (peer_manager_init --> pm_init --> sm_init --> nrf_ble_lesc_init --> nrf_ble_lesc_keypair_generate--> nrf_crypto_ecc_key_pair_generate --> nrf_crypto_backend_mbedtls_key_pair_generate --> mbedtls_ecp_gen_keypair)

  • Hi,

    I have managed to reproduce this, and get memory corruption in mbed TLS using the default sdk_config.h memory manager configurations from the BLE peripheral examples, which do not use mbed TLS by default. Modifying the configuration like this fixed the issue (sdk_config.h snippet):

    ...
    
    // <e> MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator
    //==========================================================
    #ifndef MEM_MANAGER_ENABLED
    #define MEM_MANAGER_ENABLED 1
    #endif
    // <o> MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT
    #define MEMORY_MANAGER_SMALL_BLOCK_COUNT 128
    #endif
    
    // <o> MEMORY_MANAGER_SMALL_BLOCK_SIZE -  Size of each memory blocks identified as 'small' block. 
    // <i>  Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE
    #define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32
    #endif
    
    // <o> MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT
    #define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 64
    #endif
    
    // <o> MEMORY_MANAGER_MEDIUM_BLOCK_SIZE -  Size of each memory blocks identified as 'medium' block. 
    // <i>  Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE
    #define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 64
    #endif
    
    // <o> MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_LARGE_BLOCK_COUNT 32
    #endif
    
    // <o> MEMORY_MANAGER_LARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'large' block. 
    // <i>  Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_LARGE_BLOCK_SIZE 128
    #endif
    
    // <o> MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 8
    #endif
    
    // <o> MEMORY_MANAGER_XLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra large' block. 
    // <i>  Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 256
    #endif
    
    // <o> MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 4
    #endif
    
    // <o> MEMORY_MANAGER_XXLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra extra large' block. 
    // <i>  Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 2048
    #endif
    
    ...

Reply
  • Hi,

    I have managed to reproduce this, and get memory corruption in mbed TLS using the default sdk_config.h memory manager configurations from the BLE peripheral examples, which do not use mbed TLS by default. Modifying the configuration like this fixed the issue (sdk_config.h snippet):

    ...
    
    // <e> MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator
    //==========================================================
    #ifndef MEM_MANAGER_ENABLED
    #define MEM_MANAGER_ENABLED 1
    #endif
    // <o> MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT
    #define MEMORY_MANAGER_SMALL_BLOCK_COUNT 128
    #endif
    
    // <o> MEMORY_MANAGER_SMALL_BLOCK_SIZE -  Size of each memory blocks identified as 'small' block. 
    // <i>  Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE
    #define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32
    #endif
    
    // <o> MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT
    #define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 64
    #endif
    
    // <o> MEMORY_MANAGER_MEDIUM_BLOCK_SIZE -  Size of each memory blocks identified as 'medium' block. 
    // <i>  Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE
    #define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 64
    #endif
    
    // <o> MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_LARGE_BLOCK_COUNT 32
    #endif
    
    // <o> MEMORY_MANAGER_LARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'large' block. 
    // <i>  Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_LARGE_BLOCK_SIZE 128
    #endif
    
    // <o> MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 8
    #endif
    
    // <o> MEMORY_MANAGER_XLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra large' block. 
    // <i>  Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 256
    #endif
    
    // <o> MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block.  <0-255> 
    
    
    #ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT
    #define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 4
    #endif
    
    // <o> MEMORY_MANAGER_XXLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra extra large' block. 
    // <i>  Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized.
    
    #ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE
    #define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 2048
    #endif
    
    ...

Children
Related