LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_2expt.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 7 8 87.5 %
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_2EXPT_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* computes a = 2**b
       7             :  *
       8             :  * Simple algorithm which zeroes the int, grows it then just sets one bit
       9             :  * as required.
      10             :  */
      11         893 : mp_err mp_2expt(mp_int *a, int b)
      12             : {
      13          32 :    mp_err    err;
      14             : 
      15             :    /* zero a as per default */
      16         893 :    mp_zero(a);
      17             : 
      18             :    /* grow a to accomodate the single bit */
      19         893 :    if ((err = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
      20           0 :       return err;
      21             :    }
      22             : 
      23             :    /* set the used count of where the bit will go */
      24         893 :    a->used = (b / MP_DIGIT_BIT) + 1;
      25             : 
      26             :    /* put the single bit in its place */
      27         893 :    a->dp[b / MP_DIGIT_BIT] = (mp_digit)1 << (mp_digit)(b % MP_DIGIT_BIT);
      28             : 
      29         893 :    return MP_OKAY;
      30             : }
      31             : #endif

Generated by: LCOV version 1.14