rand.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. void RAND_keep_random_devices_open(int keep);
  40. # if defined(__ANDROID__) && defined(__NDK_FPABI__)
  41. __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
  42. # endif
  43. void RAND_add(const void *buf, int num, double randomness);
  44. int RAND_load_file(const char *file, long max_bytes);
  45. int RAND_write_file(const char *file);
  46. const char *RAND_file_name(char *file, size_t num);
  47. int RAND_status(void);
  48. # ifndef OPENSSL_NO_EGD
  49. int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
  50. int RAND_egd(const char *path);
  51. int RAND_egd_bytes(const char *path, int bytes);
  52. # endif
  53. int RAND_poll(void);
  54. # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
  55. /* application has to include <windows.h> in order to use these */
  56. DEPRECATEDIN_1_1_0(void RAND_screen(void))
  57. DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
  58. # endif
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif