Codebase list libcryptx-perl / 8af2bc8
ecc_dp_fill_from_sets fix Karel Miko 6 years ago
1 changed file(s) with 28 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
1111
1212 #ifdef LTC_MECC
1313
14 static int hexstrcmp(const char *hexa, const char *hexb)
15 {
16 #define MY_TOLOWER(a) ((((a)>='A')&&((a)<='Z')) ? ((a)|0x60) : (a))
17 /* ignore leading zeroes */
18 while(*hexa == '0') hexa++;
19 while(*hexb == '0') hexb++;
20 /* compare: case insensitive, hexadecimal chars only */
21 while (*hexa && *hexb) {
22 if ( (*hexa < '0' || *hexa > '9') &&
23 (*hexa < 'a' || *hexa > 'f') &&
24 (*hexa < 'A' || *hexa > 'F') ) return 1;
25 if ( (*hexb < '0' || *hexb > '9') &&
26 (*hexb < 'a' || *hexb > 'f') &&
27 (*hexb < 'A' || *hexb > 'F') ) return 1;
28 if (MY_TOLOWER(*hexa) != MY_TOLOWER(*hexb)) return 1;
29 hexa++;
30 hexb++;
31 }
32 if (*hexa == '\0' && *hexb == '\0') return 0; /* success - match */
33 return 1;
34 }
35
1436 /* search known curve by curve parameters and fill in missing parameters into dp
1537 * we assume every parameter has the same case (usually uppercase) and no leading zeros
1638 */
2446 if (!dp->prime || !dp->A || !dp->B || !dp->order || !dp->Gx || !dp->Gy || dp->cofactor == 0) return CRYPT_INVALID_ARG;
2547
2648 for (x = 0; ltc_ecc_sets[x].size != 0; x++) {
27 if (XSTRCMP(ltc_ecc_sets[x].prime, dp->prime) == 0 &&
28 XSTRCMP(ltc_ecc_sets[x].A, dp->A) == 0 &&
29 XSTRCMP(ltc_ecc_sets[x].B, dp->B) == 0 &&
30 XSTRCMP(ltc_ecc_sets[x].order, dp->order) == 0 &&
31 XSTRCMP(ltc_ecc_sets[x].Gx, dp->Gx) == 0 &&
32 XSTRCMP(ltc_ecc_sets[x].Gy, dp->Gy) == 0 &&
49 if (hexstrcmp(ltc_ecc_sets[x].prime, dp->prime) == 0 &&
50 hexstrcmp(ltc_ecc_sets[x].A, dp->A) == 0 &&
51 hexstrcmp(ltc_ecc_sets[x].B, dp->B) == 0 &&
52 hexstrcmp(ltc_ecc_sets[x].order, dp->order) == 0 &&
53 hexstrcmp(ltc_ecc_sets[x].Gx, dp->Gx) == 0 &&
54 hexstrcmp(ltc_ecc_sets[x].Gy, dp->Gy) == 0 &&
3355 ltc_ecc_sets[x].cofactor == dp->cofactor) {
3456
3557 params = ltc_ecc_sets[x];