LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_dr_is_modulus.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 5 7 71.4 %
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_DR_IS_MODULUS_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* determines if a number is a valid DR modulus */
       7         229 : mp_bool mp_dr_is_modulus(const mp_int *a)
       8             : {
       9             :    int ix;
      10             : 
      11             :    /* must be at least two digits */
      12         229 :    if (a->used < 2) {
      13           0 :       return MP_NO;
      14             :    }
      15             : 
      16             :    /* must be of the form b**k - a [a <= b] so all
      17             :     * but the first digit must be equal to -1 (mod b).
      18             :     */
      19         229 :    for (ix = 1; ix < a->used; ix++) {
      20         229 :       if (a->dp[ix] != MP_MASK) {
      21         229 :          return MP_NO;
      22             :       }
      23             :    }
      24           0 :    return MP_YES;
      25             : }
      26             : 
      27             : #endif

Generated by: LCOV version 1.13