LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_fwrite.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 20 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_FWRITE_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : #ifndef MP_NO_FILE
       7           0 : mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream)
       8             : {
       9           0 :    char *buf;
      10           0 :    mp_err err;
      11           0 :    int len;
      12           0 :    size_t written;
      13             : 
      14             :    /* TODO: this function is not in this PR */
      15           0 :    if (MP_HAS(MP_RADIX_SIZE_OVERESTIMATE)) {
      16             :       /* if ((err = mp_radix_size_overestimate(&t, base, &len)) != MP_OKAY)      goto LBL_ERR; */
      17             :    } else {
      18           0 :       if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) {
      19           0 :          return err;
      20             :       }
      21             :    }
      22             : 
      23           0 :    buf = (char *) MP_MALLOC((size_t)len);
      24           0 :    if (buf == NULL) {
      25           0 :       return MP_MEM;
      26             :    }
      27             : 
      28           0 :    if ((err = mp_to_radix(a, buf, (size_t)len, &written, radix)) != MP_OKAY) {
      29           0 :       goto LBL_ERR;
      30             :    }
      31             : 
      32           0 :    if (fwrite(buf, written, 1uL, stream) != 1uL) {
      33           0 :       err = MP_ERR;
      34           0 :       goto LBL_ERR;
      35             :    }
      36           0 :    err = MP_OKAY;
      37             : 
      38             : 
      39           0 : LBL_ERR:
      40           0 :    MP_FREE_BUFFER(buf, (size_t)len);
      41           0 :    return err;
      42             : }
      43             : #endif
      44             : 
      45             : #endif

Generated by: LCOV version 1.14