static QString oid_sect() { QString ret; int i, max = OBJ_new_nid(0); for (i=first_additional_oid; i < max; i++) { const char *sn = OBJ_nid2sn(i); if (!sn) break; ret += QString("%1 = %2\n"). arg(OBJ_nid2sn(i)). arg(OBJ_obj2QString(OBJ_nid2obj(i), 1)); } if (!ret.isEmpty()) { ret = QString("oid_section = xca_oids\n\n" "[ xca_oids ]\n") + ret + "\n"; } return ret; }
builtin_curves::builtin_curves() { int i, num_curves = EC_get_builtin_curves(NULL, 0); EC_builtin_curve *curves = (EC_builtin_curve*)OPENSSL_malloc( (int)(sizeof(EC_builtin_curve) *num_curves)); check_oom(curves); BIGNUM *order = BN_new(); check_oom(order); EC_get_builtin_curves(curves, num_curves); for (i=0; i< num_curves; i++) { size_t j; int flag = 0, nid = curves[i].nid; unsigned long type = 0; for (j=0; j<ARRAY_SIZE(x962_curve_nids); j++) { if (x962_curve_nids[j] == nid) { flag = CURVE_X962; break; } } if (!flag) { for (j=0; j<ARRAY_SIZE(other_curve_nids); j++) { if (other_curve_nids[j] == nid) { flag = CURVE_OTHER; break; } } } if (!flag) continue; EC_GROUP *group = EC_GROUP_new_by_curve_name(nid); EC_GROUP_get_order(group, order, NULL); switch (EC_METHOD_get_field_type(EC_GROUP_method_of(group))) { case NID_X9_62_prime_field: type = CKF_EC_F_P; break; case NID_X9_62_characteristic_two_field: type = CKF_EC_F_2M; break; default: continue; } #undef PRINT_KNOWN_CURVES #ifdef PRINT_KNOWN_CURVES fprintf(stderr, "%50s %27s %20s %s\n", curves[i].comment, OBJ_nid2sn(nid), CCHAR(OBJ_obj2QString(OBJ_nid2obj(nid), 1)), type == CKF_EC_F_P ? "Fp" : "F2m"); #endif append(builtin_curve(nid, QString(curves[i].comment), BN_num_bits(order), flag, type)); EC_GROUP_free(group); } BN_free(order); }