diff --git a/src/thirdparty/jwt/CMakeLists.txt b/src/thirdparty/jwt/CMakeLists.txt index ea61d451..3f257f5c 100644 --- a/src/thirdparty/jwt/CMakeLists.txt +++ b/src/thirdparty/jwt/CMakeLists.txt @@ -4,12 +4,12 @@ add_module( "lib" "libjwt" "" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() add_sources( SOURCE_GROUP "Source" - "base64.cpp" - "claim.cpp" - "decode.cpp" - "encode.cpp" - "util.cpp" - "version.cpp" + "base64.c" + "claim.c" + "decode.c" + "encode.c" + "util.c" + "version.c" ) add_sources( SOURCE_GROUP "Include" diff --git a/src/thirdparty/jwt/base64.cpp b/src/thirdparty/jwt/base64.c similarity index 100% rename from src/thirdparty/jwt/base64.cpp rename to src/thirdparty/jwt/base64.c diff --git a/src/thirdparty/jwt/claim.cpp b/src/thirdparty/jwt/claim.c similarity index 97% rename from src/thirdparty/jwt/claim.cpp rename to src/thirdparty/jwt/claim.c index a8edab49..8918f0bc 100644 --- a/src/thirdparty/jwt/claim.cpp +++ b/src/thirdparty/jwt/claim.c @@ -14,9 +14,9 @@ limitations under the License. */ -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "include/claim.h" #include "include/version.h" @@ -24,13 +24,7 @@ #include "include/chillbuff.h" #include -#ifdef __cplusplus -extern "C" { -#endif #include -#ifdef __cplusplus -} -#endif void l8w8jwt_free_claims(struct l8w8jwt_claim* claims, const size_t claims_count) { @@ -147,6 +141,6 @@ struct l8w8jwt_claim* l8w8jwt_get_claim(struct l8w8jwt_claim* claims, const size return NULL; } -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/thirdparty/jwt/decode.cpp b/src/thirdparty/jwt/decode.c similarity index 94% rename from src/thirdparty/jwt/decode.cpp rename to src/thirdparty/jwt/decode.c index e1c68542..121a2cab 100644 --- a/src/thirdparty/jwt/decode.cpp +++ b/src/thirdparty/jwt/decode.c @@ -14,9 +14,9 @@ limitations under the License. */ -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #define JSMN_STATIC @@ -30,9 +30,6 @@ #include #include -//#ifdef __cplusplus -//extern "C" { -//#endif #include #include #include @@ -40,9 +37,6 @@ #include #include #include -//#ifdef __cplusplus -//} -//#endif #if L8W8JWT_ENABLE_EDDSA #include @@ -335,7 +329,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati return L8W8JWT_NULL_ARG; } - *out_validation_result = (l8w8jwt_validation_result)~L8W8JWT_VALID; + *out_validation_result = (enum l8w8jwt_validation_result)~L8W8JWT_VALID; char* header = NULL; size_t header_length = 0; @@ -661,7 +655,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_sub != NULL) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "sub", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "sub", 3); if (c == NULL || strncmp(c->value, params->validate_sub, params->validate_sub_length ? params->validate_sub_length : strlen(params->validate_sub)) != 0) { validation_res |= (unsigned)L8W8JWT_SUB_FAILURE; @@ -670,7 +664,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_aud != NULL) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "aud", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "aud", 3); if (c == NULL || strncmp(c->value, params->validate_aud, params->validate_aud_length ? params->validate_aud_length : strlen(params->validate_aud)) != 0) { validation_res |= (unsigned)L8W8JWT_AUD_FAILURE; @@ -679,7 +673,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_iss != NULL) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "iss", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "iss", 3); if (c == NULL || strncmp(c->value, params->validate_iss, params->validate_iss_length ? params->validate_iss_length : strlen(params->validate_iss)) != 0) { validation_res |= (unsigned)L8W8JWT_ISS_FAILURE; @@ -688,7 +682,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_jti != NULL) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "jti", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "jti", 3); if (c == NULL || strncmp(c->value, params->validate_jti, params->validate_jti_length ? params->validate_jti_length : strlen(params->validate_jti)) != 0) { validation_res |= (unsigned)L8W8JWT_JTI_FAILURE; @@ -699,7 +693,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_exp) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "exp", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "exp", 3); if (c == NULL || ct - params->exp_tolerance_seconds > strtoll(c->value, NULL, 10)) { validation_res |= (unsigned)L8W8JWT_EXP_FAILURE; @@ -708,7 +702,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_nbf) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "nbf", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "nbf", 3); if (c == NULL || ct + params->nbf_tolerance_seconds < strtoll(c->value, NULL, 10)) { validation_res |= (unsigned)L8W8JWT_NBF_FAILURE; @@ -717,7 +711,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_iat) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "iat", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "iat", 3); if (c == NULL || ct + params->iat_tolerance_seconds < strtoll(c->value, NULL, 10)) { validation_res |= (unsigned)L8W8JWT_IAT_FAILURE; @@ -726,7 +720,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati if (params->validate_typ) { - struct l8w8jwt_claim* c = l8w8jwt_get_claim((l8w8jwt_claim*)claims.array, claims.length, "typ", 3); + struct l8w8jwt_claim* c = l8w8jwt_get_claim((struct l8w8jwt_claim*)claims.array, claims.length, "typ", 3); if (c == NULL || l8w8jwt_strncmpic(c->value, params->validate_typ, params->validate_typ_length) != 0) { validation_res |= (unsigned)L8W8JWT_TYP_FAILURE; @@ -734,7 +728,7 @@ int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validati } r = L8W8JWT_SUCCESS; - *out_validation_result = (l8w8jwt_validation_result)validation_res; + *out_validation_result = (enum l8w8jwt_validation_result)validation_res; if (out_claims != NULL && out_claims_length != NULL) { @@ -774,6 +768,6 @@ exit: #undef JSMN_STATIC -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/thirdparty/jwt/encode.cpp b/src/thirdparty/jwt/encode.c similarity index 99% rename from src/thirdparty/jwt/encode.cpp rename to src/thirdparty/jwt/encode.c index d3caca39..8abc0962 100644 --- a/src/thirdparty/jwt/encode.cpp +++ b/src/thirdparty/jwt/encode.c @@ -14,9 +14,9 @@ limitations under the License. */ -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "include/util.h" #include "include/encode.h" @@ -683,6 +683,6 @@ exit: return r; } -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/src/thirdparty/jwt/include/base64.h b/src/thirdparty/jwt/include/base64.h index f6211f60..f3124fc8 100644 --- a/src/thirdparty/jwt/include/base64.h +++ b/src/thirdparty/jwt/include/base64.h @@ -26,9 +26,9 @@ #ifndef L8W8JWT_BASE64_H #define L8W8JWT_BASE64_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "version.h" #include @@ -70,8 +70,8 @@ L8W8JWT_API int l8w8jwt_base64_encode(int url, const uint8_t* data, size_t data_ */ L8W8JWT_API int l8w8jwt_base64_decode(int url, const char* data, size_t data_length, uint8_t** out, size_t* out_length); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_BASE64_H diff --git a/src/thirdparty/jwt/include/claim.h b/src/thirdparty/jwt/include/claim.h index a6cc1aa8..0b55acad 100644 --- a/src/thirdparty/jwt/include/claim.h +++ b/src/thirdparty/jwt/include/claim.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_CLAIM_H #define L8W8JWT_CLAIM_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "version.h" #include @@ -139,8 +139,8 @@ L8W8JWT_API int l8w8jwt_write_claims(struct chillbuff* stringbuilder, struct l8w */ L8W8JWT_API struct l8w8jwt_claim* l8w8jwt_get_claim(struct l8w8jwt_claim* claims, size_t claims_count, const char* key, size_t key_length); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_CLAIM_H diff --git a/src/thirdparty/jwt/include/decode.h b/src/thirdparty/jwt/include/decode.h index 42ee2a78..a8a31cb4 100644 --- a/src/thirdparty/jwt/include/decode.h +++ b/src/thirdparty/jwt/include/decode.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_DECODE_H #define L8W8JWT_DECODE_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "algs.h" #include "claim.h" @@ -267,8 +267,8 @@ L8W8JWT_API int l8w8jwt_validate_decoding_params(struct l8w8jwt_decoding_params* */ L8W8JWT_API int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validation_result* out_validation_result, struct l8w8jwt_claim** out_claims, size_t* out_claims_length); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_DECODE_H diff --git a/src/thirdparty/jwt/include/encode.h b/src/thirdparty/jwt/include/encode.h index 963b0f1c..a1b8e1c9 100644 --- a/src/thirdparty/jwt/include/encode.h +++ b/src/thirdparty/jwt/include/encode.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_ENCODE_H #define L8W8JWT_ENCODE_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include "algs.h" #include "claim.h" @@ -199,8 +199,8 @@ L8W8JWT_API int l8w8jwt_validate_encoding_params(struct l8w8jwt_encoding_params* */ L8W8JWT_API int l8w8jwt_encode(struct l8w8jwt_encoding_params* params); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_ENCODE_H diff --git a/src/thirdparty/jwt/include/retcodes.h b/src/thirdparty/jwt/include/retcodes.h index 653e5303..fe3bef71 100644 --- a/src/thirdparty/jwt/include/retcodes.h +++ b/src/thirdparty/jwt/include/retcodes.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_RETCODES_H #define L8W8JWT_RETCODES_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif /** * Returned from a l8w8jwt function when everything went smooth 'n' chill. Time to get Schwifty, Morteyy! @@ -100,8 +100,8 @@ */ #define L8W8JWT_UNSUPPORTED_ALG 800 -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_RETCODES_H diff --git a/src/thirdparty/jwt/include/util.h b/src/thirdparty/jwt/include/util.h index 9df8f292..7bd4d479 100644 --- a/src/thirdparty/jwt/include/util.h +++ b/src/thirdparty/jwt/include/util.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_UTIL_H #define L8W8JWT_UTIL_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif #include #include "version.h" @@ -51,8 +51,8 @@ L8W8JWT_API int l8w8jwt_hexstr2bin(const char* hexstr, size_t hexstr_length, uns */ L8W8JWT_API int l8w8jwt_strncmpic(const char* str1, const char* str2, size_t n); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_UTIL_H \ No newline at end of file diff --git a/src/thirdparty/jwt/include/version.h b/src/thirdparty/jwt/include/version.h index 4f196d2c..9fce28a0 100644 --- a/src/thirdparty/jwt/include/version.h +++ b/src/thirdparty/jwt/include/version.h @@ -23,9 +23,9 @@ #ifndef L8W8JWT_VERSION_H #define L8W8JWT_VERSION_H -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif /** * Current l8w8jwt version number. @@ -80,8 +80,8 @@ L8W8JWT_API int l8w8jwt_get_version_number(void); */ L8W8JWT_API void l8w8jwt_get_version_string(char out[32]); -//#ifdef __cplusplus -//} // extern "C" -//#endif +#ifdef __cplusplus +} // extern "C" +#endif #endif // L8W8JWT_VERSION_H diff --git a/src/thirdparty/jwt/util.cpp b/src/thirdparty/jwt/util.c similarity index 95% rename from src/thirdparty/jwt/util.cpp rename to src/thirdparty/jwt/util.c index 2a827fcc..686659e9 100644 --- a/src/thirdparty/jwt/util.cpp +++ b/src/thirdparty/jwt/util.c @@ -17,9 +17,9 @@ #include "include/util.h" #include -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif int l8w8jwt_hexstr2bin(const char* hexstr, const size_t hexstr_length, unsigned char* output, const size_t output_size, size_t* output_length) { @@ -82,6 +82,6 @@ int l8w8jwt_strncmpic(const char* str1, const char* str2, size_t n) return ret; } -//#ifdef __cplusplus -//} // extern "C" -//#endif \ No newline at end of file +#ifdef __cplusplus +} // extern "C" +#endif \ No newline at end of file diff --git a/src/thirdparty/jwt/version.cpp b/src/thirdparty/jwt/version.c similarity index 95% rename from src/thirdparty/jwt/version.cpp rename to src/thirdparty/jwt/version.c index f8b94b82..62604c3a 100644 --- a/src/thirdparty/jwt/version.cpp +++ b/src/thirdparty/jwt/version.c @@ -22,9 +22,9 @@ #include #endif -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus +extern "C" { +#endif void l8w8jwt_free(void* mem) { @@ -70,6 +70,6 @@ void l8w8jwt_get_version_string(char out[32]) out[version_string_length] = '\0'; } -//#ifdef __cplusplus -//} // extern "C" -//#endif \ No newline at end of file +#ifdef __cplusplus +} // extern "C" +#endif \ No newline at end of file