Skip to content

Commit

Permalink
changes to get_composite_idx
Browse files Browse the repository at this point in the history
Signed-off-by: feventura <[email protected]>
  • Loading branch information
feventura committed Oct 18, 2024
1 parent 829817c commit f42cde0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion oqsprov/oqs_prov.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions oqsprov/oqs_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 12 additions & 5 deletions oqsprov/oqsprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit f42cde0

Please sign in to comment.