rand.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef HEADER_RAND_H
  10. # define HEADER_RAND_H
  11. # include <stdlib.h>
  12. # include <openssl/ossl_typ.h>
  13. # include <openssl/e_os2.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Already defined in ossl_typ.h */
  18. /* typedef struct rand_meth_st RAND_METHOD; */
  19. struct rand_meth_st {
  20. int (*seed) (const void *buf, int num);
  21. int (*bytes) (unsigned char *buf, int num);
  22. void (*cleanup) (void);
  23. int (*add) (const void *buf, int num, double entropy);
  24. int (*pseudorand) (unsigned char *buf, int num);
  25. int (*status) (void);
  26. };
  27. # ifdef BN_DEBUG
  28. extern int rand_predictable;
  29. # endif
  30. int RAND_set_rand_method(const RAND_METHOD *meth);
  31. const RAND_METHOD *RAND_get_rand_method(void);
  32. # ifndef OPENSSL_NO_ENGINE
  33. int RAND_set_rand_engine(ENGINE *engine);
  34. # endif
  35. RAND_METHOD *RAND_OpenSSL(void);
  36. #if OPENSSL_API_COMPAT < 0x10100000L
  37. # define RAND_cleanup() while(0) continue
  38. #endif
  39. int RAND_bytes(unsigned char *buf, int num);
  40. DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
  41. void RAND_seed(const void *buf, int num);
  42. #if defined(__ANDROID__) && defined(__NDK_FPABI__)
  43. __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
  44. #endif
  45. void RAND_add(const void *buf, int num, double entropy);
  46. int RAND_load_file(const char *file, long max_bytes);
  47. int RAND_write_file(const char *file);
  48. const char *RAND_file_name(char *file, size_t num);
  49. int RAND_status(void);
  50. # ifndef OPENSSL_NO_EGD
  51. int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
  52. int RAND_egd(const char *path);
  53. int RAND_egd_bytes(const char *path, int bytes);
  54. # endif
  55. int RAND_poll(void);
  56. #if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
  57. /* application has to include <windows.h> in order to use these */
  58. DEPRECATEDIN_1_1_0(void RAND_screen(void))
  59. DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
  60. #endif
  61. /* BEGIN ERROR CODES */
  62. /*
  63. * The following lines are auto generated by the script mkerr.pl. Any changes
  64. * made after this point may be overwritten when the script is next run.
  65. */
  66. int ERR_load_RAND_strings(void);
  67. /* Error codes for the RAND functions. */
  68. /* Function codes. */
  69. # define RAND_F_RAND_BYTES 100
  70. /* Reason codes. */
  71. # define RAND_R_PRNG_NOT_SEEDED 100
  72. # ifdef __cplusplus
  73. }
  74. # endif
  75. #endif