libwebsockets
Lightweight C library for HTML5 websockets
lws-gencrypto.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lws_gencrypto_keyelem
 

Macros

#define LWS_GENCRYPTO_MAX_KEYEL_COUNT   LWS_GENCRYPTO_RSA_KEYEL_COUNT
 

Typedefs

typedef struct lws_gencrypto_keyelem lws_gc_elem_t
 

Enumerations

enum  lws_gencrypto_kty { LWS_GENCRYPTO_KTY_UNKNOWN , LWS_GENCRYPTO_KTY_OCT , LWS_GENCRYPTO_KTY_RSA , LWS_GENCRYPTO_KTY_EC }
 
enum  lws_gencrypto_oct_tok { LWS_GENCRYPTO_OCT_KEYEL_K , LWS_GENCRYPTO_OCT_KEYEL_COUNT }
 
enum  lws_gencrypto_rsa_tok {
  LWS_GENCRYPTO_RSA_KEYEL_E , LWS_GENCRYPTO_RSA_KEYEL_N , LWS_GENCRYPTO_RSA_KEYEL_D , LWS_GENCRYPTO_RSA_KEYEL_P ,
  LWS_GENCRYPTO_RSA_KEYEL_Q , LWS_GENCRYPTO_RSA_KEYEL_DP , LWS_GENCRYPTO_RSA_KEYEL_DQ , LWS_GENCRYPTO_RSA_KEYEL_QI ,
  LWS_GENCRYPTO_RSA_KEYEL_OTHER , LWS_GENCRYPTO_RSA_KEYEL_RI , LWS_GENCRYPTO_RSA_KEYEL_DI , LWS_GENCRYPTO_RSA_KEYEL_TI ,
  LWS_GENCRYPTO_RSA_KEYEL_COUNT
}
 
enum  lws_gencrypto_ec_tok {
  LWS_GENCRYPTO_EC_KEYEL_CRV , LWS_GENCRYPTO_EC_KEYEL_X , LWS_GENCRYPTO_EC_KEYEL_D = LWS_GENCRYPTO_RSA_KEYEL_D , LWS_GENCRYPTO_EC_KEYEL_Y ,
  LWS_GENCRYPTO_EC_KEYEL_COUNT
}
 
enum  lws_gencrypto_aes_tok { LWS_GENCRYPTO_AES_KEYEL_K = LWS_GENCRYPTO_OCT_KEYEL_K , LWS_GENCRYPTO_AES_KEYEL_COUNT }
 

Functions

LWS_VISIBLE LWS_EXTERN int lws_gencrypto_bits_to_bytes (int bits)
 
LWS_VISIBLE LWS_EXTERN int lws_base64_size (int bytes)
 
LWS_VISIBLE LWS_EXTERN size_t lws_gencrypto_padded_length (size_t block_size, size_t len)
 

Data Structure Documentation

◆ lws_gencrypto_keyelem

struct lws_gencrypto_keyelem

Definition at line 99 of file lws-gencrypto.h.

+ Collaboration diagram for lws_gencrypto_keyelem:
Data Fields
uint8_t * buf
uint32_t len

Macro Definition Documentation

◆ LWS_GENCRYPTO_MAX_KEYEL_COUNT

#define LWS_GENCRYPTO_MAX_KEYEL_COUNT   LWS_GENCRYPTO_RSA_KEYEL_COUNT

Definition at line 90 of file lws-gencrypto.h.

Typedef Documentation

◆ lws_gc_elem_t

Enumeration Type Documentation

◆ lws_gencrypto_kty

Enumerator
LWS_GENCRYPTO_KTY_UNKNOWN 
LWS_GENCRYPTO_KTY_OCT 
LWS_GENCRYPTO_KTY_RSA 
LWS_GENCRYPTO_KTY_EC 

Definition at line 31 of file lws-gencrypto.h.

31  {
33 
37 };
@ LWS_GENCRYPTO_KTY_EC
Definition: lws-gencrypto.h:36
@ LWS_GENCRYPTO_KTY_RSA
Definition: lws-gencrypto.h:35
@ LWS_GENCRYPTO_KTY_UNKNOWN
Definition: lws-gencrypto.h:32
@ LWS_GENCRYPTO_KTY_OCT
Definition: lws-gencrypto.h:34

◆ lws_gencrypto_oct_tok

Enumerator
LWS_GENCRYPTO_OCT_KEYEL_K 
LWS_GENCRYPTO_OCT_KEYEL_COUNT 

Definition at line 46 of file lws-gencrypto.h.

46  {
47  LWS_GENCRYPTO_OCT_KEYEL_K, /* note... same offset as AES K */
48 
50 };
@ LWS_GENCRYPTO_OCT_KEYEL_COUNT
Definition: lws-gencrypto.h:49
@ LWS_GENCRYPTO_OCT_KEYEL_K
Definition: lws-gencrypto.h:47

◆ lws_gencrypto_rsa_tok

