libwebsockets
Lightweight C library for HTML5 websockets
lws-jose.h File Reference

Go to the source code of this file.

Data Structures

struct  lws_jose_jwe_alg
 
struct  lws_jws_recpient
 
struct  lws_jose
 

Macros

#define LWS_JWS_MAX_RECIPIENTS   3
 

Enumerations

enum  lws_jws_jose_hdr_indexes {
  LJJHI_ALG , LJJHI_JKU , LJJHI_JWK , LJJHI_KID ,
  LJJHI_X5U , LJJHI_X5C , LJJHI_X5T , LJJHI_X5T_S256 ,
  LJJHI_TYP , LJJHI_CTY , LJJHI_CRIT , LJJHI_RECIPS_HDR ,
  LJJHI_RECIPS_HDR_ALG , LJJHI_RECIPS_HDR_KID , LJJHI_RECIPS_EKEY , LJJHI_ENC ,
  LJJHI_ZIP , LJJHI_EPK , LJJHI_APU , LJJHI_APV ,
  LJJHI_IV , LJJHI_TAG , LJJHI_P2S , LJJHI_P2C ,
  LWS_COUNT_JOSE_HDR_ELEMENTS
}
 
enum  lws_jose_algtype {
  LWS_JOSE_ENCTYPE_NONE , LWS_JOSE_ENCTYPE_RSASSA_PKCS1_1_5 , LWS_JOSE_ENCTYPE_RSASSA_PKCS1_OAEP , LWS_JOSE_ENCTYPE_RSASSA_PKCS1_PSS ,
  LWS_JOSE_ENCTYPE_ECDSA , LWS_JOSE_ENCTYPE_ECDHES , LWS_JOSE_ENCTYPE_AES_CBC , LWS_JOSE_ENCTYPE_AES_CFB128 ,
  LWS_JOSE_ENCTYPE_AES_CFB8 , LWS_JOSE_ENCTYPE_AES_CTR , LWS_JOSE_ENCTYPE_AES_ECB , LWS_JOSE_ENCTYPE_AES_OFB ,
  LWS_JOSE_ENCTYPE_AES_XTS , LWS_JOSE_ENCTYPE_AES_GCM
}
 

Functions

LWS_VISIBLE LWS_EXTERN void lws_jose_init (struct lws_jose *jose)
 
LWS_VISIBLE LWS_EXTERN void lws_jose_destroy (struct lws_jose *jose)
 
LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jws_alg_to_definition (const char *alg, const struct lws_jose_jwe_alg **jose)
 
LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jwe_alg_to_definition (const char *alg, const struct lws_jose_jwe_alg **jose)
 
LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jwe_enc_to_definition (const char *enc, const struct lws_jose_jwe_alg **jose)
 
LWS_VISIBLE LWS_EXTERN int lws_jws_parse_jose (struct lws_jose *jose, const char *buf, int len, char *temp, int *temp_len)
 
LWS_VISIBLE LWS_EXTERN int lws_jwe_parse_jose (struct lws_jose *jose, const char *buf, int len, char *temp, int *temp_len)
 

Data Structure Documentation

◆ lws_jose_jwe_alg

struct lws_jose_jwe_alg

Definition at line 80 of file lws-jose.h.

+ Collaboration diagram for lws_jose_jwe_alg:
Data Fields
enum lws_genhash_types hash_type
enum lws_genhmac_types hmac_type
enum lws_jose_algtype algtype_signing
enum lws_jose_algtype algtype_crypto
const char * alg
const char * curve_name
unsigned short keybits_min
unsigned short keybits_fixed
unsigned short ivbits

◆ lws_jws_recpient

struct lws_jws_recpient

Definition at line 106 of file lws-jose.h.

+ Collaboration diagram for lws_jws_recpient:
Data Fields
struct lws_gencrypto_keyelem unprot[LWS_COUNT_JOSE_HDR_ELEMENTS]
struct lws_jwk jwk_ephemeral
struct lws_jwk jwk

◆ lws_jose

struct lws_jose

Definition at line 116 of file lws-jose.h.

+ Collaboration diagram for lws_jose:
Data Fields
struct lws_gencrypto_keyelem e[LWS_COUNT_JOSE_HDR_ELEMENTS]
struct lws_jws_recpient recipient[LWS_JWS_MAX_RECIPIENTS]
char typ[32]
char edone[LWS_COUNT_JOSE_HDR_ELEMENTS]
const struct lws_jose_jwe_alg * alg
const struct lws_jose_jwe_alg * enc_alg
int recipients

Macro Definition Documentation

◆ LWS_JWS_MAX_RECIPIENTS

#define LWS_JWS_MAX_RECIPIENTS   3

Definition at line 104 of file lws-jose.h.

Enumeration Type Documentation

◆ lws_jws_jose_hdr_indexes

