random.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. random.h
  5. Abstract:
  6. This header contains definitions for the random device interface.
  7. Author:
  8. Evan Green 14-Jan-2015
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. //
  17. // Interface UUID for Pseudo-Random Number Generators.
  18. //
  19. #define UUID_PSEUDO_RANDOM_SOURCE_INTERFACE \
  20. {{0x2AF9AAD3, 0x0EFC48BD, 0xBCE87270, 0xB6834C26}}
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. typedef struct _INTERFACE_PSEUDO_RANDOM_SOURCE INTERFACE_PSEUDO_RANDOM_SOURCE,
  25. *PINTERFACE_PSEUDO_RANDOM_SOURCE;
  26. //
  27. // Pseudo Random Number Generator interface functions
  28. //
  29. typedef
  30. VOID
  31. (*PPSEUDO_RANDOM_ADD_ENTROPY) (
  32. PINTERFACE_PSEUDO_RANDOM_SOURCE Interface,
  33. PVOID Data,
  34. UINTN Length
  35. );
  36. /*++
  37. Routine Description:
  38. This routine adds entropy to a pseudo-random device. This function can be
  39. called at or below dispatch level.
  40. Arguments:
  41. Interface - Supplies a pointer to the interface instance.
  42. Data - Supplies a pointer to the entropy data to add. This data must be
  43. non-paged.
  44. Length - Supplies the number of bytes in the data.
  45. Return Value:
  46. None.
  47. --*/
  48. typedef
  49. VOID
  50. (*PPSEUDO_RANDOM_ADD_TIME_POINT_ENTROPY) (
  51. PINTERFACE_PSEUDO_RANDOM_SOURCE Interface
  52. );
  53. /*++
  54. Routine Description:
  55. This routine adds entropy to a pseudo-random device based on the fact that
  56. this current moment in time is a random one. Said differently, it adds
  57. entropy based on the current timestamp, with the assumption that this
  58. function is called by a source that generates such events randomly. This
  59. function can be called at or below dispatch level.
  60. Arguments:
  61. Interface - Supplies a pointer to the interface instance.
  62. Return Value:
  63. None.
  64. --*/
  65. typedef
  66. VOID
  67. (*PPSEUDO_RANDOM_GET_BYTES) (
  68. PINTERFACE_PSEUDO_RANDOM_SOURCE Interface,
  69. PVOID Data,
  70. UINTN Length
  71. );
  72. /*++
  73. Routine Description:
  74. This routine gets random data from a pseudo-random number generator. This
  75. function can be called at or below dispatch level.
  76. Arguments:
  77. Interface - Supplies a pointer to the interface instance.
  78. Data - Supplies a pointer where the random data will be returned. This
  79. buffer must be non-paged.
  80. Length - Supplies the number of bytes of random data to return.
  81. Return Value:
  82. None.
  83. --*/
  84. /*++
  85. Structure Description:
  86. This structure defines the interface for a pseudo-random number generator.
  87. Members:
  88. DeviceToken - Stores an oqaque token used by the interface functions that
  89. identifies the device.
  90. AddEntropy - Stores a pointer to a function used to add entropy to the
  91. system.
  92. AddTimePointEntropy - Stores a pointer to a function used to add entropy
  93. based on the current time, with the assumption that these events
  94. occur at random intervals.
  95. GetBytes - Stores a pointer to a function used to read data from the
  96. pseudo-random number generator.
  97. --*/
  98. struct _INTERFACE_PSEUDO_RANDOM_SOURCE {
  99. PVOID DeviceToken;
  100. PPSEUDO_RANDOM_ADD_ENTROPY AddEntropy;
  101. PPSEUDO_RANDOM_ADD_TIME_POINT_ENTROPY AddTimePointEntropy;
  102. PPSEUDO_RANDOM_GET_BYTES GetBytes;
  103. };
  104. //
  105. // -------------------------------------------------------------------- Globals
  106. //
  107. //
  108. // -------------------------------------------------------- Function Prototypes
  109. //