libwebsockets
Lightweight C library for HTML5 websockets
lws-sha1-base64.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
31 #ifdef LWS_SHA1_USE_OPENSSL_NAME
32 #define lws_SHA1 SHA1
33 #else
43 LWS_VISIBLE LWS_EXTERN unsigned char *
44 lws_SHA1(const unsigned char *d, size_t n, unsigned char *md);
45 #endif
56 LWS_VISIBLE LWS_EXTERN int
57 lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
68 LWS_VISIBLE LWS_EXTERN int
69 lws_b64_encode_string_url(const char *in, int in_len, char *out, int out_size);
79 LWS_VISIBLE LWS_EXTERN int
80 lws_b64_decode_string(const char *in, char *out, int out_size);
91 LWS_VISIBLE LWS_EXTERN int
92 lws_b64_decode_string_len(const char *in, int in_len, char *out, int out_size);
93 
94 struct lws_b64state {
95  unsigned char quad[4];
96  size_t done;
97  size_t len;
98  int i;
99  int c;
100 };
101 
102 LWS_VISIBLE LWS_EXTERN void
103 lws_b64_decode_state_init(struct lws_b64state *state);
104 
105 LWS_VISIBLE LWS_EXTERN int
106 lws_b64_decode_stateful(struct lws_b64state *s, const char *in, size_t *in_len,
107  uint8_t *out, size_t *out_size, int final);
109 
LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string_url(const char *in, int in_len, char *out, int out_size)
LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string(const char *in, char *out, int out_size)
LWS_VISIBLE LWS_EXTERN unsigned char * lws_SHA1(const unsigned char *d, size_t n, unsigned char *md)
LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string(const char *in, int in_len, char *out, int out_size)
LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string_len(const char *in, int in_len, char *out, int out_size)
Definition: lws-sha1-base64.h:94