Enumerator
LJJHI_ALG 
LJJHI_JKU 
LJJHI_JWK 
LJJHI_KID 
LJJHI_X5U 
LJJHI_X5C 
LJJHI_X5T 
LJJHI_X5T_S256 
LJJHI_TYP 
LJJHI_CTY 
LJJHI_CRIT 
LJJHI_RECIPS_HDR 
LJJHI_RECIPS_HDR_ALG 
LJJHI_RECIPS_HDR_KID 
LJJHI_RECIPS_EKEY 
LJJHI_ENC 
LJJHI_ZIP 
LJJHI_EPK 
LJJHI_APU 
LJJHI_APV 
LJJHI_IV 
LJJHI_TAG 
LJJHI_P2S 
LJJHI_P2C 
LWS_COUNT_JOSE_HDR_ELEMENTS 

Definition at line 25 of file lws-jose.h.

25 {
26 LJJHI_ALG, /* REQUIRED */
27 LJJHI_JKU, /* Optional: string */
28 LJJHI_JWK, /* Optional: jwk JSON object: public key: */
29 LJJHI_KID, /* Optional: string */
30 LJJHI_X5U, /* Optional: string: url of public key cert / chain */
31 LJJHI_X5C, /* Optional: base64 (NOT -url): actual cert */
32 LJJHI_X5T, /* Optional: base64url: SHA-1 of actual cert */
33 LJJHI_X5T_S256, /* Optional: base64url: SHA-256 of actual cert */
34 LJJHI_TYP, /* Optional: string: media type */
35 LJJHI_CTY, /* Optional: string: content media type */
36 LJJHI_CRIT, /* Optional for send, REQUIRED: array of strings:
37 * mustn't contain standardized strings or null set */
38
43
44 LJJHI_ENC, /* JWE only: Optional: string */
45 LJJHI_ZIP, /* JWE only: Optional: string ("DEF" = deflate) */
46
47 LJJHI_EPK, /* Additional arg for JWE ECDH: ephemeral public key */
48 LJJHI_APU, /* Additional arg for JWE ECDH: base64url */
49 LJJHI_APV, /* Additional arg for JWE ECDH: base64url */
50 LJJHI_IV, /* Additional arg for JWE AES: base64url */
51 LJJHI_TAG, /* Additional arg for JWE AES: base64url */
52 LJJHI_P2S, /* Additional arg for JWE PBES2: base64url: salt */
53 LJJHI_P2C, /* Additional arg for JWE PBES2: integer: count */
54
56};
@ LJJHI_X5T
Definition: lws-jose.h:32
@ LJJHI_P2S
Definition: lws-jose.h:52
@ LJJHI_X5U
Definition: lws-jose.h:30
@ LJJHI_TAG
Definition: lws-jose.h:51
@ LWS_COUNT_JOSE_HDR_ELEMENTS
Definition: lws-jose.h:55
@ LJJHI_TYP
Definition: lws-jose.h:34
@ LJJHI_ZIP
Definition: lws-jose.h:45
@ LJJHI_RECIPS_HDR
Definition: lws-jose.h:39
@ LJJHI_CTY
Definition: lws-jose.h:35
@ LJJHI_JKU
Definition: lws-jose.h:27
@ LJJHI_P2C
Definition: lws-jose.h:53
@ LJJHI_RECIPS_HDR_ALG
Definition: lws-jose.h:40
@ LJJHI_APU
Definition: lws-jose.h:48
@ LJJHI_RECIPS_HDR_KID
Definition: lws-jose.h:41
@ LJJHI_APV
Definition: lws-jose.h:49
@ LJJHI_RECIPS_EKEY
Definition: lws-jose.h:42
@ LJJHI_ALG
Definition: lws-jose.h:26
@ LJJHI_KID
Definition: lws-jose.h:29
@ LJJHI_CRIT
Definition: lws-jose.h:36
@ LJJHI_X5C
Definition: lws-jose.h:31
@ LJJHI_X5T_S256
Definition: lws-jose.h:33
@ LJJHI_IV
Definition: lws-jose.h:50
@ LJJHI_EPK
Definition: lws-jose.h:47
@ LJJHI_JWK
Definition: lws-jose.h:28
@ LJJHI_ENC
Definition: lws-jose.h:44

◆ lws_jose_algtype

Enumerator
LWS_JOSE_ENCTYPE_NONE 
LWS_JOSE_ENCTYPE_RSASSA_PKCS1_1_5 
LWS_JOSE_ENCTYPE_RSASSA_PKCS1_OAEP 
LWS_JOSE_ENCTYPE_RSASSA_PKCS1_PSS 
LWS_JOSE_ENCTYPE_ECDSA 
LWS_JOSE_ENCTYPE_ECDHES 
LWS_JOSE_ENCTYPE_AES_CBC 
LWS_JOSE_ENCTYPE_AES_CFB128 
LWS_JOSE_ENCTYPE_AES_CFB8 
LWS_JOSE_ENCTYPE_AES_CTR 
LWS_JOSE_ENCTYPE_AES_ECB 
LWS_JOSE_ENCTYPE_AES_OFB 
LWS_JOSE_ENCTYPE_AES_XTS 
LWS_JOSE_ENCTYPE_AES_GCM 

Definition at line 58 of file lws-jose.h.

58 {
60
64
67
74 LWS_JOSE_ENCTYPE_AES_XTS, /* care: requires double-length key */
76};
@ LWS_JOSE_ENCTYPE_AES_CFB128
Definition: lws-jose.h:69
@ LWS_JOSE_ENCTYPE_AES_CTR
Definition: lws-jose.h:71
@ LWS_JOSE_ENCTYPE_AES_ECB
Definition: lws-jose.h:72
@ LWS_JOSE_ENCTYPE_AES_GCM
Definition: lws-jose.h:75
@ LWS_JOSE_ENCTYPE_AES_CFB8
Definition: lws-jose.h:70
@ LWS_JOSE_ENCTYPE_RSASSA_PKCS1_OAEP
Definition: lws-jose.h:62
@ LWS_JOSE_ENCTYPE_AES_OFB
Definition: lws-jose.h:73
@ LWS_JOSE_ENCTYPE_NONE
Definition: lws-jose.h:59
@ LWS_JOSE_ENCTYPE_AES_XTS
Definition: lws-jose.h:74
@ LWS_JOSE_ENCTYPE_ECDSA
Definition: lws-jose.h:65
@ LWS_JOSE_ENCTYPE_ECDHES
Definition: lws-jose.h:66
@ LWS_JOSE_ENCTYPE_RSASSA_PKCS1_PSS
Definition: lws-jose.h:63
@ LWS_JOSE_ENCTYPE_RSASSA_PKCS1_1_5
Definition: lws-jose.h:61
@ LWS_JOSE_ENCTYPE_AES_CBC
Definition: lws-jose.h:68

Function Documentation

◆ lws_jose_init()

LWS_VISIBLE LWS_EXTERN void lws_jose_init ( struct lws_jose jose)

lws_jose_init() - prepare a struct lws_jose for use

Parameters
josethe jose header struct to prepare

◆ lws_jose_destroy()

LWS_VISIBLE LWS_EXTERN void lws_jose_destroy ( struct lws_jose jose)

lws_jose_destroy() - retire a struct lws_jose from use

Parameters
josethe jose header struct to destroy

◆ lws_gencrypto_jws_alg_to_definition()

LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jws_alg_to_definition ( const char *  alg,
const struct lws_jose_jwe_alg **  jose 
)

lws_gencrypto_jws_alg_to_definition() - look up a jws alg name

Parameters
algthe jws alg name
josepointer to the pointer to the info struct to set on success

Returns 0 if *jose set, else nonzero for failure

◆ lws_gencrypto_jwe_alg_to_definition()

LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jwe_alg_to_definition ( const char *  alg,
const struct lws_jose_jwe_alg **  jose 
)

lws_gencrypto_jwe_alg_to_definition() - look up a jwe alg name

Parameters
algthe jwe alg name
josepointer to the pointer to the info struct to set on success

Returns 0 if *jose set, else nonzero for failure

◆ lws_gencrypto_jwe_enc_to_definition()

LWS_VISIBLE LWS_EXTERN int lws_gencrypto_jwe_enc_to_definition ( const char *  enc,
const struct lws_jose_jwe_alg **  jose 
)

lws_gencrypto_jwe_enc_to_definition() - look up a jwe enc name

Parameters
algthe jwe enc name
josepointer to the pointer to the info struct to set on success

Returns 0 if *jose set, else nonzero for failure

◆ lws_jws_parse_jose()

LWS_VISIBLE LWS_EXTERN int lws_jws_parse_jose ( struct lws_jose jose,
const char *  buf,
int  len,
char *  temp,
int *  temp_len 
)

lws_jws_parse_jose() - parse a JWS JOSE header

Parameters
josethe jose struct to set to parsing results
bufthe raw JOSE header
lenthe length of the raw JOSE header
tempparent-owned buffer to "allocate" elements into
temp_lenamount of space available in temp

returns 0 for success, or -1 for error *temp_len is updated to reflect the amount of temp used if successful.

◆ lws_jwe_parse_jose()

LWS_VISIBLE LWS_EXTERN int lws_jwe_parse_jose ( struct lws_jose jose,
const char *  buf,
int  len,
char *  temp,
int *  temp_len 
)

lws_jwe_parse_jose() - parse a JWE JOSE header

Parameters
josethe jose struct to set to parsing results
bufthe raw JOSE header
lenthe length of the raw JOSE header
tempparent-owned buffer to "allocate" elements into
temp_lenamount of space available in temp

returns 0 for success, or -1 for error *temp_len is updated to reflect the amount of temp used if successful.