LCOV - code coverage report
Current view: top level - src/edhoc - bstr_encode_decode.c (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 12 12
Test Date: 2026-03-12 12:01:18 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50.0 % 6 3

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright (c) 2022 Eriptic Technologies.
       3                 :             :  *
       4                 :             :  * SPDX-License-Identifier: Apache-2.0 or MIT
       5                 :             :  */
       6                 :             : 
       7                 :             : #include "zcbor_common.h"
       8                 :             : #include "cbor/edhoc_encode_bstr_type.h"
       9                 :             : #include "cbor/edhoc_decode_bstr_type.h"
      10                 :             : 
      11                 :             : #include "common/oscore_edhoc_error.h"
      12                 :             : #include "common/print_util.h"
      13                 :             : #include "common/memcpy_s.h"
      14                 :             : #include "common/byte_array.h"
      15                 :             : 
      16                 :          57 : enum err encode_bstr(const struct byte_array *in, struct byte_array *out)
      17                 :             : {
      18                 :             :         size_t payload_len_out;
      19                 :             :         struct zcbor_string tmp;
      20                 :          57 :         tmp.value = in->ptr;
      21                 :          57 :         tmp.len = in->len;
      22         [ -  + ]:          57 :         TRY_EXPECT(cbor_encode_bstr_type_b_str(out->ptr, out->len, &tmp,
      23                 :             :                                                &payload_len_out),
      24                 :             :                    0);
      25                 :          57 :         out->len = (uint32_t)payload_len_out;
      26                 :          57 :         return ok;
      27                 :             : }
      28                 :             : 
      29                 :           6 : enum err decode_bstr(const struct byte_array *in, struct byte_array *out)
      30                 :             : {
      31                 :             :         struct zcbor_string str;
      32                 :           6 :         size_t decode_len = 0;
      33                 :             : 
      34         [ -  + ]:           6 :         TRY_EXPECT(cbor_decode_bstr_type_b_str(in->ptr, in->len, &str,
      35                 :             :                                                &decode_len),
      36                 :             :                    0);
      37                 :             : 
      38         [ -  + ]:           6 :         TRY(_memcpy_s(out->ptr, out->len, str.value, (uint32_t)str.len));
      39                 :           6 :         out->len = (uint32_t)str.len;
      40                 :             : 
      41                 :           6 :         return ok;
      42                 :             : }
        

Generated by: LCOV version 2.0-1