Skip to content

Commit

Permalink
merged with lastest commit from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
feventura committed Nov 4, 2023
2 parents 7f87423 + 4dac252 commit 4df9d0e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions oqsprov/oqs_encode_key2any.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[])
}
}
OQS_ENC_PRINTF2(" cipher set to %p: \n", ctx->cipher);
// not passing in a cipher param will lead to no-op hence no error
return 1;
}

Expand Down
4 changes: 4 additions & 0 deletions oqsprov/oqs_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl,
goto err;
}
}
// not passing in params to respond to is no error; the response is empty
ret = 1;
err:
return ret;
Expand Down Expand Up @@ -374,6 +375,7 @@ static int oqsx_get_params(void *key, OSSL_PARAM params[])
return 0;
}

// not passing in params to respond to is no error
return 1;
}

Expand Down Expand Up @@ -444,6 +446,7 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[])
}
}

// not passing in params to set is no error, just a no-op
return 1;
}

Expand Down Expand Up @@ -575,6 +578,7 @@ static int oqsx_gen_set_params(void *genctx, const OSSL_PARAM params[])
if (gctx->propq == NULL)
return 0;
}
// not passing in params is no error; subsequent operations may fail, though
return 1;
}

Expand Down
3 changes: 2 additions & 1 deletion oqsprov/oqs_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ static int oqs_sig_set_ctx_params(void *vpoqs_sigctx, const OSSL_PARAM params[])
return 0;
}

return 1;
// not passing in parameters we can act on is no error
return 1;
}

static const OSSL_PARAM known_settable_ctx_params[]
Expand Down
1 change: 1 addition & 0 deletions oqsprov/oqsprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ static int oqsprovider_get_params(void *provctx, OSSL_PARAM params[])
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS);
if (p != NULL && !OSSL_PARAM_set_int(p, 1)) // provider is always running
return 0;
// not passing in params to respond to is no error; response is empty then
return 1;
}

Expand Down
47 changes: 22 additions & 25 deletions oqsprov/oqsprov_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,52 +1479,49 @@ int oqsx_key_allocate_keymaterial(OQSX_KEY *key, int include_private)
int oqsx_key_fromdata(OQSX_KEY *key, const OSSL_PARAM params[],
int include_private)
{
const OSSL_PARAM *p;
const OSSL_PARAM *pp1, *pp2;

OQS_KEY_PRINTF("OQSX Key from data called\n");
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
if (p != NULL)
{
if (p->data_type != OSSL_PARAM_OCTET_STRING)
{
pp1 = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
pp2 = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY);
// at least one parameter must be given
if (pp1 == NULL && pp2 == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
}
if (pp1 != NULL) {
if (pp1->data_type != OSSL_PARAM_OCTET_STRING) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING);
return 0;
}
if (key->privkeylen != p->data_size)
{
if (key->privkeylen != pp1->data_size) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_SIZE);
return 0;
}
OPENSSL_secure_clear_free(key->privkey, p->data_size);
key->privkey = OPENSSL_secure_malloc(p->data_size);
if (key->privkey == NULL)
{
OPENSSL_secure_clear_free(key->privkey, pp1->data_size);
key->privkey = OPENSSL_secure_malloc(pp1->data_size);
if (key->privkey == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
return 0;
}
memcpy(key->privkey, p->data, p->data_size);
memcpy(key->privkey, pp1->data, pp1->data_size);
}
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY);
if (p != NULL)
{
if (p->data_type != OSSL_PARAM_OCTET_STRING)
{
if (pp2 != NULL) {
if (pp2->data_type != OSSL_PARAM_OCTET_STRING) {
OQS_KEY_PRINTF("invalid data type\n");
return 0;
}
if (key->pubkeylen != p->data_size)
{
if (key->pubkeylen != pp2->data_size) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_SIZE);
return 0;
}
OPENSSL_secure_clear_free(key->pubkey, p->data_size);
key->pubkey = OPENSSL_secure_malloc(p->data_size);
if (key->pubkey == NULL)
{
OPENSSL_secure_clear_free(key->pubkey, pp2->data_size);
key->pubkey = OPENSSL_secure_malloc(pp2->data_size);
if (key->pubkey == NULL) {
ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE);
return 0;
}
memcpy(key->pubkey, p->data, p->data_size);
memcpy(key->pubkey, pp2->data, pp2->data_size);
}
if (!oqsx_key_set_composites(key)
|| !oqsx_key_recreate_classickey(
Expand Down

0 comments on commit 4df9d0e

Please sign in to comment.