Skip to content

Commit

Permalink
jwt: remove jwt_payload_len function
Browse files Browse the repository at this point in the history
The function jwt_payload_len doesn't return payload length but returns
used data in builder->buf

If jwt_payload_len is called after jwt_init_builder, header length will
be returned
If jwt_payload_len is called after jwt_add_payload, header+payload
length will be returned
If jwt_payload_len is called after jwt_sign, header+payload+sign length
will be returned

So, this commit removes the function and uses strlen instead

Signed-off-by: Benjamin Lemouzy <blemouzy@centralp.fr>
  • Loading branch information
blemouzy authored and nashif committed Oct 8, 2024
1 parent 64ecbea commit 9f60075
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions include/zephyr/data/jwt.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ int jwt_sign(struct jwt_builder *builder,
const char *der_key,
size_t der_key_len);


static inline size_t jwt_payload_len(struct jwt_builder *builder)
{
return (builder->buf - builder->base);
}

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/jwt/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ZTEST(jwt_tests, test_jwt)
zassert_equal(build.overflowed, false, "Not overflow");

printk("JWT:\n%s\n", buf);
printk("len: %zd\n", jwt_payload_len(&build));
printk("len: %zd\n", strlen(buf));
}

ZTEST_SUITE(jwt_tests, NULL, NULL, NULL, NULL, NULL);

0 comments on commit 9f60075

Please sign in to comment.