Skip to content

Commit

Permalink
Merge pull request #7511 from julek-wolfssl/ec-meth
Browse files Browse the repository at this point in the history
Stub EC_KEY_METHOD
  • Loading branch information
dgarske authored May 13, 2024
2 parents 56129bd + d629152 commit 4eab526
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 1 deletion.
75 changes: 74 additions & 1 deletion src/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5607,7 +5607,7 @@ int wolfSSL_DSA_do_verify_ex(const unsigned char* digest, int digest_len,
}
#endif /* !HAVE_SELFTEST */

WOLFSSL_API int wolfSSL_i2d_DSAparams(const WOLFSSL_DSA* dsa,
int wolfSSL_i2d_DSAparams(const WOLFSSL_DSA* dsa,
unsigned char** out)
{
int ret = 0;
Expand Down Expand Up @@ -14037,6 +14037,79 @@ int wolfSSL_ECDH_compute_key(void *out, size_t outLen,

/* End ECDH */

#ifndef NO_WOLFSSL_STUB
const WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_OpenSSL(void)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_OpenSSL");

return NULL;
}

WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_METHOD_new(
const WOLFSSL_EC_KEY_METHOD *meth)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_METHOD_new");

(void)meth;

return NULL;
}

void wolfSSL_EC_KEY_METHOD_free(WOLFSSL_EC_KEY_METHOD *meth)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_METHOD_free");

(void)meth;
}

void wolfSSL_EC_KEY_METHOD_set_init(WOLFSSL_EC_KEY_METHOD *meth,
void* a1, void* a2, void* a3, void* a4, void* a5, void* a6)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_METHOD_set_init");

(void)meth;
(void)a1;
(void)a2;
(void)a3;
(void)a4;
(void)a5;
(void)a6;
}

void wolfSSL_EC_KEY_METHOD_set_sign(WOLFSSL_EC_KEY_METHOD *meth,
void* a1, void* a2, void* a3)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_METHOD_set_sign");

(void)meth;
(void)a1;
(void)a2;
(void)a3;
}

const WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_get_method(
const WOLFSSL_EC_KEY *key)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_get_method");

(void)key;

return NULL;
}

int wolfSSL_EC_KEY_set_method(WOLFSSL_EC_KEY *key,
const WOLFSSL_EC_KEY_METHOD *meth)
{
WOLFSSL_STUB("wolfSSL_EC_KEY_set_method");

(void)key;
(void)meth;

return 0;
}

#endif /* !NO_WOLFSSL_STUB */

#endif /* OPENSSL_EXTRA */

#endif /* HAVE_ECC */
Expand Down
30 changes: 30 additions & 0 deletions wolfssl/openssl/ec.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ struct WOLFSSL_EC_BUILTIN_CURVE {

typedef int point_conversion_form_t;

typedef struct WOLFSSL_EC_KEY_METHOD {
/* Not implemented */
/* Just here so that some C compilers don't complain. To be removed. */
void* dummy_member;
} WOLFSSL_EC_KEY_METHOD;

WOLFSSL_API
size_t wolfSSL_EC_get_builtin_curves(WOLFSSL_EC_BUILTIN_CURVE *r,size_t nitems);

Expand Down Expand Up @@ -313,13 +319,29 @@ char* wolfSSL_EC_POINT_point2hex(const WOLFSSL_EC_GROUP* group,
WOLFSSL_BN_CTX* ctx);
#endif

WOLFSSL_API const WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_OpenSSL(void);
WOLFSSL_API WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_METHOD_new(
const WOLFSSL_EC_KEY_METHOD *meth);
WOLFSSL_API void wolfSSL_EC_KEY_METHOD_free(WOLFSSL_EC_KEY_METHOD *meth);
/* TODO when implementing change the types to the real callback signatures
* and use real parameter names */
WOLFSSL_API void wolfSSL_EC_KEY_METHOD_set_init(WOLFSSL_EC_KEY_METHOD *meth,
void* a1, void* a2, void* a3, void* a4, void* a5, void* a6);
WOLFSSL_API void wolfSSL_EC_KEY_METHOD_set_sign(WOLFSSL_EC_KEY_METHOD *meth,
void* a1, void* a2, void* a3);
WOLFSSL_API const WOLFSSL_EC_KEY_METHOD *wolfSSL_EC_KEY_get_method(
const WOLFSSL_EC_KEY *key);
WOLFSSL_API int wolfSSL_EC_KEY_set_method(WOLFSSL_EC_KEY *key,
const WOLFSSL_EC_KEY_METHOD *meth);

#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)

typedef WOLFSSL_EC_KEY EC_KEY;
typedef WOLFSSL_EC_GROUP EC_GROUP;
typedef WOLFSSL_EC_GROUP EC_METHOD;
typedef WOLFSSL_EC_POINT EC_POINT;
typedef WOLFSSL_EC_BUILTIN_CURVE EC_builtin_curve;
typedef WOLFSSL_EC_KEY_METHOD EC_KEY_METHOD;

#ifndef HAVE_ECC
#define OPENSSL_NO_EC
Expand Down Expand Up @@ -405,6 +427,14 @@ typedef WOLFSSL_EC_BUILTIN_CURVE EC_builtin_curve;
#define EC_curve_nid2nist wolfSSL_EC_curve_nid2nist
#define EC_curve_nist2nid wolfSSL_EC_curve_nist2nid

#define EC_KEY_OpenSSL wolfSSL_EC_KEY_OpenSSL
#define EC_KEY_METHOD_new wolfSSL_EC_KEY_METHOD_new
#define EC_KEY_METHOD_free wolfSSL_EC_KEY_METHOD_free
#define EC_KEY_METHOD_set_init wolfSSL_EC_KEY_METHOD_set_init
#define EC_KEY_METHOD_set_sign wolfSSL_EC_KEY_METHOD_set_sign
#define EC_KEY_get_method wolfSSL_EC_KEY_get_method
#define EC_KEY_set_method wolfSSL_EC_KEY_set_method

#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */

#ifdef __cplusplus
Expand Down

0 comments on commit 4eab526

Please sign in to comment.