From f42cde07ba578be178f71ead9919c34f24fd74d5 Mon Sep 17 00:00:00 2001 From: feventura Date: Fri, 18 Oct 2024 15:36:36 -0400 Subject: [PATCH] changes to get_composite_idx Signed-off-by: feventura --- oqsprov/oqs_prov.h | 2 +- oqsprov/oqs_sig.c | 4 ++-- oqsprov/oqsprov.c | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/oqsprov/oqs_prov.h b/oqsprov/oqs_prov.h index bb8ed1a9..33d74350 100644 --- a/oqsprov/oqs_prov.h +++ b/oqsprov/oqs_prov.h @@ -203,7 +203,7 @@ char *get_oqsname_fromtls(char *tlsname); char *get_oqsname(int nid); char *get_cmpname(int nid, int index); int get_oqsalg_idx(int nid); -int get_composite_idx(int idx); +int get_composite_idx(char *name); /* Workaround for not functioning EC PARAM initialization * TBD, check https://github.com/openssl/openssl/issues/16989 diff --git a/oqsprov/oqs_sig.c b/oqsprov/oqs_sig.c index 83305bb2..91250642 100644 --- a/oqsprov/oqs_sig.c +++ b/oqsprov/oqs_sig.c @@ -447,7 +447,7 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, unsigned char *buf; int i; int nid = OBJ_sn2nid(oqsxkey->tls_name); - int comp_idx = get_composite_idx(get_oqsalg_idx(nid)); + int comp_idx = get_composite_idx(oqsxkey->tls_name); if (comp_idx == -1) goto endsign; const unsigned char *oid_prefix = composite_OID_prefix[comp_idx - 1]; @@ -799,7 +799,7 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, CompositeSignature *compsig; int i; int nid = OBJ_sn2nid(oqsxkey->tls_name); - int comp_idx = get_composite_idx(get_oqsalg_idx(nid)); + int comp_idx = get_composite_idx(oqsxkey->tls_name); if (comp_idx == -1) goto endverify; unsigned char *buf; diff --git a/oqsprov/oqsprov.c b/oqsprov/oqsprov.c index 899032c3..559e9826 100644 --- a/oqsprov/oqsprov.c +++ b/oqsprov/oqsprov.c @@ -997,13 +997,20 @@ static const OSSL_ALGORITHM oqsprovider_decoder[] = { }; // get the last number on the composite OID -int get_composite_idx(int idx) { - char *s; +int get_composite_idx(char *name) { + char *s = NULL; int i, len, ret = -1, count = 0; - if (2 * idx > OQS_OID_CNT) - return 0; - s = (char *)oqs_oid_alg_list[idx * 2]; + for (i = 1; i <= OQS_OID_CNT; i += 2) { + if (!strcmp((char *)oqs_oid_alg_list[i], name)) { + s = (char *)oqs_oid_alg_list[i - 1]; + break; + } + } + if (s == NULL) { + return ret; + } + len = strlen(s); for (i = 0; i < len; i++) {