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

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_REDUCE_IS_2K_L_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* determines if reduce_2k_l can be used */
       7         229 : mp_bool mp_reduce_is_2k_l(const mp_int *a)
       8             : {
       9             :    int ix, iy;
      10             : 
      11         229 :    if (a->used == 0) {
      12           0 :       return MP_NO;
      13         229 :    } else if (a->used == 1) {
      14           0 :       return MP_YES;
      15         229 :    } else if (a->used > 1) {
      16             :       /* if more than half of the digits are -1 we're sold */
      17        9519 :       for (iy = ix = 0; ix < a->used; ix++) {
      18        9290 :          if (a->dp[ix] == MP_DIGIT_MAX) {
      19         154 :             ++iy;
      20             :          }
      21             :       }
      22         229 :       return (iy >= (a->used/2)) ? MP_YES : MP_NO;
      23             :    } else {
      24           0 :       return MP_NO;
      25             :    }
      26             : }
      27             : 
      28             : #endif

Generated by: LCOV version 1.13