RAND_bytes.pod 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. =pod
  2. =head1 NAME
  3. RAND_bytes, RAND_pseudo_bytes - generate random data
  4. =head1 SYNOPSIS
  5. #include <openssl/rand.h>
  6. int RAND_bytes(unsigned char *buf, int num);
  7. int RAND_pseudo_bytes(unsigned char *buf, int num);
  8. =head1 DESCRIPTION
  9. RAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
  10. into B<buf>. An error occurs if the PRNG has not been seeded with
  11. enough randomness to ensure an unpredictable byte sequence.
  12. RAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>.
  13. Pseudo-random byte sequences generated by RAND_pseudo_bytes() will be
  14. unique if they are of sufficient length, but are not necessarily
  15. unpredictable. They can be used for non-cryptographic purposes and for
  16. certain purposes in cryptographic protocols, but usually not for key
  17. generation etc.
  18. The contents of B<buf> is mixed into the entropy pool before retrieving
  19. the new pseudo-random bytes unless disabled at compile time (see FAQ).
  20. =head1 RETURN VALUES
  21. RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
  22. obtained by L<ERR_get_error(3)|ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
  23. bytes generated are cryptographically strong, 0 otherwise. Both
  24. functions return -1 if they are not supported by the current RAND
  25. method.
  26. =head1 SEE ALSO
  27. L<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
  28. L<RAND_add(3)|RAND_add(3)>
  29. =head1 HISTORY
  30. RAND_bytes() is available in all versions of SSLeay and OpenSSL. It
  31. has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
  32. in OpenSSL 0.9.5.
  33. =cut