LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_expt_u32.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 0 18 0.0 %
Date: 2023-11-21 12:31:41 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_EXPT_U32_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* calculate c = a**b  using a square-multiply algorithm */
       7           0 : mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c)
       8             : {
       9           0 :    mp_err err;
      10             : 
      11           0 :    mp_int  g;
      12             : 
      13           0 :    if ((err = mp_init_copy(&g, a)) != MP_OKAY) {
      14           0 :       return err;
      15             :    }
      16             : 
      17             :    /* set initial result */
      18           0 :    mp_set(c, 1uL);
      19             : 
      20           0 :    while (b > 0u) {
      21             :       /* if the bit is set multiply */
      22           0 :       if ((b & 1u) != 0u) {
      23           0 :          if ((err = mp_mul(c, &g, c)) != MP_OKAY) {
      24           0 :             goto LBL_ERR;
      25             :          }
      26             :       }
      27             : 
      28             :       /* square */
      29           0 :       if (b > 1u) {
      30           0 :          if ((err = mp_sqr(&g, &g)) != MP_OKAY) {
      31           0 :             goto LBL_ERR;
      32             :          }
      33             :       }
      34             : 
      35             :       /* shift to next bit */
      36           0 :       b >>= 1;
      37             :    }
      38             : 
      39           0 :    err = MP_OKAY;
      40             : 
      41           0 : LBL_ERR:
      42           0 :    mp_clear(&g);
      43           0 :    return err;
      44             : }
      45             : 
      46             : #endif

Generated by: LCOV version 1.14