LCOV - code coverage report
Current view: top level - test - entropy.c (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 9 9
Test Date: 2026-01-29 09:48:10 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 62.5 % 8 5

             Branch data     Line data    Source code
       1                 :             : #include <zephyr/kernel.h>
       2                 :             : #include <zephyr/device.h>
       3                 :             : #include <zephyr/drivers/entropy.h>
       4                 :             : #include <mbedtls/entropy.h>
       5                 :             : #include <entropy_poll.h>
       6                 :             : 
       7                 :           2 : int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len,
       8                 :             :                           size_t *olen)
       9                 :             : {
      10                 :             :         // const struct device *dev;
      11                 :             :         // size_t chunk_size;
      12                 :             : 
      13                 :           2 :         (void)data;
      14                 :             : 
      15         [ +  - ]:           2 :         if (output == NULL) {
      16                 :             :                 return -1;
      17                 :             :         }
      18                 :             : 
      19         [ +  - ]:           2 :         if (olen == NULL) {
      20                 :             :                 return -1;
      21                 :             :         }
      22                 :             : 
      23         [ +  - ]:           2 :         if (len == 0) {
      24                 :             :                 return -1;
      25                 :             :         }
      26                 :             : 
      27                 :             :         // dev = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL);
      28                 :             : 
      29                 :             :         // if (!dev) {
      30                 :             :         //      return MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED;
      31                 :             :         // }
      32                 :             : 
      33                 :             :         // while (len > 0) {
      34                 :             :         //      chunk_size = MIN(MBEDTLS_ENTROPY_MAX_GATHER, len);
      35                 :             : 
      36                 :             :         //      if (entropy_get_entropy(dev, output, chunk_size) < 0) {
      37                 :             :         //              return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED;
      38                 :             :         //      }
      39                 :             : 
      40                 :             :         //      *olen += chunk_size;
      41                 :             :         //      output += chunk_size;
      42                 :             :         //      len -= chunk_size;
      43                 :             :         // }
      44                 :             : 
      45                 :             :         /*We don't get real random numbers*/
      46         [ +  + ]:         258 :         for (size_t i = 0; i < len; i++) {
      47                 :         256 :                 output[i] = i;
      48                 :             :         }
      49                 :             : 
      50                 :           2 :         *olen = len;
      51                 :             : 
      52                 :           2 :         return 0;
      53                 :             : }
      54                 :             : 
      55                 :             : #if defined(unix) || defined(__linux__) || defined(__unix__) ||                \
      56                 :             :         defined(__unix) | (defined(__APPLE__) && defined(__MACH__)) ||         \
      57                 :             :         defined(uECC_POSIX)
      58                 :             : /*use the entropy source as provided in /tinycrypt/lib/source/ecc_platform_specific.c*/
      59                 :             : #else
      60                 :             : int default_CSPRNG(uint8_t *dest, unsigned int size)
      61                 :             : {
      62                 :             :         return 1;
      63                 :             : }
      64                 :             : #endif
        

Generated by: LCOV version 2.0-1