src/jdk.crypto.ec/share/native/libsunec/impl/mp_gf2m.h
author valeriep
Fri, 22 Jun 2018 23:10:36 +0000
changeset 50731 ed322b4cfe49
parent 47216 71c04702a3d5
permissions -rw-r--r--
7007966: Add Brainpool ECC support (RFC 5639) Summary: Enhance SunEC provider with the support of brainpool256/320/384/512r1 curves Reviewed-by: valeriep Contributed-by: Tobias Wagner <tobias.wagner@n-design.de>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9774
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     1
/*
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     3
 * Use is subject to license terms.
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     4
 *
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     5
 * This library is free software; you can redistribute it and/or
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     7
 * License as published by the Free Software Foundation; either
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
     8
 * version 2.1 of the License, or (at your option) any later version.
3863
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     9
 *
9774
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    10
 * This library is distributed in the hope that it will be useful,
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    13
 * Lesser General Public License for more details.
3863
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    14
 *
9774
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public License
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    16
 * along with this library; if not, write to the Free Software Foundation,
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    17
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3863
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    18
 *
9774
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    21
 * questions.
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    22
 */
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    23
50a2b28ca54c 7049173: Replace the software license for ECC native code
vinnie
parents: 9035
diff changeset
    24
/* *********************************************************************
3863
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    25
 *
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    26
 * The Original Code is the Multi-precision Binary Polynomial Arithmetic Library.
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    27
 *
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    28
 * The Initial Developer of the Original Code is
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    29
 * Sun Microsystems, Inc.
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    30
 * Portions created by the Initial Developer are Copyright (C) 2003
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    31
 * the Initial Developer. All Rights Reserved.
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    32
 *
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    33
 * Contributor(s):
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    34
 *   Sheueling Chang Shantz <sheueling.chang@sun.com> and
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    35
 *   Douglas Stebila <douglas@stebila.ca> of Sun Laboratories.
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    36
 *
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    37
 *********************************************************************** */
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    38
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    39
#ifndef _MP_GF2M_H_
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    40
#define _MP_GF2M_H_
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    41
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    42
#include "mpi.h"
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    43
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    44
mp_err mp_badd(const mp_int *a, const mp_int *b, mp_int *c);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    45
mp_err mp_bmul(const mp_int *a, const mp_int *b, mp_int *c);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    46
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    47
/* For modular arithmetic, the irreducible polynomial f(t) is represented
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    48
 * as an array of int[], where f(t) is of the form:
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    49
 *     f(t) = t^p[0] + t^p[1] + ... + t^p[k]
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    50
 * where m = p[0] > p[1] > ... > p[k] = 0.
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    51
 */
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    52
mp_err mp_bmod(const mp_int *a, const unsigned int p[], mp_int *r);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    53
mp_err mp_bmulmod(const mp_int *a, const mp_int *b, const unsigned int p[],
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    54
    mp_int *r);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    55
mp_err mp_bsqrmod(const mp_int *a, const unsigned int p[], mp_int *r);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    56
mp_err mp_bdivmod(const mp_int *y, const mp_int *x, const mp_int *pp,
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    57
    const unsigned int p[], mp_int *r);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    58
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    59
int mp_bpoly2arr(const mp_int *a, unsigned int p[], int max);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    60
mp_err mp_barr2poly(const unsigned int p[], mp_int *a);
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    61
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    62
#endif /* _MP_GF2M_H_ */