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

Do not duplicate call to getenv. #369

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions oqs-template/oqsprov/oqsprov.c/encoding_patching.fragment
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% set cnt = namespace(val=-2) %}
{ const char* envval = NULL;
{%- for sig in config['sigs'] %}
{%- for variant in sig['variants'] %}
{%- set cnt.val = cnt.val + 2 %}
if (getenv("OQS_ENCODING_{{variant['name']|upper}}")) oqs_alg_encoding_list[{{ cnt.val }}] = getenv("OQS_ENCODING_{{variant['name']|upper}}");
if (getenv("OQS_ENCODING_{{variant['name']|upper}}_ALGNAME")) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = getenv("OQS_ENCODING_{{variant['name']|upper}}_ALGNAME");
if ((envval = getenv("OQS_ENCODING_{{variant['name']|upper}}"))) oqs_alg_encoding_list[{{ cnt.val }}] = envval;
if ((envval = getenv("OQS_ENCODING_{{variant['name']|upper}}_ALGNAME"))) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = envval;
{%- for classical_alg in variant['mix_with'] %}
{%- set cnt.val = cnt.val + 2 %}
if (getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}")) oqs_alg_encoding_list[{{ cnt.val }}] = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}");
if (getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}_ALGNAME")) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}_ALGNAME");
if ((envval = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}"))) oqs_alg_encoding_list[{{ cnt.val }}] = envval;
if ((envval = getenv("OQS_ENCODING_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}_ALGNAME"))) oqs_alg_encoding_list[{{ cnt.val + 1 }}] = envval;
{%- endfor %}
{%- for composite_alg in variant['composite'] %}
{%- set cnt.val = cnt.val + 2 %}
Expand All @@ -16,4 +17,5 @@
{%- endfor %}
{%- endfor %}
{%- endfor %}
}

12 changes: 7 additions & 5 deletions oqs-template/oqsprov/oqsprov.c/oid_patching.fragment
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{% set cnt = namespace(val=-2) %}
{
const char *envval = NULL;

#ifdef OQS_KEM_ENCODERS

{% set kemcount = namespace(val=-2) %}
{% for kem in config['kems'] %}
{% set kemcount.val = kemcount.val + 2 -%}
if (getenv("OQS_OID_{{kem['name_group']|upper}}")) oqs_oid_alg_list[{{ kemcount.val }}] = getenv("OQS_OID_{{kem['name_group']|upper}}");
if ((envval = getenv("OQS_OID_{{kem['name_group']|upper}}"))) oqs_oid_alg_list[{{ kemcount.val }}] = envval;
{% for hybrid in kem['hybrids'] %}
{% set kemcount.val = kemcount.val + 2 -%}
if (getenv("OQS_OID_{{ hybrid['hybrid_group']|upper }}_{{kem['name_group']|upper}}")) oqs_oid_alg_list[{{ kemcount.val }}] = getenv("OQS_OID_{{ hybrid['hybrid_group']|upper }}_{{kem['name_group']|upper}}");
if ((envval = getenv("OQS_OID_{{ hybrid['hybrid_group']|upper }}_{{kem['name_group']|upper}}"))) oqs_oid_alg_list[{{ kemcount.val }}] = envval;
{%- endfor -%}
{%- endfor %}

Expand All @@ -20,11 +22,11 @@
{%- for sig in config['sigs'] %}
{%- for variant in sig['variants'] %}
{%- set cnt.val = cnt.val + 2 %}
if (getenv("OQS_OID_{{variant['name']|upper}}")) oqs_oid_alg_list[{{ cnt.val }}+OQS_KEMOID_CNT] = getenv("OQS_OID_{{variant['name']|upper}}");
if ((envval = getenv("OQS_OID_{{variant['name']|upper}}"))) oqs_oid_alg_list[{{ cnt.val }}+OQS_KEMOID_CNT] = envval;
{%- for classical_alg in variant['mix_with'] %}
{%- set cnt.val = cnt.val + 2 %}
if (getenv("OQS_OID_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}")) oqs_oid_alg_list[{{ cnt.val }}+OQS_KEMOID_CNT] = getenv("OQS_OID_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}");
if ((envval = getenv("OQS_OID_{{ classical_alg['name']|upper }}_{{variant['name']|upper}}"))) oqs_oid_alg_list[{{ cnt.val }}+OQS_KEMOID_CNT] = envval;
{%- endfor %}
{%- endfor %}
{%- endfor %}

}
Loading
Loading