aboutsummaryrefslogtreecommitdiff
path: root/picohttp_base64.c
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@physik.uni-muenchen.de>2013-12-06 19:01:10 +0100
committerWolfgang Draxinger <Wolfgang.Draxinger@physik.uni-muenchen.de>2013-12-06 19:01:10 +0100
commit0099af525fe5efed85b27274d2341962b3929dae (patch)
tree406f34c673b53b4a3c1b1f9d92463a16a50a5fa7 /picohttp_base64.c
parent65930003e56b64afdde64cd9597e55b21d08b7c3 (diff)
downloadlitheweb-0099af525fe5efed85b27274d2341962b3929dae.tar.gz
litheweb-0099af525fe5efed85b27274d2341962b3929dae.tar.bz2
fixes in base64 encode and auth structure
Diffstat (limited to 'picohttp_base64.c')
-rw-r--r--picohttp_base64.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/picohttp_base64.c b/picohttp_base64.c
index 1374bff..3411286 100644
--- a/picohttp_base64.c
+++ b/picohttp_base64.c
@@ -5,24 +5,22 @@ void phb64encode(
size_t count,
phb64enc_t enc)
{
- switch(count) {
- default: break;
- case 2:
- enc[3] = 0xff;
- case 1:
- enc[2] = 0xff;
- }
+ enc[1] = 0;
+ enc[3] = 0xff;
+ enc[2] = (count > 1) ? 0 : 0xff;
+
switch(count) {
default:
return;
- case 4:
- enc[3] |= ((raw[3] & 0x3f));
case 3:
+ enc[3] = ((raw[2] & 0x3f));
+ enc[2] = ((raw[2] & 0xc0) >> 6);
case 2:
- enc[2] |= ((raw[2] & 0xc0) >> 6) | ((raw[1] & 0x0f) << 2);
+ enc[2] |= ((raw[1] & 0x0f) << 2);
+ enc[1] = ((raw[1] & 0xf0) >> 4);
case 1:
- enc[1] = ((raw[1] & 0xf0) >> 4) | ((raw[0] & 0x03) << 4);
- enc[0] = ((raw[0] & 0xfc) >> 2);
+ enc[1] |= ((raw[0] & 0x03) << 4);
+ enc[0] = ((raw[0] & 0xfc) >> 2);
}
for(int i = 0; i < 4; i++) {