jdk/src/share/native/sun/security/ec/ecp_384.c
author vinnie
Tue, 11 Aug 2009 16:52:26 +0100
changeset 3492 e549cea58864
permissions -rw-r--r--
6840752: Provide out-of-the-box support for ECC algorithms Reviewed-by: alanb, mullan, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     1
/* *********************************************************************
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     2
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     3
 * Sun elects to have this file available under and governed by the
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     4
 * Mozilla Public License Version 1.1 ("MPL") (see
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     5
 * http://www.mozilla.org/MPL/ for full license text). For the avoidance
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     6
 * of doubt and subject to the following, Sun also elects to allow
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     7
 * licensees to use this file under the MPL, the GNU General Public
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     8
 * License version 2 only or the Lesser General Public License version
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     9
 * 2.1 only. Any references to the "GNU General Public License version 2
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    10
 * or later" or "GPL" in the following shall be construed to mean the
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    11
 * GNU General Public License version 2 only. Any references to the "GNU
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    12
 * Lesser General Public License version 2.1 or later" or "LGPL" in the
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    13
 * following shall be construed to mean the GNU Lesser General Public
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    14
 * License version 2.1 only. However, the following notice accompanied
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    15
 * the original version of this file:
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    16
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    17
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    18
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    19
 * The contents of this file are subject to the Mozilla Public License Version
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    20
 * 1.1 (the "License"); you may not use this file except in compliance with
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    21
 * the License. You may obtain a copy of the License at
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    22
 * http://www.mozilla.org/MPL/
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    23
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    24
 * Software distributed under the License is distributed on an "AS IS" basis,
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    25
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    26
 * for the specific language governing rights and limitations under the
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    27
 * License.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    28
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    29
 * The Original Code is the elliptic curve math library for prime field curves.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    30
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    31
 * The Initial Developer of the Original Code is
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    32
 * Sun Microsystems, Inc.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    33
 * Portions created by the Initial Developer are Copyright (C) 2003
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    34
 * the Initial Developer. All Rights Reserved.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    35
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    36
 * Contributor(s):
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    37
 *   Douglas Stebila <douglas@stebila.ca>
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    38
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    39
 * Alternatively, the contents of this file may be used under the terms of
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    40
 * either the GNU General Public License Version 2 or later (the "GPL"), or
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    41
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    42
 * in which case the provisions of the GPL or the LGPL are applicable instead
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    43
 * of those above. If you wish to allow use of your version of this file only
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    44
 * under the terms of either the GPL or the LGPL, and not to allow others to
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    45
 * use your version of this file under the terms of the MPL, indicate your
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    46
 * decision by deleting the provisions above and replace them with the notice
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    47
 * and other provisions required by the GPL or the LGPL. If you do not delete
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    48
 * the provisions above, a recipient may use your version of this file under
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    49
 * the terms of any one of the MPL, the GPL or the LGPL.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    50
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    51
 *********************************************************************** */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    52
/*
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    53
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    54
 * Use is subject to license terms.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    55
 */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    56
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    57
#pragma ident   "%Z%%M% %I%     %E% SMI"
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    58
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    59
#include "ecp.h"
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    60
#include "mpi.h"
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    61
#include "mplogic.h"
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    62
#include "mpi-priv.h"
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    63
#ifndef _KERNEL
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    64
#include <stdlib.h>
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    65
#endif
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    66
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    67
/* Fast modular reduction for p384 = 2^384 - 2^128 - 2^96 + 2^32 - 1.  a can be r.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    68
 * Uses algorithm 2.30 from Hankerson, Menezes, Vanstone. Guide to
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    69
 * Elliptic Curve Cryptography. */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    70
mp_err
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    71
ec_GFp_nistp384_mod(const mp_int *a, mp_int *r, const GFMethod *meth)
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    72
{
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    73
        mp_err res = MP_OKAY;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    74
        int a_bits = mpl_significant_bits(a);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    75
        int i;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    76
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    77
        /* m1, m2 are statically-allocated mp_int of exactly the size we need */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    78
        mp_int m[10];
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    79
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    80
#ifdef ECL_THIRTY_TWO_BIT
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    81
        mp_digit s[10][12];
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    82
        for (i = 0; i < 10; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    83
                MP_SIGN(&m[i]) = MP_ZPOS;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    84
                MP_ALLOC(&m[i]) = 12;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    85
                MP_USED(&m[i]) = 12;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    86
                MP_DIGITS(&m[i]) = s[i];
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    87
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    88
#else
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    89
        mp_digit s[10][6];
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    90
        for (i = 0; i < 10; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    91
                MP_SIGN(&m[i]) = MP_ZPOS;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    92
                MP_ALLOC(&m[i]) = 6;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    93
                MP_USED(&m[i]) = 6;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    94
                MP_DIGITS(&m[i]) = s[i];
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    95
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    96
#endif
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    97
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    98
#ifdef ECL_THIRTY_TWO_BIT
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    99
        /* for polynomials larger than twice the field size or polynomials
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   100
         * not using all words, use regular reduction */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   101
        if ((a_bits > 768) || (a_bits <= 736)) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   102
                MP_CHECKOK(mp_mod(a, &meth->irr, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   103
        } else {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   104
                for (i = 0; i < 12; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   105
                        s[0][i] = MP_DIGIT(a, i);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   106
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   107
                s[1][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   108
                s[1][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   109
                s[1][2] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   110
                s[1][3] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   111
                s[1][4] = MP_DIGIT(a, 21);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   112
                s[1][5] = MP_DIGIT(a, 22);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   113
                s[1][6] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   114
                s[1][7] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   115
                s[1][8] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   116
                s[1][9] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   117
                s[1][10] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   118
                s[1][11] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   119
                for (i = 0; i < 12; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   120
                        s[2][i] = MP_DIGIT(a, i+12);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   121
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   122
                s[3][0] = MP_DIGIT(a, 21);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   123
                s[3][1] = MP_DIGIT(a, 22);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   124
                s[3][2] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   125
                for (i = 3; i < 12; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   126
                        s[3][i] = MP_DIGIT(a, i+9);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   127
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   128
                s[4][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   129
                s[4][1] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   130
                s[4][2] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   131
                s[4][3] = MP_DIGIT(a, 20);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   132
                for (i = 4; i < 12; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   133
                        s[4][i] = MP_DIGIT(a, i+8);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   134
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   135
                s[5][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   136
                s[5][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   137
                s[5][2] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   138
                s[5][3] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   139
                s[5][4] = MP_DIGIT(a, 20);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   140
                s[5][5] = MP_DIGIT(a, 21);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   141
                s[5][6] = MP_DIGIT(a, 22);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   142
                s[5][7] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   143
                s[5][8] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   144
                s[5][9] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   145
                s[5][10] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   146
                s[5][11] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   147
                s[6][0] = MP_DIGIT(a, 20);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   148
                s[6][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   149
                s[6][2] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   150
                s[6][3] = MP_DIGIT(a, 21);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   151
                s[6][4] = MP_DIGIT(a, 22);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   152
                s[6][5] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   153
                s[6][6] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   154
                s[6][7] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   155
                s[6][8] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   156
                s[6][9] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   157
                s[6][10] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   158
                s[6][11] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   159
                s[7][0] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   160
                for (i = 1; i < 12; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   161
                        s[7][i] = MP_DIGIT(a, i+11);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   162
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   163
                s[8][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   164
                s[8][1] = MP_DIGIT(a, 20);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   165
                s[8][2] = MP_DIGIT(a, 21);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   166
                s[8][3] = MP_DIGIT(a, 22);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   167
                s[8][4] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   168
                s[8][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   169
                s[8][6] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   170
                s[8][7] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   171
                s[8][8] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   172
                s[8][9] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   173
                s[8][10] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   174
                s[8][11] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   175
                s[9][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   176
                s[9][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   177
                s[9][2] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   178
                s[9][3] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   179
                s[9][4] = MP_DIGIT(a, 23);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   180
                s[9][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   181
                s[9][6] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   182
                s[9][7] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   183
                s[9][8] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   184
                s[9][9] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   185
                s[9][10] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   186
                s[9][11] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   187
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   188
                MP_CHECKOK(mp_add(&m[0], &m[1], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   189
                MP_CHECKOK(mp_add(r, &m[1], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   190
                MP_CHECKOK(mp_add(r, &m[2], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   191
                MP_CHECKOK(mp_add(r, &m[3], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   192
                MP_CHECKOK(mp_add(r, &m[4], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   193
                MP_CHECKOK(mp_add(r, &m[5], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   194
                MP_CHECKOK(mp_add(r, &m[6], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   195
                MP_CHECKOK(mp_sub(r, &m[7], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   196
                MP_CHECKOK(mp_sub(r, &m[8], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   197
                MP_CHECKOK(mp_submod(r, &m[9], &meth->irr, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   198
                s_mp_clamp(r);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   199
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   200
#else
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   201
        /* for polynomials larger than twice the field size or polynomials
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   202
         * not using all words, use regular reduction */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   203
        if ((a_bits > 768) || (a_bits <= 736)) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   204
                MP_CHECKOK(mp_mod(a, &meth->irr, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   205
        } else {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   206
                for (i = 0; i < 6; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   207
                        s[0][i] = MP_DIGIT(a, i);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   208
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   209
                s[1][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   210
                s[1][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   211
                s[1][2] = (MP_DIGIT(a, 10) >> 32) | (MP_DIGIT(a, 11) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   212
                s[1][3] = MP_DIGIT(a, 11) >> 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   213
                s[1][4] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   214
                s[1][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   215
                for (i = 0; i < 6; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   216
                        s[2][i] = MP_DIGIT(a, i+6);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   217
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   218
                s[3][0] = (MP_DIGIT(a, 10) >> 32) | (MP_DIGIT(a, 11) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   219
                s[3][1] = (MP_DIGIT(a, 11) >> 32) | (MP_DIGIT(a, 6) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   220
                for (i = 2; i < 6; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   221
                        s[3][i] = (MP_DIGIT(a, i+4) >> 32) | (MP_DIGIT(a, i+5) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   222
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   223
                s[4][0] = (MP_DIGIT(a, 11) >> 32) << 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   224
                s[4][1] = MP_DIGIT(a, 10) << 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   225
                for (i = 2; i < 6; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   226
                        s[4][i] = MP_DIGIT(a, i+4);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   227
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   228
                s[5][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   229
                s[5][1] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   230
                s[5][2] = MP_DIGIT(a, 10);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   231
                s[5][3] = MP_DIGIT(a, 11);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   232
                s[5][4] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   233
                s[5][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   234
                s[6][0] = (MP_DIGIT(a, 10) << 32) >> 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   235
                s[6][1] = (MP_DIGIT(a, 10) >> 32) << 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   236
                s[6][2] = MP_DIGIT(a, 11);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   237
                s[6][3] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   238
                s[6][4] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   239
                s[6][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   240
                s[7][0] = (MP_DIGIT(a, 11) >> 32) | (MP_DIGIT(a, 6) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   241
                for (i = 1; i < 6; i++) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   242
                        s[7][i] = (MP_DIGIT(a, i+5) >> 32) | (MP_DIGIT(a, i+6) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   243
                }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   244
                s[8][0] = MP_DIGIT(a, 10) << 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   245
                s[8][1] = (MP_DIGIT(a, 10) >> 32) | (MP_DIGIT(a, 11) << 32);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   246
                s[8][2] = MP_DIGIT(a, 11) >> 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   247
                s[8][3] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   248
                s[8][4] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   249
                s[8][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   250
                s[9][0] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   251
                s[9][1] = (MP_DIGIT(a, 11) >> 32) << 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   252
                s[9][2] = MP_DIGIT(a, 11) >> 32;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   253
                s[9][3] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   254
                s[9][4] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   255
                s[9][5] = 0;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   256
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   257
                MP_CHECKOK(mp_add(&m[0], &m[1], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   258
                MP_CHECKOK(mp_add(r, &m[1], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   259
                MP_CHECKOK(mp_add(r, &m[2], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   260
                MP_CHECKOK(mp_add(r, &m[3], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   261
                MP_CHECKOK(mp_add(r, &m[4], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   262
                MP_CHECKOK(mp_add(r, &m[5], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   263
                MP_CHECKOK(mp_add(r, &m[6], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   264
                MP_CHECKOK(mp_sub(r, &m[7], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   265
                MP_CHECKOK(mp_sub(r, &m[8], r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   266
                MP_CHECKOK(mp_submod(r, &m[9], &meth->irr, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   267
                s_mp_clamp(r);
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   268
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   269
#endif
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   270
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   271
  CLEANUP:
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   272
        return res;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   273
}
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   274
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   275
/* Compute the square of polynomial a, reduce modulo p384. Store the
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   276
 * result in r.  r could be a.  Uses optimized modular reduction for p384.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   277
 */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   278
mp_err
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   279
ec_GFp_nistp384_sqr(const mp_int *a, mp_int *r, const GFMethod *meth)
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   280
{
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   281
        mp_err res = MP_OKAY;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   282
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   283
        MP_CHECKOK(mp_sqr(a, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   284
        MP_CHECKOK(ec_GFp_nistp384_mod(r, r, meth));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   285
  CLEANUP:
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   286
        return res;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   287
}
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   288
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   289
/* Compute the product of two polynomials a and b, reduce modulo p384.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   290
 * Store the result in r.  r could be a or b; a could be b.  Uses
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   291
 * optimized modular reduction for p384. */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   292
mp_err
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   293
ec_GFp_nistp384_mul(const mp_int *a, const mp_int *b, mp_int *r,
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   294
                                        const GFMethod *meth)
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   295
{
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   296
        mp_err res = MP_OKAY;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   297
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   298
        MP_CHECKOK(mp_mul(a, b, r));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   299
        MP_CHECKOK(ec_GFp_nistp384_mod(r, r, meth));
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   300
  CLEANUP:
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   301
        return res;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   302
}
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   303
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   304
/* Wire in fast field arithmetic and precomputation of base point for
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   305
 * named curves. */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   306
mp_err
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   307
ec_group_set_gfp384(ECGroup *group, ECCurveName name)
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   308
{
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   309
        if (name == ECCurve_NIST_P384) {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   310
                group->meth->field_mod = &ec_GFp_nistp384_mod;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   311
                group->meth->field_mul = &ec_GFp_nistp384_mul;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   312
                group->meth->field_sqr = &ec_GFp_nistp384_sqr;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   313
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   314
        return MP_OKAY;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   315
}