Skip to content

Commit

Permalink
disable tests on no-OID KEMs
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Baentsch <57787676+baentsch@users.noreply.github.com>
  • Loading branch information
baentsch committed Sep 15, 2024
1 parent a60f6b7 commit e94338d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 46 deletions.
94 changes: 48 additions & 46 deletions oqsprov/oqsprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,53 +1153,55 @@ int OQS_PROVIDER_ENTRYPOINT_NAME(const OSSL_CORE_HANDLE *handle,
if (oqs_oid_alg_list[i] == NULL) {
OQS_PROV_PRINTF2("OQS PROV: Warning: No OID registered for %s\n",
oqs_oid_alg_list[i + 1]);
break;
}
if (!c_obj_create(handle, oqs_oid_alg_list[i], oqs_oid_alg_list[i + 1],
oqs_oid_alg_list[i + 1])) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
fprintf(stderr, "error registering NID for %s\n",
oqs_oid_alg_list[i + 1]);
goto end_init;
}

/* create object (NID) again to avoid setup corner case problems
* see https://github.com/openssl/openssl/discussions/21903
* Not testing for errors is intentional.
* At least one core version hangs up; so don't do this there:
*/
if (strcmp("3.1.0", ossl_versionp)) {
ERR_set_mark();
OBJ_create(oqs_oid_alg_list[i], oqs_oid_alg_list[i + 1],
oqs_oid_alg_list[i + 1]);
ERR_pop_to_mark();
}

if (!oqs_set_nid((char *)oqs_oid_alg_list[i + 1],
OBJ_sn2nid(oqs_oid_alg_list[i + 1]))) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
}

if (!c_obj_add_sigid(handle, oqs_oid_alg_list[i + 1], "",
oqs_oid_alg_list[i + 1])) {
fprintf(stderr, "error registering %s with no hash\n",
oqs_oid_alg_list[i + 1]);
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
}

if (OBJ_sn2nid(oqs_oid_alg_list[i + 1]) != 0) {
OQS_PROV_PRINTF3(
"OQS PROV: successfully registered %s with NID %d\n",
oqs_oid_alg_list[i + 1], OBJ_sn2nid(oqs_oid_alg_list[i + 1]));
} else {
fprintf(stderr,
"OQS PROV: Impossible error: NID unregistered "
"for %s.\n",
oqs_oid_alg_list[i + 1]);
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
if (!c_obj_create(handle, oqs_oid_alg_list[i],
oqs_oid_alg_list[i + 1],
oqs_oid_alg_list[i + 1])) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
fprintf(stderr, "error registering NID for %s\n",
oqs_oid_alg_list[i + 1]);
goto end_init;
}

/* create object (NID) again to avoid setup corner case problems
* see https://github.com/openssl/openssl/discussions/21903
* Not testing for errors is intentional.
* At least one core version hangs up; so don't do this there:
*/
if (strcmp("3.1.0", ossl_versionp)) {
ERR_set_mark();
OBJ_create(oqs_oid_alg_list[i], oqs_oid_alg_list[i + 1],
oqs_oid_alg_list[i + 1]);
ERR_pop_to_mark();
}

if (!oqs_set_nid((char *)oqs_oid_alg_list[i + 1],
OBJ_sn2nid(oqs_oid_alg_list[i + 1]))) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
}

if (!c_obj_add_sigid(handle, oqs_oid_alg_list[i + 1], "",
oqs_oid_alg_list[i + 1])) {
fprintf(stderr, "error registering %s with no hash\n",
oqs_oid_alg_list[i + 1]);
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
}

if (OBJ_sn2nid(oqs_oid_alg_list[i + 1]) != 0) {
OQS_PROV_PRINTF3(
"OQS PROV: successfully registered %s with NID %d\n",
oqs_oid_alg_list[i + 1],
OBJ_sn2nid(oqs_oid_alg_list[i + 1]));
} else {
fprintf(stderr,
"OQS PROV: Impossible error: NID unregistered "
"for %s.\n",
oqs_oid_alg_list[i + 1]);
ERR_raise(ERR_LIB_USER, OQSPROV_R_OBJ_CREATE_ERR);
goto end_init;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/oqs_test_endecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ static int test_oqs_encdec(const char *alg_name) {
if (pkey == NULL)
goto end;

if (!OBJ_sn2nid(alg_name)) {
printf("No OID registered for %s", alg_name);
ok = 1;
goto end;
}
if (!encode_EVP_PKEY_prov(pkey, test_params_list[i].format,
test_params_list[i].structure,
test_params_list[i].pass,
Expand Down

0 comments on commit e94338d

Please sign in to comment.