Skip to content

Commit

Permalink
solve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Ventura <[email protected]>
  • Loading branch information
feventura committed Mar 17, 2024
1 parent a4c6846 commit d6eedfb
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 1,496 deletions.
55 changes: 0 additions & 55 deletions oqsprov/oqs_decode_der2key.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,10 @@ static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx)
* It takes the following arguments:
*
* oqskemhyb Possible prefix for OQS KEM hybrids; typically empty
* oqskemhyb Possible prefix for OQS KEM hybrids; typically empty
* keytype_name The implementation key type as a string.
* keytype The implementation key type. This must correspond exactly
* to our existing keymgmt keytype names... in other words,
* there must exist an oqs_##keytype##_keymgmt_functions.
* there must exist an oqs_##keytype##_keymgmt_functions.
* type The type name for the set of functions that implement the
* decoder for the key type. This isn't necessarily the same
* as keytype. For example, the key types ed25519, ed448,
Expand All @@ -508,34 +506,6 @@ static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx)
* structure.
*/
// reverted const to be able to change NID/evp_type after assignment
#define MAKE_DECODER(oqskemhyb, keytype_name, keytype, type, kind) \
static struct keytype_desc_st kind##_##keytype##_desc \
= {keytype_name, oqs##oqskemhyb##_##keytype##_keymgmt_functions, \
DO_##kind(keytype)}; \
\
static OSSL_FUNC_decoder_newctx_fn kind##_der2##keytype##_newctx; \
\
static void *kind##_der2##keytype##_newctx(void *provctx) \
{ \
OQS_DEC_PRINTF("OQS DEC provider: _newctx called.\n"); \
return der2key_newctx(provctx, &kind##_##keytype##_desc, \
keytype_name); \
} \
static int kind##_der2##keytype##_does_selection(void *provctx, \
int selection) \
{ \
OQS_DEC_PRINTF("OQS DEC provider: _does_selection called.\n"); \
return der2key_check_selection(selection, &kind##_##keytype##_desc); \
} \
const OSSL_DISPATCH oqs_##kind##_der_to_##keytype##_decoder_functions[] \
= {{OSSL_FUNC_DECODER_NEWCTX, \
(void (*)(void))kind##_der2##keytype##_newctx}, \
{OSSL_FUNC_DECODER_FREECTX, (void (*)(void))der2key_freectx}, \
{OSSL_FUNC_DECODER_DOES_SELECTION, \
(void (*)(void))kind##_der2##keytype##_does_selection}, \
{OSSL_FUNC_DECODER_DECODE, (void (*)(void))oqs_der2key_decode}, \
{OSSL_FUNC_DECODER_EXPORT_OBJECT, \
(void (*)(void))der2key_export_object}, \
#define MAKE_DECODER(oqskemhyb, keytype_name, keytype, type, kind) \
static struct keytype_desc_st kind##_##keytype##_desc \
= {keytype_name, oqs##oqskemhyb##_##keytype##_keymgmt_functions, \
Expand Down Expand Up @@ -798,77 +768,52 @@ MAKE_DECODER(, "p521_falcon1024", p521_falcon1024, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "falconpadded1024", falconpadded1024, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "falconpadded1024", falconpadded1024, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
oqsx, SubjectPublicKeyInfo);
///// OQS_TEMPLATE_FRAGMENT_DECODER_MAKE_END
50 changes: 0 additions & 50 deletions oqsprov/oqs_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ static int oqsx_match(const void *keydata1, const void *keydata2, int selection)
return 0;
}

if (key1 == NULL || key2 == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
}

#ifdef NOPUBKEY_IN_PRIVKEY
/* Now this is a "leap of faith" logic: If a public-only PKEY and a
* private-only PKEY are tested for equality we cannot do anything other
Expand All @@ -170,33 +165,28 @@ static int oqsx_match(const void *keydata1, const void *keydata2, int selection)
|| (key1->privkey != NULL && key2->privkey == NULL)
|| ((key1->tls_name != NULL && key2->tls_name != NULL)
&& strcmp(key1->tls_name, key2->tls_name))) {
&& strcmp(key1->tls_name, key2->tls_name))) {
ok = 0;
} else {
} else {
ok = ((key1->privkey == NULL && key2->privkey == NULL)
|| ((key1->privkey != NULL)
&& CRYPTO_memcmp(key1->privkey, key2->privkey,
key1->privkeylen)
== 0));
}
}
}

if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
if ((key1->pubkey == NULL && key2->pubkey != NULL)
|| (key1->pubkey != NULL && key2->pubkey == NULL)
|| ((key1->tls_name != NULL && key2->tls_name != NULL)
&& strcmp(key1->tls_name, key2->tls_name))) {
&& strcmp(key1->tls_name, key2->tls_name))) {
// special case now: If domain parameter matching requested,
// consider private key match sufficient:
ok = ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
&& (key1->privkey != NULL && key2->privkey != NULL)
&& (CRYPTO_memcmp(key1->privkey, key2->privkey,
key1->privkeylen)
== 0);
} else {
} else {
ok = ok
&& ((key1->pubkey == NULL && key2->pubkey == NULL)
Expand All @@ -205,7 +195,6 @@ static int oqsx_match(const void *keydata1, const void *keydata2, int selection)
key1->pubkeylen)
== 0));
}
}
}
if (!ok)
OQS_KM_PRINTF("OQSKEYMGMT: match failed!\n");
Expand Down Expand Up @@ -275,7 +264,6 @@ int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl,
}
}
// not passing in params to respond to is no error; the response is empty
// not passing in params to respond to is no error; the response is empty
ret = 1;
err:
return ret;
Expand All @@ -296,8 +284,6 @@ static int oqsx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
* In this implementation, only public and private keys can be exported,
* nothing else
*/
if (key == NULL || param_cb == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
if (key == NULL || param_cb == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
Expand Down Expand Up @@ -353,11 +339,6 @@ static int oqsx_get_params(void *key, OSSL_PARAM params[])
return 0;
}

if (oqsxk == NULL || params == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
}

OQS_KM_PRINTF2("OQSKEYMGMT: get_params called for %s\n", params[0].key);
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL
&& !OSSL_PARAM_set_int(p, oqsx_key_secbits(oqsxk)))
Expand Down Expand Up @@ -404,7 +385,6 @@ static int oqsx_get_params(void *key, OSSL_PARAM params[])
return 0;
}

// not passing in params to respond to is no error
// not passing in params to respond to is no error
return 1;
}
Expand Down Expand Up @@ -448,10 +428,6 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[])
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
}
if (oqsxkey == NULL) {
ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS);
return 0;
}
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY);
if (p != NULL) {
size_t used_len;
Expand Down Expand Up @@ -484,7 +460,6 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[])
}
}

