LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_deprecated.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 0 117 0.0 %
Date: 2024-06-13 04:01:37 Functions: 0 44 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_DEPRECATED_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : #ifdef BN_MP_GET_BIT_C
       7           0 : int mp_get_bit(const mp_int *a, int b)
       8             : {
       9           0 :    if (b < 0) {
      10           0 :       return MP_VAL;
      11             :    }
      12           0 :    return (s_mp_get_bit(a, (unsigned int)b) == MP_YES) ? MP_YES : MP_NO;
      13             : }
      14             : #endif
      15             : #ifdef BN_MP_JACOBI_C
      16           0 : mp_err mp_jacobi(const mp_int *a, const mp_int *n, int *c)
      17             : {
      18           0 :    if (a->sign == MP_NEG) {
      19           0 :       return MP_VAL;
      20             :    }
      21           0 :    if (mp_cmp_d(n, 0uL) != MP_GT) {
      22           0 :       return MP_VAL;
      23             :    }
      24           0 :    return mp_kronecker(a, n, c);
      25             : }
      26             : #endif
      27             : #ifdef BN_MP_PRIME_RANDOM_EX_C
      28           0 : mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
      29             : {
      30           0 :    return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
      31             : }
      32             : #endif
      33             : #ifdef BN_MP_RAND_DIGIT_C
      34           0 : mp_err mp_rand_digit(mp_digit *r)
      35             : {
      36           0 :    mp_err err = s_mp_rand_source(r, sizeof(mp_digit));
      37           0 :    *r &= MP_MASK;
      38           0 :    return err;
      39             : }
      40             : #endif
      41             : #ifdef BN_FAST_MP_INVMOD_C
      42           0 : mp_err fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
      43             : {
      44           0 :    return s_mp_invmod_fast(a, b, c);
      45             : }
      46             : #endif
      47             : #ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
      48           0 : mp_err fast_mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
      49             : {
      50           0 :    return s_mp_montgomery_reduce_fast(x, n, rho);
      51             : }
      52             : #endif
      53             : #ifdef BN_FAST_S_MP_MUL_DIGS_C
      54           0 : mp_err fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
      55             : {
      56           0 :    return s_mp_mul_digs_fast(a, b, c, digs);
      57             : }
      58             : #endif
      59             : #ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
      60           0 : mp_err fast_s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
      61             : {
      62           0 :    return s_mp_mul_high_digs_fast(a, b, c, digs);
      63             : }
      64             : #endif
      65             : #ifdef BN_FAST_S_MP_SQR_C
      66           0 : mp_err fast_s_mp_sqr(const mp_int *a, mp_int *b)
      67             : {
      68           0 :    return s_mp_sqr_fast(a, b);
      69             : }
      70             : #endif
      71             : #ifdef BN_MP_BALANCE_MUL_C
      72           0 : mp_err mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
      73             : {
      74           0 :    return s_mp_balance_mul(a, b, c);
      75             : }
      76             : #endif
      77             : #ifdef BN_MP_EXPTMOD_FAST_C
      78           0 : mp_err mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
      79             : {
      80           0 :    return s_mp_exptmod_fast(G, X, P, Y, redmode);
      81             : }
      82             : #endif
      83             : #ifdef BN_MP_INVMOD_SLOW_C
      84           0 : mp_err mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
      85             : {
      86           0 :    return s_mp_invmod_slow(a, b, c);
      87             : }
      88             : #endif
      89             : #ifdef BN_MP_KARATSUBA_MUL_C
      90           0 : mp_err mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
      91             : {
      92           0 :    return s_mp_karatsuba_mul(a, b, c);
      93             : }
      94             : #endif
      95             : #ifdef BN_MP_KARATSUBA_SQR_C
      96           0 : mp_err mp_karatsuba_sqr(const mp_int *a, mp_int *b)
      97             : {
      98           0 :    return s_mp_karatsuba_sqr(a, b);
      99             : }
     100             : #endif
     101             : #ifdef BN_MP_TOOM_MUL_C
     102           0 : mp_err mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
     103             : {
     104           0 :    return s_mp_toom_mul(a, b, c);
     105             : }
     106             : #endif
     107             : #ifdef BN_MP_TOOM_SQR_C
     108           0 : mp_err mp_toom_sqr(const mp_int *a, mp_int *b)
     109             : {
     110           0 :    return s_mp_toom_sqr(a, b);
     111             : }
     112             : #endif
     113             : #ifdef S_MP_REVERSE_C
     114             : void bn_reverse(unsigned char *s, int len)
     115             : {
     116             :    if (len > 0) {
     117             :       s_mp_reverse(s, (size_t)len);
     118             :    }
     119             : }
     120             : #endif
     121             : #ifdef BN_MP_TC_AND_C
     122           0 : mp_err mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
     123             : {
     124           0 :    return mp_and(a, b, c);
     125             : }
     126             : #endif
     127             : #ifdef BN_MP_TC_OR_C
     128           0 : mp_err mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c)
     129             : {
     130           0 :    return mp_or(a, b, c);
     131             : }
     132             : #endif
     133             : #ifdef BN_MP_TC_XOR_C
     134           0 : mp_err mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
     135             : {
     136           0 :    return mp_xor(a, b, c);
     137             : }
     138             : #endif
     139             : #ifdef BN_MP_TC_DIV_2D_C
     140           0 : mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
     141             : {
     142           0 :    return mp_signed_rsh(a, b, c);
     143             : }
     144             : #endif
     145             : #ifdef BN_MP_INIT_SET_INT_C
     146           0 : mp_err mp_init_set_int(mp_int *a, unsigned long b)
     147             : {
     148           0 :    return mp_init_u32(a, (uint32_t)b);
     149             : }
     150             : #endif
     151             : #ifdef BN_MP_SET_INT_C
     152           0 : mp_err mp_set_int(mp_int *a, unsigned long b)
     153             : {
     154           0 :    mp_set_u32(a, (uint32_t)b);
     155           0 :    return MP_OKAY;
     156             : }
     157             : #endif
     158             : #ifdef BN_MP_SET_LONG_C
     159           0 : mp_err mp_set_long(mp_int *a, unsigned long b)
     160             : {
     161           0 :    mp_set_u64(a, b);
     162           0 :    return MP_OKAY;
     163             : }
     164             : #endif
     165             : #ifdef BN_MP_SET_LONG_LONG_C
     166           0 : mp_err mp_set_long_long(mp_int *a, unsigned long long b)
     167             : {
     168           0 :    mp_set_u64(a, b);
     169           0 :    return MP_OKAY;
     170             : }
     171             : #endif
     172             : #ifdef BN_MP_GET_INT_C
     173           0 : unsigned long mp_get_int(const mp_int *a)
     174             : {
     175           0 :    return (unsigned long)mp_get_mag_u32(a);
     176             : }
     177             : #endif
     178             : #ifdef BN_MP_GET_LONG_C
     179           0 : unsigned long mp_get_long(const mp_int *a)
     180             : {
     181           0 :    return (unsigned long)mp_get_mag_ul(a);
     182             : }
     183             : #endif
     184             : #ifdef BN_MP_GET_LONG_LONG_C
     185           0 : unsigned long long mp_get_long_long(const mp_int *a)
     186             : {
     187           0 :    return mp_get_mag_ull(a);
     188             : }
     189             : #endif
     190             : #ifdef BN_MP_PRIME_IS_DIVISIBLE_C
     191           0 : mp_err mp_prime_is_divisible(const mp_int *a, mp_bool *result)
     192             : {
     193           0 :    return s_mp_prime_is_divisible(a, result);
     194             : }
     195             : #endif
     196             : #ifdef BN_MP_EXPT_D_EX_C
     197           0 : mp_err mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
     198             : {
     199             :    (void)fast;
     200           0 :    if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
     201           0 :       return MP_VAL;
     202             :    }
     203           0 :    return mp_expt_u32(a, (uint32_t)b, c);
     204             : }
     205             : #endif
     206             : #ifdef BN_MP_EXPT_D_C
     207           0 : mp_err mp_expt_d(const mp_int *a, mp_digit b, mp_int *c)
     208             : {
     209           0 :    if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
     210           0 :       return MP_VAL;
     211             :    }
     212           0 :    return mp_expt_u32(a, (uint32_t)b, c);
     213             : }
     214             : #endif
     215             : #ifdef BN_MP_N_ROOT_EX_C
     216           0 : mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
     217             : {
     218             :    (void)fast;
     219           0 :    if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
     220           0 :       return MP_VAL;
     221             :    }
     222           0 :    return mp_root_u32(a, (uint32_t)b, c);
     223             : }
     224             : #endif
     225             : #ifdef BN_MP_N_ROOT_C
     226           0 : mp_err mp_n_root(const mp_int *a, mp_digit b, mp_int *c)
     227             : {
     228           0 :    if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
     229           0 :       return MP_VAL;
     230             :    }
     231           0 :    return mp_root_u32(a, (uint32_t)b, c);
     232             : }
     233             : #endif
     234             : #ifdef BN_MP_UNSIGNED_BIN_SIZE_C
     235           0 : int mp_unsigned_bin_size(const mp_int *a)
     236             : {
     237           0 :    return (int)mp_ubin_size(a);
     238             : }
     239             : #endif
     240             : #ifdef BN_MP_READ_UNSIGNED_BIN_C
     241           0 : mp_err mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c)
     242             : {
     243           0 :    return mp_from_ubin(a, b, (size_t) c);
     244             : }
     245             : #endif
     246             : #ifdef BN_MP_TO_UNSIGNED_BIN_C
     247           0 : mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
     248             : {
     249           0 :    return mp_to_ubin(a, b, SIZE_MAX, NULL);
     250             : }
     251             : #endif
     252             : #ifdef BN_MP_TO_UNSIGNED_BIN_N_C
     253           0 : mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
     254             : {
     255           0 :    size_t n = mp_ubin_size(a);
     256           0 :    if (*outlen < (unsigned long)n) {
     257           0 :       return MP_VAL;
     258             :    }
     259           0 :    *outlen = (unsigned long)n;
     260           0 :    return mp_to_ubin(a, b, n, NULL);
     261             : }
     262             : #endif
     263             : #ifdef BN_MP_SIGNED_BIN_SIZE_C
     264           0 : int mp_signed_bin_size(const mp_int *a)
     265             : {
     266           0 :    return (int)mp_sbin_size(a);
     267             : }
     268             : #endif
     269             : #ifdef BN_MP_READ_SIGNED_BIN_C
     270           0 : mp_err mp_read_signed_bin(mp_int *a, const unsigned char *b, int c)
     271             : {
     272           0 :    return mp_from_sbin(a, b, (size_t) c);
     273             : }
     274             : #endif
     275             : #ifdef BN_MP_TO_SIGNED_BIN_C
     276           0 : mp_err mp_to_signed_bin(const mp_int *a, unsigned char *b)
     277             : {
     278           0 :    return mp_to_sbin(a, b, SIZE_MAX, NULL);
     279             : }
     280             : #endif
     281             : #ifdef BN_MP_TO_SIGNED_BIN_N_C
     282           0 : mp_err mp_to_signed_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
     283             : {
     284           0 :    size_t n = mp_sbin_size(a);
     285           0 :    if (*outlen < (unsigned long)n) {
     286           0 :       return MP_VAL;
     287             :    }
     288           0 :    *outlen = (unsigned long)n;
     289           0 :    return mp_to_sbin(a, b, n, NULL);
     290             : }
     291             : #endif
     292             : #ifdef BN_MP_TORADIX_N_C
     293           0 : mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
     294             : {
     295           0 :    if (maxlen < 0) {
     296           0 :       return MP_VAL;
     297             :    }
     298           0 :    return mp_to_radix(a, str, (size_t)maxlen, NULL, radix);
     299             : }
     300             : #endif
     301             : #ifdef BN_MP_TORADIX_C
     302           0 : mp_err mp_toradix(const mp_int *a, char *str, int radix)
     303             : {
     304           0 :    return mp_to_radix(a, str, SIZE_MAX, NULL, radix);
     305             : }
     306             : #endif
     307             : #ifdef BN_MP_IMPORT_C
     308           0 : mp_err mp_import(mp_int *rop, size_t count, int order, size_t size, int endian, size_t nails,
     309             :                  const void *op)
     310             : {
     311           0 :    return mp_unpack(rop, count, order, size, endian, nails, op);
     312             : }
     313             : #endif
     314             : #ifdef BN_MP_EXPORT_C
     315           0 : mp_err mp_export(void *rop, size_t *countp, int order, size_t size,
     316             :                  int endian, size_t nails, const mp_int *op)
     317             : {
     318           0 :    return mp_pack(rop, SIZE_MAX, countp, order, size, endian, nails, op);
     319             : }
     320             : #endif
     321             : #endif

Generated by: LCOV version 1.13