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 master 2f515e9b Lines: 9 12 75.0 %
Date: 2024-04-21 15:09:00 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         922 : mp_bool mp_reduce_is_2k_l(const mp_int *a)
       8             : {
       9          32 :    int ix, iy;
      10             : 
      11         922 :    if (a->used == 0) {
      12           0 :       return MP_NO;
      13         922 :    } else if (a->used == 1) {
      14           0 :       return MP_YES;
      15         922 :    } else if (a->used > 1) {
      16             :       /* if more than half of the digits are -1 we're sold */
      17       50107 :       for (iy = ix = 0; ix < a->used; ix++) {
      18       49185 :          if (a->dp[ix] == MP_DIGIT_MAX) {
      19         348 :             ++iy;
      20             :          }
      21             :       }
      22         922 :       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.14