prng_test.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. *******************************************************************************
  3. \file prng_test.c
  4. \brief Tests for pseudorandom number generators
  5. \project bee2/test
  6. \created 2014.06.30
  7. \version 2023.03.29
  8. \copyright The Bee2 authors
  9. \license Licensed under the Apache License, Version 2.0 (see LICENSE.txt).
  10. *******************************************************************************
  11. */
  12. #include <bee2/core/mem.h>
  13. #include <bee2/core/hex.h>
  14. #include <bee2/core/prng.h>
  15. #include <bee2/core/util.h>
  16. /*
  17. *******************************************************************************
  18. Тестирование
  19. *******************************************************************************
  20. */
  21. bool_t prngTest()
  22. {
  23. octet buf[128];
  24. char state[256];
  25. // подготовить память
  26. if (sizeof(state) < prngSTB_keep())
  27. return FALSE;
  28. // prngSTB
  29. prngSTBStart(state, 0);
  30. prngSTBStepR(buf, 128, state);
  31. if (!hexEq(buf,
  32. "402971E923BFD0B621E230D4CBFAF010"
  33. "E2D1F32D5C76B58AE05AB02BB85B2A10"
  34. "67F8DC6FFFF51932D956E3B3749884C5"
  35. "623331D616FF391C8AF12556A0CBA754"
  36. "79F682F6DD86DACB59346C50DD01CFAF"
  37. "6255D350C3B7392C8F6AA11496BBD25D"
  38. "D80C0173331A9C0DF721884E4E2773C5"
  39. "7FE4E23824E31FC902F1C7A09EB1C312"))
  40. return FALSE;
  41. // все нормально
  42. return TRUE;
  43. }