-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathngx_http_secure_token_utils.h
75 lines (61 loc) · 1.56 KB
/
ngx_http_secure_token_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef _NGX_HTTP_SECURE_TOKEN_UTILS_H_INCLUDED_
#define _NGX_HTTP_SECURE_TOKEN_UTILS_H_INCLUDED_
// includes
#include <ngx_core.h>
#include <ngx_http.h>
#include <openssl/evp.h>
// constants
#ifndef MD5_DIGEST_LENGTH
#define MD5_DIGEST_LENGTH (16)
#endif // MD5_DIGEST_LENGTH
#ifndef AES_BLOCK_SIZE
#define AES_BLOCK_SIZE (16)
#endif // AES_BLOCK_SIZE
// typedefs
typedef enum {
NGX_HTTP_SECURE_TOKEN_TIME_UNSET,
NGX_HTTP_SECURE_TOKEN_TIME_RELATIVE,
NGX_HTTP_SECURE_TOKEN_TIME_ABSOLUTE,
} ngx_secure_token_time_type_t;
typedef struct {
ngx_secure_token_time_type_t type;
time_t val;
} ngx_secure_token_time_t;
// conf functions
char* ngx_http_secure_token_conf_set_hex_str_slot(
ngx_conf_t *cf,
ngx_command_t *cmd,
void *conf);
char* ngx_http_secure_token_conf_set_time_slot(
ngx_conf_t *cf,
ngx_command_t *cmd,
void *conf);
char* ngx_http_secure_token_conf_set_private_key_slot(
ngx_conf_t *cf,
ngx_command_t *cmd,
void *conf);
char* ngx_http_secure_token_conf_block(
ngx_conf_t *cf,
ngx_command_t *cmds,
void *conf,
ngx_http_get_variable_pt get_handler);
// token functions
u_char* ngx_http_secure_token_encode_base64_internal(
u_char *d,
ngx_str_t *src,
const u_char *basis,
u_char padding);
ngx_int_t ngx_http_secure_token_sign(
ngx_http_request_t* r,
EVP_PKEY* private_key,
ngx_str_t* message,
ngx_str_t* signature);
ngx_int_t ngx_http_secure_token_escape_xml(
ngx_pool_t* pool,
ngx_str_t* src,
ngx_str_t* dest);
char* ngx_conf_check_str_len_bounds(
ngx_conf_t *cf,
void *post,
void *data);
#endif // _NGX_HTTP_SECURE_TOKEN_UTILS_H_INCLUDED_