Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom OID by environment variable offset misalignment #417

Closed
iMrYang opened this issue May 24, 2024 · 3 comments · Fixed by #419
Closed

Custom OID by environment variable offset misalignment #417

iMrYang opened this issue May 24, 2024 · 3 comments · Fixed by #419
Labels
bug Something isn't working

Comments

@iMrYang
Copy link

iMrYang commented May 24, 2024

Describe the bug

If environment variable is defined, the function oqs_patch_oids() modifies array oqs_oid_alg_list OID.
There is an incorrect offset value after the OQS_OID_RSA3072_MLDSA44 environment variable.
The next environment variable after OQS_OID_RSA3072_MLDSA44 is OQS_OID_MLDSA65, but in array oqs_oid_alg_list, after rsa3072_mldsa44 is mldsa44_pss2048, not mldsa65

const char *oqs_oid_alg_list[OQS_OID_CNT] = {
    ...
    
    "1.3.6.1.4.1.2.267.12.4.4",
    "mldsa44",
    "1.3.9999.7.1",
    "p256_mldsa44",
    "1.3.9999.7.2",
    "rsa3072_mldsa44",                  /* rsa3072_mldsa44,  */
    "2.16.840.1.114027.80.8.1.1",
    "mldsa44_pss2048",
    "2.16.840.1.114027.80.8.1.2",
    "mldsa44_rsa2048",
    "2.16.840.1.114027.80.8.1.3",
    "mldsa44_ed25519",
    "2.16.840.1.114027.80.8.1.4",
    "mldsa44_p256",
    "2.16.840.1.114027.80.8.1.5",
    "mldsa44_bp256",
    "1.3.6.1.4.1.2.267.12.6.5",
    "mldsa65",                          /* mldsa65  */
    "1.3.9999.7.3",
    "p384_mldsa65",

    ... 
};
int oqs_patch_oids(void)
{
    ...

    if ((envval = getenv("OQS_OID_MLDSA44")))
        oqs_oid_alg_list[14 + OQS_KEMOID_CNT] = envval;
    if ((envval = getenv("OQS_OID_P256_MLDSA44")))
        oqs_oid_alg_list[16 + OQS_KEMOID_CNT] = envval;
    if ((envval = getenv("OQS_OID_RSA3072_MLDSA44")))       /* rsa3072_mldsa44 */
        oqs_oid_alg_list[18 + OQS_KEMOID_CNT] = envval;
                                                            /* <-- here lose */
    if ((envval = getenv("OQS_OID_MLDSA65")))               /* mldsa65, offset is incorrect after this  */
        oqs_oid_alg_list[20 + OQS_KEMOID_CNT] = envval;
    if ((envval = getenv("OQS_OID_P384_MLDSA65")))
        oqs_oid_alg_list[22 + OQS_KEMOID_CNT] = envval;

    ...
}
@iMrYang iMrYang added the bug Something isn't working label May 24, 2024
@baentsch
Copy link
Member

Thanks for this bug report, @iMrYang . This is indeed wrong.

The error is apparently caused by a missing code generation snippet for operating on composite algorithms that is present for the baseline OID list. Tagging @feventura fyi: You'd arguably be best placed to rectify this: Please let us know whether you'd have time to provide a PR for this or whether someone else should look into this.

@baentsch
Copy link
Member

@feventura Please disregard my question above: It was easier to fix than I thought: Please check #419. @iMrYang please let me know whether you'd agree this solves the problem.

@iMrYang
Copy link
Author

iMrYang commented May 27, 2024

@baentsch I agree, at least the file oqsprov.c is as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants