Here's some COBOL which calls CSNBRNGL. I have included calls to STCKF to get
timings (see: https://github.com/admattingly/Macho/ ) but you can comment this
out if you wish. Hopefully this logic is self-explanatory:
identification division.
program-id. wrangle.
environment division.
data division.
working-storage section.
01 cca-return-code pic 9(9) comp-5.
01 cca-reason-code pic 9(9) comp-5.
01 cca-exit-data-length pic 9(9) comp-5.
01 cca-exit-data pic x.
01 cca-rule-array-count pic 9(9) comp-5.
01 cca-rule-array.
05 cca-rule pic x(8) occurs 8.
01 rng-key-identifier-length pic 9(9) comp-5.
01 rng-key-identifier pic x(64).
01 rng-random-number-length pic 9(9) comp-5.
01 rng-random-number pic x(4096).
01 rng-function pic x(8) value 'CSNBRNGL'.
*
01 time-start pic 9(18) comp-5.
01 time-end pic 9(18) comp-5.
01 elapsed-microseconds pic z(5)9.9(10).
01 stck-ticks pic 9(18) comp-5.
01 stck-function pic x(8) value 'STCKF'.
*
procedure division.
move 16 to rng-random-number-length
call stck-function using time-start stck-ticks
perform get-random
call stck-function using time-end stck-ticks
if cca-return-code = 0 then
display function
hex-of(rng-random-number(1:rng-random-number-length))
else
display 'CSNBRNGL rc=' cca-return-code
', rsn=' cca-reason-code
end-if
compute elapsed-microseconds = (time-end - time-start)
/ 4096.0
display 'Elapsed=' elapsed-microseconds ' us'
stop run.
get-random.
move zero to cca-exit-data-length
move 1 to cca-rule-array-count
move 'RANDOM' to cca-rule(1)
move 0 to rng-key-identifier-length
* rng-random-number-length set by caller
call rng-function using
cca-return-code
cca-reason-code
cca-exit-data-length
cca-exit-data
cca-rule-array-count
cca-rule-array
rng-key-identifier-length
rng-key-identifier
rng-random-number-length
rng-random-number.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN