< prev index next >

src/jdk.crypto.ec/share/native/libsunec/impl/ecl_mult.c

Print this page
rev 50999 : 8207233: Minor improvements of jdk C-coding
   1 /*
   2  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Use is subject to license terms.
   4  *
   5  * This library is free software; you can redistribute it and/or
   6  * modify it under the terms of the GNU Lesser General Public
   7  * License as published by the Free Software Foundation; either
   8  * version 2.1 of the License, or (at your option) any later version.
   9  *
  10  * This library is distributed in the hope that it will be useful,
  11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13  * Lesser General Public License for more details.
  14  *
  15  * You should have received a copy of the GNU Lesser General Public License
  16  * along with this library; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  64                 MP_CHECKOK(mp_init(&kt, FLAG(k)));
  65                 MP_CHECKOK(mp_mod(k, &group->order, &kt));
  66         } else {
  67                 MP_SIGN(&kt) = MP_ZPOS;
  68                 MP_USED(&kt) = MP_USED(k);
  69                 MP_ALLOC(&kt) = MP_ALLOC(k);
  70                 MP_DIGITS(&kt) = MP_DIGITS(k);
  71         }
  72 
  73         if ((px == NULL) || (py == NULL)) {
  74                 if (group->base_point_mul) {
  75                         MP_CHECKOK(group->base_point_mul(&kt, rx, ry, group));
  76                 } else {
  77                         kt.flag = (mp_sign)0;
  78                         MP_CHECKOK(group->
  79                                            point_mul(&kt, &group->genx, &group->geny, rx, ry,
  80                                                                  group, timing));
  81                 }
  82         } else {
  83                 if (group->meth->field_enc) {

  84                         MP_CHECKOK(group->meth->field_enc(px, rx, group->meth));
  85                         MP_CHECKOK(group->meth->field_enc(py, ry, group->meth));
  86                         MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group, timing));
  87                 } else {
  88                         kt.flag = (mp_sign)0;
  89                         MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group, timing));
  90                 }
  91         }
  92         if (group->meth->field_dec) {
  93                 MP_CHECKOK(group->meth->field_dec(rx, rx, group->meth));
  94                 MP_CHECKOK(group->meth->field_dec(ry, ry, group->meth));
  95         }
  96 
  97   CLEANUP:
  98         if (MP_DIGITS(&kt) != MP_DIGITS(k)) {
  99                 mp_clear(&kt);
 100         }
 101         return res;
 102 }
 103 


   1 /*
   2  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Use is subject to license terms.
   4  *
   5  * This library is free software; you can redistribute it and/or
   6  * modify it under the terms of the GNU Lesser General Public
   7  * License as published by the Free Software Foundation; either
   8  * version 2.1 of the License, or (at your option) any later version.
   9  *
  10  * This library is distributed in the hope that it will be useful,
  11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13  * Lesser General Public License for more details.
  14  *
  15  * You should have received a copy of the GNU Lesser General Public License
  16  * along with this library; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  64                 MP_CHECKOK(mp_init(&kt, FLAG(k)));
  65                 MP_CHECKOK(mp_mod(k, &group->order, &kt));
  66         } else {
  67                 MP_SIGN(&kt) = MP_ZPOS;
  68                 MP_USED(&kt) = MP_USED(k);
  69                 MP_ALLOC(&kt) = MP_ALLOC(k);
  70                 MP_DIGITS(&kt) = MP_DIGITS(k);
  71         }
  72 
  73         if ((px == NULL) || (py == NULL)) {
  74                 if (group->base_point_mul) {
  75                         MP_CHECKOK(group->base_point_mul(&kt, rx, ry, group));
  76                 } else {
  77                         kt.flag = (mp_sign)0;
  78                         MP_CHECKOK(group->
  79                                            point_mul(&kt, &group->genx, &group->geny, rx, ry,
  80                                                                  group, timing));
  81                 }
  82         } else {
  83                 if (group->meth->field_enc) {
  84                         kt.flag = (mp_sign)0;
  85                         MP_CHECKOK(group->meth->field_enc(px, rx, group->meth));
  86                         MP_CHECKOK(group->meth->field_enc(py, ry, group->meth));
  87                         MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group, timing));
  88                 } else {
  89                         kt.flag = (mp_sign)0;
  90                         MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group, timing));
  91                 }
  92         }
  93         if (group->meth->field_dec) {
  94                 MP_CHECKOK(group->meth->field_dec(rx, rx, group->meth));
  95                 MP_CHECKOK(group->meth->field_dec(ry, ry, group->meth));
  96         }
  97 
  98   CLEANUP:
  99         if (MP_DIGITS(&kt) != MP_DIGITS(k)) {
 100                 mp_clear(&kt);
 101         }
 102         return res;
 103 }
 104 


< prev index next >