You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
981 B

  1. #include "windows/windows-quirks.h"
  2. #define TEST_NAME "auth5"
  3. #include "cmptest.h"
  4. unsigned char key[32];
  5. unsigned char c[10000];
  6. unsigned char a[32];
  7. int main(void)
  8. {
  9. size_t clen;
  10. for (clen = 0; clen < 10000; ++clen) {
  11. randombytes_buf(key, sizeof key);
  12. randombytes_buf(c, clen);
  13. crypto_auth(a, c, clen, key);
  14. if (crypto_auth_verify(a, c, clen, key) != 0) {
  15. printf("fail %u\n", (unsigned int) clen);
  16. return 100;
  17. }
  18. if (clen > 0) {
  19. c[rand() % clen] += 1 + (rand() % 255);
  20. if (crypto_auth_verify(a, c, clen, key) == 0) {
  21. printf("forgery %u\n", (unsigned int) clen);
  22. return 100;
  23. }
  24. a[rand() % sizeof a] += 1 + (rand() % 255);
  25. if (crypto_auth_verify(a, c, clen, key) == 0) {
  26. printf("forgery %u\n", (unsigned int) clen);
  27. return 100;
  28. }
  29. }
  30. }
  31. return 0;
  32. }