File: rtlgenrandom.c

package info (click to toggle)
python-xeddsa 0.4.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 884 kB
  • sloc: ansic: 5,442; python: 525; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "kernelrandombytes.h"
#include <Windows.h>

#define RtlGenRandom SystemFunction036

#ifdef __cplusplus
extern "C" {
#endif
BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
#ifdef __cplusplus
}
#endif

void kernelrandombytes(unsigned char *x,unsigned long long xlen)
{
  int i;

  while (xlen > 0) {
    if (xlen < 256) i = xlen; else i = 256;
    RtlGenRandom(x, i);
    x += i;
    xlen -= i;
  }
}