RAND_bytes.pod 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. =pod
  2. =head1 NAME
  3. RAND_bytes, RAND_priv_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_priv_bytes(unsigned char *buf, int num);
  8. Deprecated since OpenSSL 1.1.0, can be hidden entirely by defining
  9. B<OPENSSL_API_COMPAT> with a suitable version value, see
  10. L<openssl_user_macros(7)>:
  11. int RAND_pseudo_bytes(unsigned char *buf, int num);
  12. =head1 DESCRIPTION
  13. RAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
  14. into B<buf>.
  15. RAND_priv_bytes() has the same semantics as RAND_bytes(). It is intended to
  16. be used for generating values that should remain private. If using the
  17. default RAND_METHOD, this function uses a separate "private" PRNG
  18. instance so that a compromise of the "public" PRNG instance will not
  19. affect the secrecy of these private values, as described in L<RAND(7)>
  20. and L<RAND_DRBG(7)>.
  21. =head1 NOTES
  22. Always check the error return value of RAND_bytes() and
  23. RAND_priv_bytes() and do not take randomness for granted: an error occurs
  24. if the CSPRNG has not been seeded with enough randomness to ensure an
  25. unpredictable byte sequence.
  26. =head1 RETURN VALUES
  27. RAND_bytes() and RAND_priv_bytes()
  28. return 1 on success, -1 if not supported by the current
  29. RAND method, or 0 on other failure. The error code can be
  30. obtained by L<ERR_get_error(3)>.
  31. =head1 HISTORY
  32. =over 2
  33. =item *
  34. RAND_pseudo_bytes() was deprecated in OpenSSL 1.1.0; use RAND_bytes() instead.
  35. =item *
  36. The RAND_priv_bytes() function was added in OpenSSL 1.1.1.
  37. =back
  38. =head1 SEE ALSO
  39. L<RAND_add(3)>,
  40. L<RAND_bytes(3)>,
  41. L<RAND_priv_bytes(3)>,
  42. L<ERR_get_error(3)>,
  43. L<RAND(7)>,
  44. L<RAND_DRBG(7)>
  45. =head1 COPYRIGHT
  46. Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
  47. Licensed under the Apache License 2.0 (the "License"). You may not use
  48. this file except in compliance with the License. You can obtain a copy
  49. in the file LICENSE in the source distribution or at
  50. L<https://www.openssl.org/source/license.html>.
  51. =cut