rand.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 1995-2018 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. # include <openssl/randerr.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct rand_meth_st {
  19. int (*seed) (const void *buf, int num);
  20. int (*bytes) (unsigned char *buf, int num);
  21. void (*cleanup) (void);
  22. int (*add) (const void *buf, int num, double randomness);
  23. int (*pseudorand) (unsigned char *buf, int num);
  24. int (*status) (void);
  25. };
  26. int RAND_set_rand_method(const RAND_METHOD *meth);
  27. const RAND_METHOD *RAND_get_rand_method(void);
  28. # ifndef OPENSSL_NO_ENGINE
  29. int RAND_set_rand_engine(ENGINE *engine);
  30. # endif
  31. RAND_METHOD *RAND_OpenSSL(void);
  32. # if OPENSSL_API_COMPAT < 0x10100000L
  33. # define RAND_cleanup() while(0) continue
  34. # endif
  35. int RAND_bytes(unsigned char *buf, int num);
  36. int RAND_priv_bytes(unsigned char *buf, int num);
  37. DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
  38. void RAND_seed(const void *buf, int num);
  39. # if defined(__ANDROID__) && defined(__NDK_FPABI__)
  40. __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
  41. # endif
  42. void RAND_add(const void *buf, int num, double randomness);
  43. int RAND_load_file(const char *file, long max_bytes);
  44. int RAND_write_file(const char *file);
  45. const char *RAND_file_name(char *file, size_t num);
  46. int RAND_status(void);
  47. # ifndef OPENSSL_NO_EGD
  48. int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
  49. int RAND_egd(const char *path);
  50. int RAND_egd_bytes(const char *path, int bytes);
  51. # endif
  52. typedef void (*RAND_poll_cb)(void *arg,
  53. const void *buf, int num, double randomness);
  54. int RAND_poll(void);
  55. # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
  56. /* application has to include <windows.h> in order to use these */
  57. DEPRECATEDIN_1_1_0(void RAND_screen(void))
  58. DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
  59. # endif
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif