![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
struct | lws_jwk |
Functions | |
LWS_VISIBLE LWS_EXTERN int | lws_jwk_import (struct lws_jwk *s, const char *in, size_t len) |
LWS_VISIBLE LWS_EXTERN void | lws_jwk_destroy (struct lws_jwk *s) |
LWS_VISIBLE LWS_EXTERN int | lws_jwk_export (struct lws_jwk *s, int _private, char *p, size_t len) |
LWS_VISIBLE int | lws_jwk_load (struct lws_jwk *s, const char *filename) |
LWS_VISIBLE int | lws_jwk_save (struct lws_jwk *s, const char *filename) |
LWS_VISIBLE int | lws_jwk_rfc7638_fingerprint (struct lws_jwk *s, char *digest32) |
Lws provides an API to parse JSON Web Keys into a struct lws_genrsa_elements.
"oct" and "RSA" type keys are supported. For "oct" keys, they are held in the "e" member of the struct lws_genrsa_elements.
Keys elements are allocated on the heap. You must destroy the allocations in the struct lws_genrsa_elements by calling lws_jwk_destroy_genrsa_elements() when you are finished with it.
LWS_VISIBLE LWS_EXTERN void lws_jwk_destroy | ( | struct lws_jwk * | s | ) |
#include <lib/libwebsockets.h>
lws_jwk_destroy() - Destroy a JSON Web key
s | the JWK object to destroy |
All allocations in the lws_jwk are destroyed
LWS_VISIBLE LWS_EXTERN int lws_jwk_export | ( | struct lws_jwk * | s, |
int | _private, | ||
char * | p, | ||
size_t | len | ||
) |
#include <lib/libwebsockets.h>
lws_jwk_export() - Export a JSON Web key to a textual representation
s | the JWK object to export |
_private | 0 = just export public parts, 1 = export everything |
p | the buffer to write the exported JWK to |
len | the length of the buffer p in bytes |
Returns length of the used part of the buffer if OK, or -1 for error.
Serializes the content of the JWK into a char buffer.
LWS_VISIBLE LWS_EXTERN int lws_jwk_import | ( | struct lws_jwk * | s, |
const char * | in, | ||
size_t | len | ||
) |
#include <lib/libwebsockets.h>
lws_jwk_import() - Create a JSON Web key from the textual representation
s | the JWK object to create |
in | a single JWK JSON stanza in utf-8 |
len | the length of the JWK JSON stanza in bytes |
Creates an lws_jwk struct filled with data from the JSON representation. "oct" and "rsa" key types are supported.
For "oct" type keys, it is loaded into el.e.
LWS_VISIBLE int lws_jwk_load | ( | struct lws_jwk * | s, |
const char * | filename | ||
) |
#include <lib/libwebsockets.h>
lws_jwk_load() - Import a JSON Web key from a file
s | the JWK object to load into |
filename | filename to load from |
Returns 0 for OK or -1 for failure
LWS_VISIBLE int lws_jwk_rfc7638_fingerprint | ( | struct lws_jwk * | s, |
char * | digest32 | ||
) |
#include <lib/libwebsockets.h>
lws_jwk_rfc7638_fingerprint() - jwk to RFC7638 compliant fingerprint
s | the JWK object to fingerprint |
digest32 | buffer to take 32-byte digest |
Returns 0 for OK or -1 for failure
LWS_VISIBLE int lws_jwk_save | ( | struct lws_jwk * | s, |
const char * | filename | ||
) |
#include <lib/libwebsockets.h>
lws_jwk_save() - Export a JSON Web key to a file
s | the JWK object to save from |
filename | filename to save to |
Returns 0 for OK or -1 for failure