RAND_load_file.pod 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. =pod
  2. =head1 NAME
  3. RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
  4. =head1 SYNOPSIS
  5. #include <openssl/rand.h>
  6. const char *RAND_file_name(char *buf, size_t num);
  7. int RAND_load_file(const char *filename, long max_bytes);
  8. int RAND_write_file(const char *filename);
  9. =head1 DESCRIPTION
  10. RAND_file_name() generates a default path for the random seed
  11. file. B<buf> points to a buffer of size B<num> in which to store the
  12. filename.
  13. On all systems, if the environment variable B<RANDFILE> is set, its
  14. value will be used as the seed file name.
  15. Otherwise, the file is called ".rnd", found in platform dependent locations:
  16. =over 4
  17. =item On Windows (in order of preference)
  18. %HOME%, %USERPROFILE%, %SYSTEMROOT%, C:\
  19. =item On VMS
  20. SYS$LOGIN:
  21. =item On all other systems
  22. $HOME
  23. =back
  24. If C<$HOME> (on non-Windows and non-VMS system) is not set either, or
  25. B<num> is too small for the path name, an error occurs.
  26. RAND_load_file() reads a number of bytes from file B<filename> and
  27. adds them to the PRNG. If B<max_bytes> is non-negative,
  28. up to B<max_bytes> are read;
  29. if B<max_bytes> is -1, the complete file is read.
  30. RAND_write_file() writes a number of random bytes (currently 1024) to
  31. file B<filename> which can be used to initialize the PRNG by calling
  32. RAND_load_file() in a later session.
  33. =head1 RETURN VALUES
  34. RAND_load_file() returns the number of bytes read or -1 on error.
  35. RAND_write_file() returns the number of bytes written, and -1 if the
  36. bytes written were generated without appropriate seed.
  37. RAND_file_name() returns a pointer to B<buf> on success, and NULL on
  38. error.
  39. =head1 SEE ALSO
  40. L<rand(3)>, L<RAND_add(3)>, L<RAND_cleanup(3)>
  41. =head1 COPYRIGHT
  42. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  43. Licensed under the OpenSSL license (the "License"). You may not use
  44. this file except in compliance with the License. You can obtain a copy
  45. in the file LICENSE in the source distribution or at
  46. L<https://www.openssl.org/source/license.html>.
  47. =cut