Print this page
8660 mpi code checks return value of void function

Split Close
Expand all
Collapse all
          --- old/usr/src/common/mpi/mpmontg.c
          +++ new/usr/src/common/mpi/mpmontg.c
↓ open down ↓ 32 lines elided ↑ open up ↑
  33   33   * decision by deleting the provisions above and replace them with the notice
  34   34   * and other provisions required by the GPL or the LGPL. If you do not delete
  35   35   * the provisions above, a recipient may use your version of this file under
  36   36   * the terms of any one of the MPL, the GPL or the LGPL.
  37   37   *
  38   38   * ***** END LICENSE BLOCK ***** */
  39   39  /*
  40   40   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  41   41   * Use is subject to license terms.
  42   42   *
       43 + * Copyright 2017 RackTop Systems.
       44 + *
  43   45   * Sun elects to use this software under the MPL license.
  44   46   */
  45   47  
  46      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  47      -
  48   48  /* $Id: mpmontg.c,v 1.20 2006/08/29 02:41:38 nelson%bolyard.com Exp $ */
  49   49  
  50   50  /* This file implements moduluar exponentiation using Montgomery's
  51   51   * method for modular reduction.  This file implements the method
  52   52   * described as "Improvement 1" in the paper "A Cryptogrpahic Library for
  53   53   * the Motorola DSP56000" by Stephen R. Dusse' and Burton S. Kaliski Jr.
  54   54   * published in "Advances in Cryptology: Proceedings of EUROCRYPT '90"
  55   55   * "Lecture Notes in Computer Science" volume 473, 1991, pg 230-244,
  56   56   * published by Springer Verlag.
  57   57   */
↓ open down ↓ 39 lines elided ↑ open up ↑
  97   97  mp_err s_mp_redc(mp_int *T, mp_mont_modulus *mmm)
  98   98  {
  99   99    mp_err res;
 100  100    mp_size i;
 101  101  
 102  102    i = MP_USED(T) + MP_USED(&mmm->N) + 2;
 103  103    MP_CHECKOK( s_mp_pad(T, i) );
 104  104    for (i = 0; i < MP_USED(&mmm->N); ++i ) {
 105  105      mp_digit m_i = MP_DIGIT(T, i) * mmm->n0prime;
 106  106      /* T += N * m_i * (MP_RADIX ** i); */
 107      -    MP_CHECKOK( s_mp_mul_d_add_offset(&mmm->N, m_i, T, i) );
      107 +    s_mp_mul_d_add_offset(&mmm->N, m_i, T, i);
 108  108    }
 109  109    s_mp_clamp(T);
 110  110  
 111  111    /* T /= R */
 112  112    s_mp_div_2d(T, mmm->b); 
 113  113  
 114  114    if ((res = s_mp_cmp(T, &mmm->N)) >= 0) {
 115  115      /* T = T - N */
 116  116      MP_CHECKOK( s_mp_sub(T, &mmm->N) );
 117  117  #ifdef DEBUG
↓ open down ↓ 69 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX