ecl.c revision f9fbec18f5b458b560ecf45d3db8e8bd56bf6942
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * ***** BEGIN LICENSE BLOCK *****
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the Mozilla Public License Version
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * 1.1 (the "License"); you may not use this file except in compliance with
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the License. You may obtain a copy of the License at
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Software distributed under the License is distributed on an "AS IS" basis,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * for the specific language governing rights and limitations under the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The Original Code is the elliptic curve math library.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The Initial Developer of the Original Code is
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Sun Microsystems, Inc.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Portions created by the Initial Developer are Copyright (C) 2003
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the Initial Developer. All Rights Reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Contributor(s):
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Alternatively, the contents of this file may be used under the terms of
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * either the GNU General Public License Version 2 or later (the "GPL"), or
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * in which case the provisions of the GPL or the LGPL are applicable instead
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * of those above. If you wish to allow use of your version of this file only
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * under the terms of either the GPL or the LGPL, and not to allow others to
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * use your version of this file under the terms of the MPL, indicate your
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * decision by deleting the provisions above and replace them with the notice
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and other provisions required by the GPL or the LGPL. If you do not delete
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * the provisions above, a recipient may use your version of this file under
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * the terms of any one of the MPL, the GPL or the LGPL.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * ***** END LICENSE BLOCK ***** */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Sun elects to use this software under the MPL license.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#pragma ident "%Z%%M% %I% %E% SMI"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/* Allocate memory for a new ECGroup object. */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi group = (ECGroup *) kmem_alloc(sizeof(ECGroup), kmflag);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/* Construct a generic ECGroup for elliptic curves over prime fields. */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiECGroup_consGFp(const mp_int *irr, const mp_int *curvea,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi const mp_int *geny, const mp_int *order, int cofactor)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/* Construct a generic ECGroup for elliptic curves over prime fields with
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * field arithmetic implemented in Montgomery coordinates. */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiECGroup_consGFp_mont(const mp_int *irr, const mp_int *curvea,
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae MP_CHECKOK(group->meth->field_enc(genx, &group->genx, group->meth));
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi MP_CHECKOK(group->meth->field_enc(geny, &group->geny, group->meth));
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/* Construct a generic ECGroup for elliptic curves over binary polynomial
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * fields. */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiECGroup_consGF2m(const mp_int *irr, const unsigned int irr_arr[5],
return NULL;
return group;
ECGroup *
int bits;
goto CLEANUP;
#ifdef NSS_ECC_MORE_THAN_SUITE_B
switch (name) {
#ifdef ECL_USE_FP
case ECCurve_SECG_PRIME_160R1:
group =
case ECCurve_SECG_PRIME_192R1:
#ifdef ECL_USE_FP
group =
group =
case ECCurve_SECG_PRIME_224R1:
#ifdef ECL_USE_FP
group =
group =
case ECCurve_SECG_PRIME_256R1:
group =
case ECCurve_SECG_PRIME_521R1:
group =
group =
#ifdef NSS_ECC_MORE_THAN_SUITE_B
goto CLEANUP;
#ifdef _KERNEL
goto CLEANUP;
return NULL;
return group;
ECGroup *
ECGroup *
goto CLEANUP;
goto CLEANUP;
return NULL;
return group;
#ifdef _KERNEL
#ifdef _KERNEL