diff --git a/include/zephyr/data/jwt.h b/include/zephyr/data/jwt.h index e502b9321ddac6..d8bd91ad01ef9c 100644 --- a/include/zephyr/data/jwt.h +++ b/include/zephyr/data/jwt.h @@ -119,7 +119,7 @@ int jwt_init_builder(struct jwt_builder *builder, * @retval <0 Failure. */ int jwt_add_payload(struct jwt_builder *builder, - int32_t exp, + int32_t expt, int32_t iat, const char *aud); @@ -162,14 +162,14 @@ int jwt_init_parser(struct jwt_parser *parser, const char *token, char *buffer, * Parse JWT payload from a previously initialized parser. * * @param parser A previously initialized parser. - * @param exp A valid pointer to store Expiration Time value. + * @param expt A valid pointer to store Expiration Time value. * @param iat A valid pointer to store Issued At value. * @param aud A valid pointer to store Audience value. * * @retval 0 Success. * @retval <0 Failure. */ -int jwt_parse_payload(struct jwt_parser *parser, int32_t *exp, int32_t *iat, char *aud); +int jwt_parse_payload(struct jwt_parser *parser, int32_t *expt, int32_t *iat, char *aud); /** * @brief Verify JWT header and signature. diff --git a/subsys/jwt/jwt.c b/subsys/jwt/jwt.c index a588fed7bc1d13..477e6fda7e1edb 100644 --- a/subsys/jwt/jwt.c +++ b/subsys/jwt/jwt.c @@ -241,12 +241,12 @@ static int jwt_add_header(struct jwt_builder *builder) } int jwt_add_payload(struct jwt_builder *builder, - int32_t exp, + int32_t expt, int32_t iat, const char *aud) { struct jwt_payload payload = { - .exp = exp, + .exp = expt, .iat = iat, .aud = aud, }; @@ -292,7 +292,7 @@ int jwt_init_builder(struct jwt_builder *builder, return jwt_add_header(builder); } -int jwt_parse_payload(struct jwt_parser *parser, int32_t *exp, int32_t *iat, char *aud) +int jwt_parse_payload(struct jwt_parser *parser, int32_t *expt, int32_t *iat, char *aud) { struct jwt_payload payload; int res; @@ -305,7 +305,7 @@ int jwt_parse_payload(struct jwt_parser *parser, int32_t *exp, int32_t *iat, cha res = json_obj_parse(parser->buf, res, jwt_payload_desc, ARRAY_SIZE(jwt_payload_desc), &payload); if (res == (1 << ARRAY_SIZE(jwt_payload_desc)) - 1) { - *exp = payload.exp; + *expt = payload.exp; *iat = payload.iat; strcpy(aud, payload.aud); res = 0; diff --git a/tests/subsys/jwt/src/main.c b/tests/subsys/jwt/src/main.c index 6c1a29c1252d6f..369eb1d91d89d3 100644 --- a/tests/subsys/jwt/src/main.c +++ b/tests/subsys/jwt/src/main.c @@ -28,7 +28,7 @@ extern unsigned int jwt_test_private_der_len; ZTEST(jwt_tests, test_jwt) { - const int32_t exp = 1530312026; + const int32_t expt = 1530312026; const int32_t iat = 1530308426; static const char aud[] = "iot-work-199419"; /* @@ -39,7 +39,7 @@ ZTEST(jwt_tests, test_jwt) struct jwt_builder build; char jwt[460]; struct jwt_parser parse; - int32_t parsed_exp = 0; + int32_t parsed_expt = 0; int32_t parsed_iat = 0; char parsed_aud[32] = {0}; int res; @@ -47,7 +47,7 @@ ZTEST(jwt_tests, test_jwt) res = jwt_init_builder(&build, buf, sizeof(buf)); zassert_equal(res, 0, "Setting up jwt"); - res = jwt_add_payload(&build, exp, iat, aud); + res = jwt_add_payload(&build, expt, iat, aud); zassert_equal(res, 0, "Adding payload"); res = jwt_sign(&build, jwt_test_private_der, jwt_test_private_der_len); @@ -63,9 +63,9 @@ ZTEST(jwt_tests, test_jwt) res = jwt_init_parser(&parse, jwt, buf, sizeof(buf)); zassert_equal(res, 0, "Setting up jwt parsing"); - res = jwt_parse_payload(&parse, &parsed_exp, &parsed_iat, parsed_aud); + res = jwt_parse_payload(&parse, &parsed_expt, &parsed_iat, parsed_aud); zassert_equal(res, 0, "Parsing payload"); - zassert_equal(parsed_exp, exp, "Comparing expiration time"); + zassert_equal(parsed_expt, expt, "Comparing expiration time"); zassert_equal(parsed_iat, iat, "Comparing issued at"); zassert_mem_equal(parsed_aud, aud, sizeof(aud), "Comparing audience");