/*
* Use is subject to license terms.
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* *********************************************************************
*
* The Original Code is the Elliptic Curve Cryptography library.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dr Vipul Gupta <vipul.gupta@sun.com> and
* Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
*
*********************************************************************** */
#ifndef _WIN32
#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
#endif /* __linux__ || _ALLBSD_SOURCE */
#endif /* _WIN32 */
#ifdef _KERNEL
#else
#include <string.h>
#endif
#include "ec.h"
#include "ecl-curve.h"
#include "ecc_impl.h"
/*
* Initializes a SECItem from a hexadecimal string
*
* Warning: This function ignores leading 00's, so any leading 00's
* in the hexadecimal string must be optional.
*/
static SECItem *
int kmflag)
{
int i = 0;
int byteval = 0;
/* skip leading 00's unless the hex string is "00" */
str += 2;
tmp -= 2;
}
while (str[i]) {
else
return NULL;
if ((i % 2) != 0) {
byteval = 0;
}
i++;
}
return item;
}
static SECStatus
int kmflag)
{
/* 2 ['0'+'4'] + MAX_ECKEY_LEN * 2 [x,y] * 2 [hex string] + 1 ['\0'] */
goto cleanup;
if (field_type == ec_field_GFp) {
} else {
}
genenc[0] = '0';
rv = SECSuccess;
return rv;
}
{
#if EC_DEBUG
int i;
printf("Encoded params in EC_DecodeParams: ");
for (i = 0; i < encodedParams->len; i++) {
}
printf("\n");
#endif
return SECFailure;
};
return SECFailure;
}
/* For named curves, fill out curveOID */
kmflag);
#if EC_DEBUG
#ifndef SECOID_FindOIDTagDescription
#else
#endif
#endif
switch (tag) {
/* Binary curves */
/* Populate params for c2pnb163v1 */
break;
/* Populate params for c2pnb163v2 */
break;
/* Populate params for c2pnb163v3 */
break;
/* Populate params for c2pnb176v1 */
break;
/* Populate params for c2tnb191v1 */
break;
/* Populate params for c2tnb191v2 */
break;
/* Populate params for c2tnb191v3 */
break;
/* Populate params for c2pnb208w1 */
break;
/* Populate params for c2tnb239v1 */
break;
/* Populate params for c2tnb239v2 */
break;
/* Populate params for c2tnb239v3 */
break;
/* Populate params for c2pnb272w1 */
break;
/* Populate params for c2pnb304w1 */
break;
/* Populate params for c2tnb359v1 */
break;
/* Populate params for c2pnb368w1 */
break;
/* Populate params for c2tnb431r1 */
break;
case ECCurve_SECG_CHAR2_113R1:
/* Populate params for sect113r1 */
break;
case ECCurve_SECG_CHAR2_113R2:
/* Populate params for sect113r2 */
break;
case ECCurve_SECG_CHAR2_131R1:
/* Populate params for sect131r1 */
break;
case ECCurve_SECG_CHAR2_131R2:
/* Populate params for sect131r2 */
break;
case ECCurve_SECG_CHAR2_163K1:
/* Populate params for sect163k1
* (the NIST K-163 curve)
*/
break;
case ECCurve_SECG_CHAR2_163R1:
/* Populate params for sect163r1 */
break;
case ECCurve_SECG_CHAR2_163R2:
/* Populate params for sect163r2
* (the NIST B-163 curve)
*/
break;
case ECCurve_SECG_CHAR2_193R1:
/* Populate params for sect193r1 */
break;
case ECCurve_SECG_CHAR2_193R2:
/* Populate params for sect193r2 */
break;
case ECCurve_SECG_CHAR2_233K1:
/* Populate params for sect233k1
* (the NIST K-233 curve)
*/
break;
case ECCurve_SECG_CHAR2_233R1:
/* Populate params for sect233r1
* (the NIST B-233 curve)
*/
break;
case ECCurve_SECG_CHAR2_239K1:
/* Populate params for sect239k1 */
break;
case ECCurve_SECG_CHAR2_283K1:
/* Populate params for sect283k1
* (the NIST K-283 curve)
*/
break;
case ECCurve_SECG_CHAR2_283R1:
/* Populate params for sect283r1
* (the NIST B-283 curve)
*/
break;
case ECCurve_SECG_CHAR2_409K1:
/* Populate params for sect409k1
* (the NIST K-409 curve)
*/
break;
case ECCurve_SECG_CHAR2_409R1:
/* Populate params for sect409r1
* (the NIST B-409 curve)
*/
break;
case ECCurve_SECG_CHAR2_571K1:
/* Populate params for sect571k1
* (the NIST K-571 curve)
*/
break;
case ECCurve_SECG_CHAR2_571R1:
/* Populate params for sect571r1
* (the NIST B-571 curve)
*/
break;
/* Prime curves */
/* Populate params for prime192v1 aka secp192r1
* (the NIST P-192 curve)
*/
break;
/* Populate params for prime192v2 */
break;
/* Populate params for prime192v3 */
break;
/* Populate params for prime239v1 */
break;
/* Populate params for prime239v2 */
break;
/* Populate params for prime239v3 */
break;
/* Populate params for prime256v1 aka secp256r1
* (the NIST P-256 curve)
*/
break;
case ECCurve_SECG_PRIME_112R1:
/* Populate params for secp112r1 */
break;
case ECCurve_SECG_PRIME_112R2:
/* Populate params for secp112r2 */
break;
case ECCurve_SECG_PRIME_128R1:
/* Populate params for secp128r1 */
break;
case ECCurve_SECG_PRIME_128R2:
/* Populate params for secp128r2 */
break;
case ECCurve_SECG_PRIME_160K1:
/* Populate params for secp160k1 */
break;
case ECCurve_SECG_PRIME_160R1:
/* Populate params for secp160r1 */
break;
case ECCurve_SECG_PRIME_160R2:
/* Populate params for secp160r1 */
break;
case ECCurve_SECG_PRIME_192K1:
/* Populate params for secp192k1 */
break;
case ECCurve_SECG_PRIME_224K1:
/* Populate params for secp224k1 */
break;
case ECCurve_SECG_PRIME_224R1:
/* Populate params for secp224r1
* (the NIST P-224 curve)
*/
break;
case ECCurve_SECG_PRIME_256K1:
/* Populate params for secp256k1 */
break;
case ECCurve_SECG_PRIME_384R1:
/* Populate params for secp384r1
* (the NIST P-384 curve)
*/
break;
case ECCurve_SECG_PRIME_521R1:
/* Populate params for secp521r1
* (the NIST P-521 curve)
*/
break;
default:
break;
};
#if EC_DEBUG
printf("Unrecognized curve, returning NULL params\n");
#endif
}
return rv;
}
{
/* Initialize an arena for the ECParams structure */
return SECFailure;
if (!params) {
return SECFailure;
}
/* Copy the encoded params */
kmflag);
/* Fill out the rest of the ECParams structure based on
* the encoded params
*/
if (rv == SECFailure) {
return SECFailure;
} else {
return SECSuccess;
}
}