LCOV - code coverage report
Current view: top level - os_stub/spdm_device_secret_lib_sample - chal.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.7 % 12 11
Test Date: 2025-09-14 08:11:04 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  *  Copyright Notice:
       3              :  *  Copyright 2024 DMTF. All rights reserved.
       4              :  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
       5              :  **/
       6              : 
       7              : #include <stdarg.h>
       8              : #include <stddef.h>
       9              : #include <setjmp.h>
      10              : #include <stdint.h>
      11              : #include <stdlib.h>
      12              : #include <stdio.h>
      13              : #include <assert.h>
      14              : #include <string.h>
      15              : 
      16              : #include <base.h>
      17              : #include "library/memlib.h"
      18              : #include "spdm_device_secret_lib_internal.h"
      19              : #include "internal/libspdm_common_lib.h"
      20              : 
      21              : #if LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP
      22              : size_t libspdm_secret_lib_challenge_opaque_data_size;
      23              : 
      24            8 : bool libspdm_challenge_opaque_data(
      25              :     void *spdm_context,
      26              :     spdm_version_number_t spdm_version,
      27              :     uint8_t slot_id,
      28              :     uint8_t *measurement_summary_hash,
      29              :     size_t measurement_summary_hash_size,
      30              :     void *opaque_data,
      31              :     size_t *opaque_data_size)
      32              : {
      33              :     size_t index;
      34              : 
      35            8 :     LIBSPDM_ASSERT(libspdm_secret_lib_challenge_opaque_data_size <= *opaque_data_size);
      36              : 
      37            8 :     *opaque_data_size = libspdm_secret_lib_challenge_opaque_data_size;
      38              : 
      39           16 :     for (index = 0; index < *opaque_data_size; index++)
      40              :     {
      41            8 :         ((uint8_t *)opaque_data)[index] = (uint8_t)index;
      42              :     }
      43              : 
      44            8 :     return true;
      45              : }
      46              : #endif /* LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP */
      47              : 
      48              : #if LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP
      49            3 : bool libspdm_encap_challenge_opaque_data(
      50              :     void *spdm_context,
      51              :     spdm_version_number_t spdm_version,
      52              :     uint8_t slot_id,
      53              :     uint8_t *measurement_summary_hash,
      54              :     size_t measurement_summary_hash_size,
      55              :     void *opaque_data,
      56              :     size_t *opaque_data_size)
      57              : {
      58              :     size_t index;
      59              : 
      60            3 :     LIBSPDM_ASSERT(libspdm_secret_lib_challenge_opaque_data_size <= *opaque_data_size);
      61              : 
      62            3 :     *opaque_data_size = libspdm_secret_lib_challenge_opaque_data_size;
      63              : 
      64            3 :     for (index = 0; index < *opaque_data_size; index++)
      65              :     {
      66            0 :         ((uint8_t *)opaque_data)[index] = (uint8_t)index;
      67              :     }
      68              : 
      69            3 :     return true;
      70              : }
      71              : #endif /* LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP */
        

Generated by: LCOV version 2.0-1