// not passing in params to set is no error, just a no-op
// not passing in params to set is no error, just a no-op
return 1;
}
Expand Down Expand Up @@ -530,8 +505,6 @@ static void *oqsx_genkey(struct oqsx_gen_ctx *gctx)
return NULL;
OQS_KM_PRINTF3("OQSKEYMGMT: gen called for %s (%s)\n", gctx->oqs_name,
gctx->tls_name);
OQS_KM_PRINTF3("OQSKEYMGMT: gen called for %s (%s)\n", gctx->oqs_name,
gctx->tls_name);
if ((key = oqsx_key_new(gctx->libctx, gctx->oqs_name, gctx->tls_name,
gctx->primitive, gctx->propq, gctx->bit_security,
gctx->alg_idx))
Expand Down Expand Up @@ -618,7 +591,6 @@ static int oqsx_gen_set_params(void *genctx, const OSSL_PARAM params[])
return 0;
}
// not passing in params is no error; subsequent operations may fail, though
// not passing in params is no error; subsequent operations may fail, though
return 1;
}

Expand Down Expand Up @@ -1368,15 +1340,10 @@ MAKE_SIG_KEYMGMT_FUNCTIONS(rsa3072_falcon512)
MAKE_SIG_KEYMGMT_FUNCTIONS(falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(p256_falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(rsa3072_falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(p256_falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(rsa3072_falconpadded512)
MAKE_SIG_KEYMGMT_FUNCTIONS(falcon1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(p521_falcon1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(falconpadded1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(p521_falconpadded1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(falconpadded1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(p521_falconpadded1024)
MAKE_SIG_KEYMGMT_FUNCTIONS(sphincssha2128fsimple)
MAKE_SIG_KEYMGMT_FUNCTIONS(p256_sphincssha2128fsimple)
MAKE_SIG_KEYMGMT_FUNCTIONS(rsa3072_sphincssha2128fsimple)
Expand Down Expand Up @@ -1456,23 +1423,6 @@ MAKE_KEM_ECX_KEYMGMT_FUNCTIONS(x25519_mlkem768, OQS_KEM_alg_ml_kem_768, 128)
MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p256_mlkem768, OQS_KEM_alg_ml_kem_768, 128)
MAKE_KEM_KEYMGMT_FUNCTIONS(mlkem1024, OQS_KEM_alg_ml_kem_1024, 256)

MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p521_mlkem1024, OQS_KEM_alg_ml_kem_1024, 256)
MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p384_mlkem1024, OQS_KEM_alg_ml_kem_1024, 192)
MAKE_KEM_KEYMGMT_FUNCTIONS(mlkem512, OQS_KEM_alg_ml_kem_512, 128)

MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p256_mlkem512, OQS_KEM_alg_ml_kem_512, 128)

MAKE_KEM_ECX_KEYMGMT_FUNCTIONS(x25519_mlkem512, OQS_KEM_alg_ml_kem_512, 128)
MAKE_KEM_KEYMGMT_FUNCTIONS(mlkem768, OQS_KEM_alg_ml_kem_768, 192)

MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p384_mlkem768, OQS_KEM_alg_ml_kem_768, 192)

MAKE_KEM_ECX_KEYMGMT_FUNCTIONS(x448_mlkem768, OQS_KEM_alg_ml_kem_768, 192)

MAKE_KEM_ECX_KEYMGMT_FUNCTIONS(x25519_mlkem768, OQS_KEM_alg_ml_kem_768, 128)
MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p256_mlkem768, OQS_KEM_alg_ml_kem_768, 128)
MAKE_KEM_KEYMGMT_FUNCTIONS(mlkem1024, OQS_KEM_alg_ml_kem_1024, 256)

MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p521_mlkem1024, OQS_KEM_alg_ml_kem_1024, 256)
MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(p384_mlkem1024, OQS_KEM_alg_ml_kem_1024, 192)
MAKE_KEM_KEYMGMT_FUNCTIONS(bikel1, OQS_KEM_alg_bike_l1, 128)
Expand Down
Loading

0 comments on commit d6eedfb

Please sign in to comment.