Enumerator
LWS_GENCRYPTO_RSA_KEYEL_E 
LWS_GENCRYPTO_RSA_KEYEL_N 
LWS_GENCRYPTO_RSA_KEYEL_D 
LWS_GENCRYPTO_RSA_KEYEL_P 
LWS_GENCRYPTO_RSA_KEYEL_Q 
LWS_GENCRYPTO_RSA_KEYEL_DP 
LWS_GENCRYPTO_RSA_KEYEL_DQ 
LWS_GENCRYPTO_RSA_KEYEL_QI 
LWS_GENCRYPTO_RSA_KEYEL_OTHER 
LWS_GENCRYPTO_RSA_KEYEL_RI 
LWS_GENCRYPTO_RSA_KEYEL_DI 
LWS_GENCRYPTO_RSA_KEYEL_TI 
LWS_GENCRYPTO_RSA_KEYEL_COUNT 

Definition at line 52 of file lws-gencrypto.h.

52  {
55  LWS_GENCRYPTO_RSA_KEYEL_D, /* note... same offset as EC D */
61 
62  /* we don't actively use these if given, but may come from COSE */
63 
68 
70 };
@ LWS_GENCRYPTO_RSA_KEYEL_D
Definition: lws-gencrypto.h:55
@ LWS_GENCRYPTO_RSA_KEYEL_DP
Definition: lws-gencrypto.h:58
@ LWS_GENCRYPTO_RSA_KEYEL_QI
Definition: lws-gencrypto.h:60
@ LWS_GENCRYPTO_RSA_KEYEL_COUNT
Definition: lws-gencrypto.h:69
@ LWS_GENCRYPTO_RSA_KEYEL_OTHER
Definition: lws-gencrypto.h:64
@ LWS_GENCRYPTO_RSA_KEYEL_RI
Definition: lws-gencrypto.h:65
@ LWS_GENCRYPTO_RSA_KEYEL_TI
Definition: lws-gencrypto.h:67
@ LWS_GENCRYPTO_RSA_KEYEL_E
Definition: lws-gencrypto.h:53
@ LWS_GENCRYPTO_RSA_KEYEL_DQ
Definition: lws-gencrypto.h:59
@ LWS_GENCRYPTO_RSA_KEYEL_N
Definition: lws-gencrypto.h:54
@ LWS_GENCRYPTO_RSA_KEYEL_Q
Definition: lws-gencrypto.h:57
@ LWS_GENCRYPTO_RSA_KEYEL_P
Definition: lws-gencrypto.h:56
@ LWS_GENCRYPTO_RSA_KEYEL_DI
Definition: lws-gencrypto.h:66

◆ lws_gencrypto_ec_tok

Enumerator
LWS_GENCRYPTO_EC_KEYEL_CRV 
LWS_GENCRYPTO_EC_KEYEL_X 
LWS_GENCRYPTO_EC_KEYEL_D 
LWS_GENCRYPTO_EC_KEYEL_Y 
LWS_GENCRYPTO_EC_KEYEL_COUNT 

Definition at line 72 of file lws-gencrypto.h.

72  {
75  /* note... same offset as RSA D */
78 
80 };
@ LWS_GENCRYPTO_EC_KEYEL_X
Definition: lws-gencrypto.h:74
@ LWS_GENCRYPTO_EC_KEYEL_COUNT
Definition: lws-gencrypto.h:79
@ LWS_GENCRYPTO_EC_KEYEL_D
Definition: lws-gencrypto.h:76
@ LWS_GENCRYPTO_EC_KEYEL_CRV
Definition: lws-gencrypto.h:73
@ LWS_GENCRYPTO_EC_KEYEL_Y
Definition: lws-gencrypto.h:77

◆ lws_gencrypto_aes_tok

Enumerator
LWS_GENCRYPTO_AES_KEYEL_K 
LWS_GENCRYPTO_AES_KEYEL_COUNT 

Definition at line 82 of file lws-gencrypto.h.

82  {
83  /* note... same offset as OCT K */
85 
87 };
@ LWS_GENCRYPTO_AES_KEYEL_K
Definition: lws-gencrypto.h:84
@ LWS_GENCRYPTO_AES_KEYEL_COUNT
Definition: lws-gencrypto.h:86

Function Documentation

◆ lws_gencrypto_bits_to_bytes()

LWS_VISIBLE LWS_EXTERN int lws_gencrypto_bits_to_bytes ( int  bits)

lws_gencrypto_bits_to_bytes() - returns rounded up bytes needed for bits

Parameters
bitsReturns the number of bytes needed to store the given number of bits. If a byte is partially used, the byte count is rounded up.

◆ lws_base64_size()

LWS_VISIBLE LWS_EXTERN int lws_base64_size ( int  bytes)

lws_base64_size() - returns estimated size of base64 encoding

Parameters
bytesReturns a slightly oversize estimate of the size of a base64 encoded version of the given amount of unencoded data.

◆ lws_gencrypto_padded_length()

LWS_VISIBLE LWS_EXTERN size_t lws_gencrypto_padded_length ( size_t  block_size,
size_t  len 
)

lws_gencrypto_padded_length() - returns PKCS#5/#7 padded length

Parameters
blocksize- blocksize to pad to
len- Length of input to pad

Returns the length of a buffer originally of size len after PKCS#5 or PKCS#7 padding has been applied to it.