RAND_bytes.pod 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. =head1 RETURN VALUES
  19. RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
  20. obtained by L<ERR_get_error(3)|ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
  21. bytes generated are cryptographically strong, 0 otherwise. Both
  22. functions return -1 if they are not supported by the current RAND
  23. method.
  24. =head1 SEE ALSO
  25. L<rand(3)|rand(3)>, L<err(3)|err(3)>, L<RAND_add(3)|RAND_add(3)>
  26. =head1 HISTORY
  27. RAND_bytes() is available in all versions of SSLeay and OpenSSL. It
  28. has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
  29. in OpenSSL 0.9.5.
  30. =cut