LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_mod_2d.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 0 14 0.0 %
Date: 2024-06-13 04:01:37 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_MOD_2D_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* calc a value mod 2**b */
       7           0 : mp_err mp_mod_2d(const mp_int *a, int b, mp_int *c)
       8             : {
       9             :    int x;
      10             :    mp_err err;
      11             : 
      12             :    /* if b is <= 0 then zero the int */
      13           0 :    if (b <= 0) {
      14           0 :       mp_zero(c);
      15           0 :       return MP_OKAY;
      16             :    }
      17             : 
      18             :    /* if the modulus is larger than the value than return */
      19           0 :    if (b >= (a->used * MP_DIGIT_BIT)) {
      20           0 :       return mp_copy(a, c);
      21             :    }
      22             : 
      23             :    /* copy */
      24           0 :    if ((err = mp_copy(a, c)) != MP_OKAY) {
      25           0 :       return err;
      26             :    }
      27             : 
      28             :    /* zero digits above the last digit of the modulus */
      29           0 :    x = (b / MP_DIGIT_BIT) + (((b % MP_DIGIT_BIT) == 0) ? 0 : 1);
      30           0 :    MP_ZERO_DIGITS(c->dp + x, c->used - x);
      31             : 
      32             :    /* clear the digit that is not completely outside/inside the modulus */
      33           0 :    c->dp[b / MP_DIGIT_BIT] &=
      34           0 :       ((mp_digit)1 << (mp_digit)(b % MP_DIGIT_BIT)) - (mp_digit)1;
      35           0 :    mp_clamp(c);
      36           0 :    return MP_OKAY;
      37             : }
      38             : #endif

Generated by: LCOV version 1.13