Skip to content
Snippets Groups Projects
Commit cff9e510 authored by Niels Möller's avatar Niels Möller
Browse files

(base64_encode): Broke out some common code from the switch..

Rev: src/nettle/base64.c:1.4
parent 0384fc6f
No related branches found
No related tags found
No related merge requests found
...@@ -71,27 +71,24 @@ base64_encode(uint8_t *dst, ...@@ -71,27 +71,24 @@ base64_encode(uint8_t *dst,
if (left_over) if (left_over)
{ {
in -= left_over;
*--out = '=';
switch(left_over) switch(left_over)
{ {
case 1: case 1:
in--;
*--out = '=';
*--out = '='; *--out = '=';
*--out = ENCODE(in[0] << 4); *--out = ENCODE(in[0] << 4);
*--out = ENCODE(in[0] >> 2);
break; break;
case 2: case 2:
in-= 2;
*--out = '=';
*--out = ENCODE( in[1] << 2); *--out = ENCODE( in[1] << 2);
*--out = ENCODE((in[0] << 4) | (in[1] >> 4)); *--out = ENCODE((in[0] << 4) | (in[1] >> 4));
*--out = ENCODE( in[0] >> 2);
break; break;
default: default:
abort(); abort();
} }
*--out = ENCODE(in[0] >> 2);
} }
while (in > src) while (in > src)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment