File: random.h

package info (click to toggle)
rsyncrypto 1.14-1.2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,552 kB
  • sloc: cpp: 3,459; sh: 1,221; makefile: 29
file content (20 lines) | stat: -rw-r--r-- 398 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef RANDOM_H
#define RANDOM_H

class random {
public:
    static void rand(void *buff, size_t size)
    {
        if( !RAND_bytes(static_cast<unsigned char *>(buff), size) )
            throw rscerror("No random entropy for key and IV");
    }
    static unsigned char rand()
    {
        unsigned char ret;
        rand( &ret, sizeof(ret) );

        return ret;
    }
};

#endif // RANDOM_H