enc_head.c 569 B

1234567891011121314151617181920212223
  1. // Assume that *out is large enough to contain the output.
  2. // Theoretically it should be 4/3 the length of src.
  3. const uint8_t *c = (const uint8_t *)src;
  4. uint8_t *o = (uint8_t *)out;
  5. // Use local temporaries to avoid cache thrashing:
  6. size_t outl = 0;
  7. struct plain64_base64_state st;
  8. st.bytes = state->bytes;
  9. st.carry = state->carry;
  10. // Turn three bytes into four 6-bit numbers:
  11. // in[0] = 00111111
  12. // in[1] = 00112222
  13. // in[2] = 00222233
  14. // in[3] = 00333333
  15. // Duff's device, a for() loop inside a switch() statement. Legal!
  16. switch (st.bytes)
  17. {
  18. for (;;)
  19. {
  20. case 0: