jdk/src/share/native/sun/security/ec/ec2.h
changeset 3492 e549cea58864
equal deleted inserted replaced
3480:c197e38bf15a 3492:e549cea58864
       
     1 /* *********************************************************************
       
     2  *
       
     3  * Sun elects to have this file available under and governed by the
       
     4  * Mozilla Public License Version 1.1 ("MPL") (see
       
     5  * http://www.mozilla.org/MPL/ for full license text). For the avoidance
       
     6  * of doubt and subject to the following, Sun also elects to allow
       
     7  * licensees to use this file under the MPL, the GNU General Public
       
     8  * License version 2 only or the Lesser General Public License version
       
     9  * 2.1 only. Any references to the "GNU General Public License version 2
       
    10  * or later" or "GPL" in the following shall be construed to mean the
       
    11  * GNU General Public License version 2 only. Any references to the "GNU
       
    12  * Lesser General Public License version 2.1 or later" or "LGPL" in the
       
    13  * following shall be construed to mean the GNU Lesser General Public
       
    14  * License version 2.1 only. However, the following notice accompanied
       
    15  * the original version of this file:
       
    16  *
       
    17  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       
    18  *
       
    19  * The contents of this file are subject to the Mozilla Public License Version
       
    20  * 1.1 (the "License"); you may not use this file except in compliance with
       
    21  * the License. You may obtain a copy of the License at
       
    22  * http://www.mozilla.org/MPL/
       
    23  *
       
    24  * Software distributed under the License is distributed on an "AS IS" basis,
       
    25  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
       
    26  * for the specific language governing rights and limitations under the
       
    27  * License.
       
    28  *
       
    29  * The Original Code is the elliptic curve math library for binary polynomial field curves.
       
    30  *
       
    31  * The Initial Developer of the Original Code is
       
    32  * Sun Microsystems, Inc.
       
    33  * Portions created by the Initial Developer are Copyright (C) 2003
       
    34  * the Initial Developer. All Rights Reserved.
       
    35  *
       
    36  * Contributor(s):
       
    37  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
       
    38  *
       
    39  * Alternatively, the contents of this file may be used under the terms of
       
    40  * either the GNU General Public License Version 2 or later (the "GPL"), or
       
    41  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
       
    42  * in which case the provisions of the GPL or the LGPL are applicable instead
       
    43  * of those above. If you wish to allow use of your version of this file only
       
    44  * under the terms of either the GPL or the LGPL, and not to allow others to
       
    45  * use your version of this file under the terms of the MPL, indicate your
       
    46  * decision by deleting the provisions above and replace them with the notice
       
    47  * and other provisions required by the GPL or the LGPL. If you do not delete
       
    48  * the provisions above, a recipient may use your version of this file under
       
    49  * the terms of any one of the MPL, the GPL or the LGPL.
       
    50  *
       
    51  *********************************************************************** */
       
    52 /*
       
    53  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
       
    54  * Use is subject to license terms.
       
    55  */
       
    56 
       
    57 #ifndef _EC2_H
       
    58 #define _EC2_H
       
    59 
       
    60 #pragma ident   "%Z%%M% %I%     %E% SMI"
       
    61 
       
    62 #include "ecl-priv.h"
       
    63 
       
    64 /* Checks if point P(px, py) is at infinity.  Uses affine coordinates. */
       
    65 mp_err ec_GF2m_pt_is_inf_aff(const mp_int *px, const mp_int *py);
       
    66 
       
    67 /* Sets P(px, py) to be the point at infinity.  Uses affine coordinates. */
       
    68 mp_err ec_GF2m_pt_set_inf_aff(mp_int *px, mp_int *py);
       
    69 
       
    70 /* Computes R = P + Q where R is (rx, ry), P is (px, py) and Q is (qx,
       
    71  * qy). Uses affine coordinates. */
       
    72 mp_err ec_GF2m_pt_add_aff(const mp_int *px, const mp_int *py,
       
    73                                                   const mp_int *qx, const mp_int *qy, mp_int *rx,
       
    74                                                   mp_int *ry, const ECGroup *group);
       
    75 
       
    76 /* Computes R = P - Q.  Uses affine coordinates. */
       
    77 mp_err ec_GF2m_pt_sub_aff(const mp_int *px, const mp_int *py,
       
    78                                                   const mp_int *qx, const mp_int *qy, mp_int *rx,
       
    79                                                   mp_int *ry, const ECGroup *group);
       
    80 
       
    81 /* Computes R = 2P.  Uses affine coordinates. */
       
    82 mp_err ec_GF2m_pt_dbl_aff(const mp_int *px, const mp_int *py, mp_int *rx,
       
    83                                                   mp_int *ry, const ECGroup *group);
       
    84 
       
    85 /* Validates a point on a GF2m curve. */
       
    86 mp_err ec_GF2m_validate_point(const mp_int *px, const mp_int *py, const ECGroup *group);
       
    87 
       
    88 /* by default, this routine is unused and thus doesn't need to be compiled */
       
    89 #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
       
    90 /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters
       
    91  * a, b and p are the elliptic curve coefficients and the irreducible that
       
    92  * determines the field GF2m.  Uses affine coordinates. */
       
    93 mp_err ec_GF2m_pt_mul_aff(const mp_int *n, const mp_int *px,
       
    94                                                   const mp_int *py, mp_int *rx, mp_int *ry,
       
    95                                                   const ECGroup *group);
       
    96 #endif
       
    97 
       
    98 /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters
       
    99  * a, b and p are the elliptic curve coefficients and the irreducible that
       
   100  * determines the field GF2m.  Uses Montgomery projective coordinates. */
       
   101 mp_err ec_GF2m_pt_mul_mont(const mp_int *n, const mp_int *px,
       
   102                                                    const mp_int *py, mp_int *rx, mp_int *ry,
       
   103                                                    const ECGroup *group);
       
   104 
       
   105 #ifdef ECL_ENABLE_GF2M_PROJ
       
   106 /* Converts a point P(px, py) from affine coordinates to projective
       
   107  * coordinates R(rx, ry, rz). */
       
   108 mp_err ec_GF2m_pt_aff2proj(const mp_int *px, const mp_int *py, mp_int *rx,
       
   109                                                    mp_int *ry, mp_int *rz, const ECGroup *group);
       
   110 
       
   111 /* Converts a point P(px, py, pz) from projective coordinates to affine
       
   112  * coordinates R(rx, ry). */
       
   113 mp_err ec_GF2m_pt_proj2aff(const mp_int *px, const mp_int *py,
       
   114                                                    const mp_int *pz, mp_int *rx, mp_int *ry,
       
   115                                                    const ECGroup *group);
       
   116 
       
   117 /* Checks if point P(px, py, pz) is at infinity.  Uses projective
       
   118  * coordinates. */
       
   119 mp_err ec_GF2m_pt_is_inf_proj(const mp_int *px, const mp_int *py,
       
   120                                                           const mp_int *pz);
       
   121 
       
   122 /* Sets P(px, py, pz) to be the point at infinity.  Uses projective
       
   123  * coordinates. */
       
   124 mp_err ec_GF2m_pt_set_inf_proj(mp_int *px, mp_int *py, mp_int *pz);
       
   125 
       
   126 /* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is
       
   127  * (qx, qy, qz).  Uses projective coordinates. */
       
   128 mp_err ec_GF2m_pt_add_proj(const mp_int *px, const mp_int *py,
       
   129                                                    const mp_int *pz, const mp_int *qx,
       
   130                                                    const mp_int *qy, mp_int *rx, mp_int *ry,
       
   131                                                    mp_int *rz, const ECGroup *group);
       
   132 
       
   133 /* Computes R = 2P.  Uses projective coordinates. */
       
   134 mp_err ec_GF2m_pt_dbl_proj(const mp_int *px, const mp_int *py,
       
   135                                                    const mp_int *pz, mp_int *rx, mp_int *ry,
       
   136                                                    mp_int *rz, const ECGroup *group);
       
   137 
       
   138 /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters
       
   139  * a, b and p are the elliptic curve coefficients and the prime that
       
   140  * determines the field GF2m.  Uses projective coordinates. */
       
   141 mp_err ec_GF2m_pt_mul_proj(const mp_int *n, const mp_int *px,
       
   142                                                    const mp_int *py, mp_int *rx, mp_int *ry,
       
   143                                                    const ECGroup *group);
       
   144 #endif
       
   145 
       
   146 #endif /* _EC2_H */