base64_test.c 548 B

123456789101112131415161718192021222324
  1. #include <tomcrypt_test.h>
  2. int base64_test(void)
  3. {
  4. unsigned char in[64], out[256], tmp[64];
  5. unsigned long x, l1, l2;
  6. for (x = 0; x < 64; x++) {
  7. yarrow_read(in, x, &yarrow_prng);
  8. l1 = sizeof(out);
  9. DO(base64_encode(in, x, out, &l1));
  10. l2 = sizeof(tmp);
  11. DO(base64_decode(out, l1, tmp, &l2));
  12. if (l2 != x || memcmp(tmp, in, x)) {
  13. fprintf(stderr, "base64 failed %lu %lu %lu", x, l1, l2);
  14. return 1;
  15. }
  16. }
  17. return 0;
  18. }
  19. /* $Source$ */
  20. /* $Revision$ */
  21. /* $Date$ */