You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.8 KiB

  1. /* Copyright (c) 2017, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include <openssl/rand.h>
  15. #include <limits.h>
  16. void RAND_seed(const void *buf, int num) {
  17. // OpenSSH calls |RAND_seed| before jailing on the assumption that any needed
  18. // file descriptors etc will be opened.
  19. uint8_t unused;
  20. RAND_bytes(&unused, sizeof(unused));
  21. }
  22. int RAND_load_file(const char *path, long num) {
  23. if (num < 0) { // read the "whole file"
  24. return 1;
  25. } else if (num <= INT_MAX) {
  26. return (int) num;
  27. } else {
  28. return INT_MAX;
  29. }
  30. }
  31. const char *RAND_file_name(char *buf, size_t num) { return NULL; }
  32. void RAND_add(const void *buf, int num, double entropy) {}
  33. int RAND_egd(const char *path) {
  34. return 255;
  35. }
  36. int RAND_poll(void) {
  37. return 1;
  38. }
  39. int RAND_status(void) {
  40. return 1;
  41. }
  42. static const struct rand_meth_st kSSLeayMethod = {
  43. RAND_seed,
  44. RAND_bytes,
  45. RAND_cleanup,
  46. RAND_add,
  47. RAND_pseudo_bytes,
  48. RAND_status,
  49. };
  50. RAND_METHOD *RAND_SSLeay(void) {
  51. return (RAND_METHOD*) &kSSLeayMethod;
  52. }
  53. const RAND_METHOD *RAND_get_rand_method(void) { return RAND_SSLeay(); }
  54. void RAND_set_rand_method(const RAND_METHOD *method) {}
  55. void RAND_cleanup(void) {}