LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_from_sbin.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 8 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_FROM_SBIN_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* read signed bin, big endian, first byte is 0==positive or 1==negative */
       7           0 : mp_err mp_from_sbin(mp_int *a, const unsigned char *buf, size_t size)
       8             : {
       9           0 :    mp_err err;
      10             : 
      11             :    /* read magnitude */
      12           0 :    if ((err = mp_from_ubin(a, buf + 1, size - 1u)) != MP_OKAY) {
      13           0 :       return err;
      14             :    }
      15             : 
      16             :    /* first byte is 0 for positive, non-zero for negative */
      17           0 :    if (buf[0] == (unsigned char)0) {
      18           0 :       a->sign = MP_ZPOS;
      19             :    } else {
      20           0 :       a->sign = MP_NEG;
      21             :    }
      22             : 
      23           0 :    return MP_OKAY;
      24             : }
      25             : #endif

Generated by: LCOV version 1.14