CJOSE
0.6.0
|
Functions and data structures for interacting with JSON Web Signature (JWS) objects. More...
Go to the source code of this file.
Typedefs | |
typedef struct _cjose_jws_int | cjose_jws_t |
Functions | |
cjose_jws_t * | cjose_jws_sign (const cjose_jwk_t *jwk, cjose_header_t *protected_header, const uint8_t *plaintext, size_t plaintext_len, cjose_err *err) |
bool | cjose_jws_export (cjose_jws_t *jws, const char **ser, cjose_err *err) |
cjose_jws_t * | cjose_jws_import (const char *compact, size_t compact_len, cjose_err *err) |
bool | cjose_jws_verify (cjose_jws_t *jws, const cjose_jwk_t *jwk, cjose_err *err) |
bool | cjose_jws_get_plaintext (const cjose_jws_t *jws, uint8_t **plaintext, size_t *plaintext_len, cjose_err *err) |
cjose_header_t * | cjose_jws_get_protected (cjose_jws_t *jws) |
void | cjose_jws_release (cjose_jws_t *jws) |
Functions and data structures for interacting with JSON Web Signature (JWS) objects.
typedef struct _cjose_jws_int cjose_jws_t |
An instance of a JWS object.
bool cjose_jws_export | ( | cjose_jws_t * | jws, |
const char ** | ser, | ||
cjose_err * | err | ||
) |
Creates a serialization of the given JWS object.
Note the current implementation only supports serialization to the JWS compact format.
jws | [in] the JWS object to be serialized. |
ser | [out] pointer to a compact serialization of this JWS. Note the returned string pointer is owned by the JWS, the caller should not attempt to free it directly, and note that it will be freed automatically when the JWS itself is released. |
err | [out] An optional error object which can be used to get additional information in the event of an error. |
bool cjose_jws_get_plaintext | ( | const cjose_jws_t * | jws, |
uint8_t ** | plaintext, | ||
size_t * | plaintext_len, | ||
cjose_err * | err | ||
) |
Returns the plaintext data of the JWS payload.
jws | [in] the JWS object for which the plaintext is requested. |
plaintext | [out] pointer to the plaintext of this JWS. Note the returned buffer is owned by the JWS, the caller should not attempt to free it directly, and note that it will be freed automatically when the JWS itself is released. |
plaintext_len | [out] number of bytes of plaintext in the returned plaintext buffer. |
err | [out] An optional error object which can be used to get additional information in the event of an error. |
cjose_header_t* cjose_jws_get_protected | ( | cjose_jws_t * | jws | ) |
Returns the protected header of the JWS payload.
NOTE: The returned header is still owned by the JWS object. Users must call cjose_header_retain()
if it is expected to be valid after the owning cjose_jws_t
is released.
jws | [in] the JWS object for which the protected header is requested. |
cjose_jws_t* cjose_jws_import | ( | const char * | compact, |
size_t | compact_len, | ||
cjose_err * | err | ||
) |
Creates a new JWS object from the given JWS compact serialization.
Note the current implementation only recognizes the JWS compact serialization format.
compact | [in] a JWS in serialized form. |
compact_len | [in] the length of the compact serialization. |
err | [out] An optional error object which can be used to get additional information in the event of an error. |
void cjose_jws_release | ( | cjose_jws_t * | jws | ) |
Releases the given JWS object.
jws | the JWS to be released. If null, this is a no-op. |
cjose_jws_t* cjose_jws_sign | ( | const cjose_jwk_t * | jwk, |
cjose_header_t * | protected_header, | ||
const uint8_t * | plaintext, | ||
size_t | plaintext_len, | ||
cjose_err * | err | ||
) |
Creates a new JWS by signing the given plaintext within the given header and JWK.
jwk | [in] the key to use for signing the JWS. |
protected_header | [in] header values to include in the JWS header. |
plaintext | [in] the plaintext to be signed as the JWS payload. |
plaintext_len | [in] the length of the plaintext. |
err | [out] An optional error object which can be used to get additional information in the event of an error. |
bool cjose_jws_verify | ( | cjose_jws_t * | jws, |
const cjose_jwk_t * | jwk, | ||
cjose_err * | err | ||
) |
Verifies the JWS object using the given JWK.
jws | [in] the JWS object to verify. |
jwk | [in] the key to use for verification. |
err | [out] An optional error object which can be used to get additional information in the event of an error. |