< prev index next >

src/jdk.crypto.ec/share/native/libsunec/impl/ec.c

Print this page
rev 16167 : 8170525: Fix minor issues in awt coding


 241 }
 242 
 243 /* Generates a new EC key pair. The private key is a supplied
 244  * value and the public key is the result of performing a scalar
 245  * point multiplication of that value with the curve's base point.
 246  */
 247 SECStatus
 248 ec_NewKey(ECParams *ecParams, ECPrivateKey **privKey,
 249     const unsigned char *privKeyBytes, int privKeyLen, int kmflag)
 250 {
 251     SECStatus rv = SECFailure;
 252     PRArenaPool *arena;
 253     ECPrivateKey *key;
 254     mp_int k;
 255     mp_err err = MP_OKAY;
 256     int len;
 257 
 258 #if EC_DEBUG
 259     printf("ec_NewKey called\n");
 260 #endif

 261 
 262     if (!ecParams || !privKey || !privKeyBytes || (privKeyLen < 0)) {
 263         PORT_SetError(SEC_ERROR_INVALID_ARGS);
 264         return SECFailure;
 265     }
 266 
 267     /* Initialize an arena for the EC key. */
 268     if (!(arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE)))
 269         return SECFailure;
 270 
 271     key = (ECPrivateKey *)PORT_ArenaZAlloc(arena, sizeof(ECPrivateKey),
 272         kmflag);
 273     if (!key) {
 274         PORT_FreeArena(arena, PR_TRUE);
 275         return SECFailure;
 276     }
 277 
 278     /* Set the version number (SEC 1 section C.4 says it should be 1) */
 279     SECITEM_AllocItem(arena, &key->version, 1, kmflag);
 280     key->version.data[0] = 1;




 241 }
 242 
 243 /* Generates a new EC key pair. The private key is a supplied
 244  * value and the public key is the result of performing a scalar
 245  * point multiplication of that value with the curve's base point.
 246  */
 247 SECStatus
 248 ec_NewKey(ECParams *ecParams, ECPrivateKey **privKey,
 249     const unsigned char *privKeyBytes, int privKeyLen, int kmflag)
 250 {
 251     SECStatus rv = SECFailure;
 252     PRArenaPool *arena;
 253     ECPrivateKey *key;
 254     mp_int k;
 255     mp_err err = MP_OKAY;
 256     int len;
 257 
 258 #if EC_DEBUG
 259     printf("ec_NewKey called\n");
 260 #endif
 261     k.dp = (mp_digit)0;
 262 
 263     if (!ecParams || !privKey || !privKeyBytes || (privKeyLen < 0)) {
 264         PORT_SetError(SEC_ERROR_INVALID_ARGS);
 265         return SECFailure;
 266     }
 267 
 268     /* Initialize an arena for the EC key. */
 269     if (!(arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE)))
 270         return SECFailure;
 271 
 272     key = (ECPrivateKey *)PORT_ArenaZAlloc(arena, sizeof(ECPrivateKey),
 273         kmflag);
 274     if (!key) {
 275         PORT_FreeArena(arena, PR_TRUE);
 276         return SECFailure;
 277     }
 278 
 279     /* Set the version number (SEC 1 section C.4 says it should be 1) */
 280     SECITEM_AllocItem(arena, &key->version, 1, kmflag);
 281     key->version.data[0] = 1;


< prev index next >