Skip to content

Commit

Permalink
Hide symbols that aren't meant to be exported
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Collins <[email protected]>
  • Loading branch information
benmcollins committed Jan 2, 2025
1 parent 1815329 commit 39b7910
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libjwt/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* out is null-terminated encode string.
* return values is out length, exclusive terminating `\0'
*/
unsigned int
JWT_NO_EXPORT unsigned int
base64_encode(const unsigned char *in, unsigned int inlen, char *out);

/*
* return values is out length
*/
unsigned int
JWT_NO_EXPORT unsigned int
base64_decode(const char *in, unsigned int inlen, unsigned char *out);

#endif /* BASE64_H */
4 changes: 4 additions & 0 deletions libjwt/gnutls/jwk-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@

static const char not_implemented[] = "GnuTLS does not yet implement JWK";

JWT_NO_EXPORT
int gnutls_process_eddsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int gnutls_process_rsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int gnutls_process_ec(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
void gnutls_process_item_free(jwk_item_t *item)
{
return;
Expand Down
1 change: 1 addition & 0 deletions libjwt/jwt-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# endif
#endif

JWT_NO_EXPORT
extern struct jwt_crypto_ops *jwt_ops;

#define jwks_write_error(__obj, __fmt, __args...) \
Expand Down
4 changes: 4 additions & 0 deletions libjwt/mbedtls/jwk-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,28 @@

static const char not_implemented[] = "MBedTLS does not yet implement JWK";

JWT_NO_EXPORT
int mbedtls_process_eddsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int mbedtls_process_rsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int mbedtls_process_ec(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
void mbedtls_process_item_free(jwk_item_t *item)
{
return;
Expand Down
13 changes: 11 additions & 2 deletions libjwt/openssl/jwk-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ static int pctx_to_pem(EVP_PKEY_CTX *pctx, OSSL_PARAM *params,
}

/* For EdDSA keys (EDDSA) */
JWT_NO_EXPORT
int openssl_process_eddsa(json_t *jwk, jwk_item_t *item)
{
unsigned char *pub_bin = NULL, *priv_bin = NULL;
Expand All @@ -214,13 +215,14 @@ int openssl_process_eddsa(json_t *jwk, jwk_item_t *item)
d = json_object_get(jwk, "d");

if (x == NULL && d == NULL) {
jwks_write_error(item, "Need an 'x' or 'd' component and found neither");
jwks_write_error(item,
"Need an 'x' or 'd' component and found neither");
goto cleanup_eddsa;
}

if (d != NULL)
item->is_private_key = priv = 1;

pctx = EVP_PKEY_CTX_new_from_name(NULL, "ED25519", NULL);
if (pctx == NULL) {
jwks_write_error(item, "Error creating pkey context");
Expand Down Expand Up @@ -273,6 +275,7 @@ int openssl_process_eddsa(json_t *jwk, jwk_item_t *item)

/* For RSA keys (RS256, RS384, RS512). Also works for RSA-PSS
* (PS256, PS384, PS512) */
JWT_NO_EXPORT
int openssl_process_rsa(json_t *jwk, jwk_item_t *item)
{
OSSL_PARAM_BLD *build = NULL;
Expand Down Expand Up @@ -385,6 +388,7 @@ int openssl_process_rsa(json_t *jwk, jwk_item_t *item)
}

/* For EC Keys (ES256, ES384, ES512) */
JWT_NO_EXPORT
int openssl_process_ec(json_t *jwk, jwk_item_t *item)
{
OSSL_PARAM *params = NULL;
Expand Down Expand Up @@ -468,6 +472,7 @@ int openssl_process_ec(json_t *jwk, jwk_item_t *item)
return ret;
}

JWT_NO_EXPORT
void openssl_process_item_free(jwk_item_t *item)
{
if (item == NULL || item->provider != JWT_CRYPTO_OPS_OPENSSL)
Expand All @@ -485,24 +490,28 @@ void openssl_process_item_free(jwk_item_t *item)

static const char not_implemented[] = "OpenSSL Support for JWK requires 3.0 or higher";

JWT_NO_EXPORT
int openssl_process_eddsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int openssl_process_rsa(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
int openssl_process_ec(json_t *jwk, jwk_item_t *item)
{
jwks_write_error(item, not_implemented);
return -1;
}

JWT_NO_EXPORT
void openssl_process_item_free(jwk_item_t *item)
{
return;
Expand Down

0 comments on commit 39b7910

Please sign in to comment.