/*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* 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
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Sun elects to use this software under the MPL license.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#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'] */
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
#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;
}
}