LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_clamp.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 6 6 100.0 %
Date: 2024-02-29 22:57:05 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_CLAMP_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* trim unused digits
       7             :  *
       8             :  * This is used to ensure that leading zero digits are
       9             :  * trimed and the leading "used" digit will be non-zero
      10             :  * Typically very fast.  Also fixes the sign if there
      11             :  * are no more leading digits
      12             :  */
      13     5338797 : void mp_clamp(mp_int *a)
      14             : {
      15             :    /* decrease used while the most significant digit is
      16             :     * zero.
      17             :     */
      18     8110431 :    while ((a->used > 0) && (a->dp[a->used - 1] == 0u)) {
      19     2771634 :       --(a->used);
      20             :    }
      21             : 
      22             :    /* reset the sign flag if used == 0 */
      23     5338797 :    if (a->used == 0) {
      24        3660 :       a->sign = MP_ZPOS;
      25             :    }
      26     5338797 : }
      27             : #endif

Generated by: LCOV version 1.14