1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpgscm: Add support for pseudo-random numbers.

* tests/gpgscm/ffi.c (do_getpid): New function.
(do_srandom): Likewise.
(random_scaled): Likewise.
(do_random): Likewise.
(do_make_random_string): Likewise.
(ffi_init): Expose the new functions.
* tests/gpgscm/lib.scm: Document the new functions.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-11-07 12:21:26 +01:00
parent 5840353d8b
commit 6e677f9b55
2 changed files with 94 additions and 0 deletions

View file

@ -185,3 +185,24 @@
(else
(write-char (apply read-char p) acc)
(loop acc))))))
;;
;; Libc functions.
;;
;; Get our process id.
(ffi-define (getpid))
;;
;; Random numbers.
;;
;; Seed the random number generator.
(ffi-define (srandom seed))
;; Get a pseudo-random number between 0 (inclusive) and SCALE
;; (exclusive).
(ffi-define (random scale))
;; Create a string of the given SIZE containing pseudo-random data.
(ffi-define (make-random-string size))