rename ecc_get_curve to ecc_find_curve

This commit is contained in:
Karel Miko 2018-07-04 10:38:38 +02:00
parent 611ca6bf14
commit 4bec98f88c
6 changed files with 15 additions and 15 deletions

View File

@ -251,7 +251,7 @@ int ecc_test(void);
void ecc_sizes(int *low, int *high);
int ecc_get_size(const ecc_key *key);
int ecc_get_curve(const char* name_or_oid, const ltc_ecc_curve** cu);
int ecc_find_curve(const char* name_or_oid, const ltc_ecc_curve** cu);
int ecc_set_curve(const ltc_ecc_curve *cu, ecc_key *key);
int ecc_generate_key(prng_state *prng, int wprng, ecc_key *key);
int ecc_set_key(const unsigned char *in, unsigned long inlen, int type, ecc_key *key);

View File

@ -212,7 +212,7 @@ static int _name_match(const char *left, const char *right)
return 0;
}
int ecc_get_curve(const char *name_or_oid, const ltc_ecc_curve **cu)
int ecc_find_curve(const char *name_or_oid, const ltc_ecc_curve **cu)
{
int i, j;
const char *OID = NULL;

View File

@ -36,7 +36,7 @@ static int _ecc_import_private_with_oid(const unsigned char *in, unsigned long i
/* load curve parameters for given curve OID */
len = sizeof(OID);
if ((err = pk_oid_num_to_str(curveoid, custom[0].size, OID, &len)) != CRYPT_OK) { goto error; }
if ((err = ecc_get_curve(OID, &curve)) != CRYPT_OK) { goto error; }
if ((err = ecc_find_curve(OID, &curve)) != CRYPT_OK) { goto error; }
if ((err = ecc_set_curve(curve, key)) != CRYPT_OK) { goto error; }
/* load private+public key */
err = ecc_set_key(bin_k, seq_priv[1].size, PK_PRIVATE, key);

View File

@ -27,7 +27,7 @@ static int _ecc_import_x509_with_oid(const unsigned char *in, unsigned long inle
/* load curve parameters for given curve OID */
len = sizeof(OID);
if ((err = pk_oid_num_to_str(curveoid, len_oid, OID, &len)) != CRYPT_OK) { goto error; }
if ((err = ecc_get_curve(OID, &curve)) != CRYPT_OK) { goto error; }
if ((err = ecc_find_curve(OID, &curve)) != CRYPT_OK) { goto error; }
if ((err = ecc_set_curve(curve, key)) != CRYPT_OK) { goto error; }
/* load public key */
err = ecc_set_key(bin_xy, len_xy, PK_PUBLIC, key);

View File

@ -54,28 +54,28 @@ int ecc_set_curve_by_size(int size, ecc_key *key)
/* for compatibility with libtomcrypt-1.17 the sizes below must match the specific curves */
if (size <= 14) {
err = ecc_get_curve("SECP112R1", &cu);
err = ecc_find_curve("SECP112R1", &cu);
}
else if (size <= 16) {
err = ecc_get_curve("SECP128R1", &cu);
err = ecc_find_curve("SECP128R1", &cu);
}
else if (size <= 20) {
err = ecc_get_curve("SECP160R1", &cu);
err = ecc_find_curve("SECP160R1", &cu);
}
else if (size <= 24) {
err = ecc_get_curve("SECP192R1", &cu);
err = ecc_find_curve("SECP192R1", &cu);
}
else if (size <= 28) {
err = ecc_get_curve("SECP224R1", &cu);
err = ecc_find_curve("SECP224R1", &cu);
}
else if (size <= 32) {
err = ecc_get_curve("SECP256R1", &cu);
err = ecc_find_curve("SECP256R1", &cu);
}
else if (size <= 48) {
err = ecc_get_curve("SECP384R1", &cu);
err = ecc_find_curve("SECP384R1", &cu);
}
else if (size <= 66) {
err = ecc_get_curve("SECP521R1", &cu);
err = ecc_find_curve("SECP521R1", &cu);
}
if (err == CRYPT_OK && cu != NULL) return ecc_set_curve(cu, key);

View File

@ -130,7 +130,7 @@ static int _ecc_issue108(void)
Result = ltc_ecc_new_point();
/* ECC-224 AKA SECP224R1 */
if ((err = ecc_get_curve("SECP224R1", &dp)) != CRYPT_OK) { goto done; }
if ((err = ecc_find_curve("SECP224R1", &dp)) != CRYPT_OK) { goto done; }
/* read A */
if ((err = mp_read_radix(a, (char *)dp->A, 16)) != CRYPT_OK) { goto done; }
/* read modulus */
@ -446,7 +446,7 @@ int _ecc_new_api(void)
unsigned long len16;
for (i = 0; i < (int)(sizeof(names)/sizeof(names[0])); i++) {
DO(ecc_get_curve(names[i], &dp));
DO(ecc_find_curve(names[i], &dp));
/* make new key */
DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp));
len = sizeof(buf);
@ -798,7 +798,7 @@ int _ecc_import_export(void) {
DO(ecc_import_openssl(short_pub, sizeof(short_pub), &pub));
DO(ecc_import_openssl(short_pri, sizeof(short_pri), &pri));
DO(ecc_get_curve("SECP256K1", &cu));
DO(ecc_find_curve("SECP256K1", &cu));
/* import - raw keys */
DO(ecc_set_curve(cu, &key));