commit 98445b0f4ae3c694c555b99a0011dc5c383f393b
parent 2cbd1a35f0d3ffb7ca4c6ec50305d01de7693695
Author: William Casarin <jb55@jb55.com>
Date: Mon, 25 Oct 2021 13:31:02 -0700
undo base64 changes
Diffstat:
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/ap_json.c b/src/ap_json.c
@@ -251,7 +251,7 @@ static int handle_wsdigest(struct ap_json *a)
struct cursor *c = &p->cur;
size_t b64_len;
unsigned char hash[32];
- char b64[128];
+ unsigned char b64[128];
unsigned char *pos;
if (!handle_key(a, "@wsdigest")) {
@@ -269,8 +269,7 @@ static int handle_wsdigest(struct ap_json *a)
pos = c->p;
- if (!(push_str(c, "SHA-256=") &&
- push_data(c, (unsigned char*)b64, b64_len) )) {
+ if (!(push_str(c, "SHA-256=") && push_data(c, b64, b64_len) )) {
return 0;
}
diff --git a/src/base64.c b/src/base64.c
@@ -12,7 +12,7 @@
#include <assert.h>
static const unsigned char base64_table[65] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const unsigned char base62_table[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -30,11 +30,11 @@ static const unsigned char base62_table[] =
* not included in out_len.
*/
-char * base_encode(const unsigned char *src, size_t len,
- char *out, size_t out_capacity,
+unsigned char * base_encode(const unsigned char *src, size_t len,
+ unsigned char *out, size_t out_capacity,
size_t *out_len, const unsigned char *base_table)
{
- char *pos;
+ unsigned char *pos;
const unsigned char *end, *in;
size_t olen;
@@ -77,14 +77,14 @@ char * base_encode(const unsigned char *src, size_t len,
return out;
}
-char *
-base64_encode(const unsigned char *src, size_t len, char *out,
+unsigned char *
+base64_encode(const unsigned char *src, size_t len, unsigned char *out,
size_t out_capacity, size_t *out_len) {
return base_encode(src, len, out, out_capacity, out_len, base64_table);
}
-char *
-base62_encode(const unsigned char *src, size_t len, char *out,
+unsigned char *
+base62_encode(const unsigned char *src, size_t len, unsigned char *out,
size_t out_capacity, size_t *out_len) {
return base_encode(src, len, out, out_capacity, out_len, base62_table);
}
diff --git a/src/base64.h b/src/base64.h
@@ -11,11 +11,11 @@
#include <stddef.h>
-char * base62_encode(const unsigned char *src, size_t len,
- char *out, size_t out_capacity,
+unsigned char * base62_encode(const unsigned char *src, size_t len,
+ unsigned char *out, size_t out_capacity,
size_t *out_len);
-char * base64_encode(const unsigned char *src, size_t len,
- char *out, size_t out_capacity,
+unsigned char * base64_encode(const unsigned char *src, size_t len,
+ unsigned char *out, size_t out_capacity,
size_t *out_len);
unsigned char * base64_decode(const unsigned char *src, size_t len,
unsigned char *out, size_t out_capacity,