RAND_load_file.pod 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. int RAND_load_file(const char *filename, long max_bytes);
  7. int RAND_write_file(const char *filename);
  8. const char *RAND_file_name(char *buf, size_t num);
  9. =head1 DESCRIPTION
  10. RAND_load_file() reads a number of bytes from file B<filename> and
  11. adds them to the PRNG. If B<max_bytes> is nonnegative,
  12. up to B<max_bytes> are read;
  13. if B<max_bytes> is -1, the complete file is read.
  14. Do not load the same file multiple times unless its contents have
  15. been updated by RAND_write_file() between reads.
  16. Also, note that B<filename> should be adequately protected so that an
  17. attacker cannot replace or examine the contents.
  18. If B<filename> is not a regular file, then user is considered to be
  19. responsible for any side effects, e.g. non-anticipated blocking or
  20. capture of controlling terminal.
  21. RAND_write_file() writes a number of random bytes (currently 128) to
  22. file B<filename> which can be used to initialize the PRNG by calling
  23. RAND_load_file() in a later session.
  24. RAND_file_name() generates a default path for the random seed
  25. file. B<buf> points to a buffer of size B<num> in which to store the
  26. filename.
  27. On all systems, if the environment variable B<RANDFILE> is set, its
  28. value will be used as the seed filename.
  29. Otherwise, the file is called C<.rnd>, found in platform dependent locations:
  30. =over 4
  31. =item On Windows (in order of preference)
  32. %HOME%, %USERPROFILE%, %SYSTEMROOT%, C:\
  33. =item On VMS
  34. SYS$LOGIN:
  35. =item On all other systems
  36. $HOME
  37. =back
  38. If C<$HOME> (on non-Windows and non-VMS system) is not set either, or
  39. B<num> is too small for the pathname, an error occurs.
  40. =head1 RETURN VALUES
  41. RAND_load_file() returns the number of bytes read or -1 on error.
  42. RAND_write_file() returns the number of bytes written, or -1 if the
  43. bytes written were generated without appropriate seeding.
  44. RAND_file_name() returns a pointer to B<buf> on success, and NULL on
  45. error.
  46. =head1 SEE ALSO
  47. L<RAND_add(3)>,
  48. L<RAND_bytes(3)>,
  49. L<RAND(7)>
  50. =head1 COPYRIGHT
  51. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  52. Licensed under the Apache License 2.0 (the "License"). You may not use
  53. this file except in compliance with the License. You can obtain a copy
  54. in the file LICENSE in the source distribution or at
  55. L<https://www.openssl.org/source/license.html>.
  56. =cut