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
968 B

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