RAND_bytes.pod 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. Deprecated:
  8. #if OPENSSL_API_COMPAT < 0x10100000L
  9. int RAND_pseudo_bytes(unsigned char *buf, int num);
  10. #endif
  11. =head1 DESCRIPTION
  12. RAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
  13. into B<buf>. An error occurs if the PRNG has not been seeded with
  14. enough randomness to ensure an unpredictable byte sequence.
  15. RAND_pseudo_bytes() has been deprecated. Users should use RAND_bytes() instead.
  16. RAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>.
  17. Pseudo-random byte sequences generated by RAND_pseudo_bytes() will be
  18. unique if they are of sufficient length, but are not necessarily
  19. unpredictable. They can be used for non-cryptographic purposes and for
  20. certain purposes in cryptographic protocols, but usually not for key
  21. generation etc.
  22. The contents of B<buf> is mixed into the entropy pool before retrieving
  23. the new pseudo-random bytes unless disabled at compile time (see FAQ).
  24. =head1 RETURN VALUES
  25. RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
  26. obtained by L<ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
  27. bytes generated are cryptographically strong, 0 otherwise. Both
  28. functions return -1 if they are not supported by the current RAND
  29. method.
  30. =head1 SEE ALSO
  31. L<rand(3)>, L<ERR_get_error(3)>,
  32. L<RAND_add(3)>
  33. =head1 COPYRIGHT
  34. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  35. Licensed under the OpenSSL license (the "License"). You may not use
  36. this file except in compliance with the License. You can obtain a copy
  37. in the file LICENSE in the source distribution or at
  38. L<https://www.openssl.org/source/license.html>.
  39. =cut