rand.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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 OPENSSL_RAND_H
  10. # define OPENSSL_RAND_H
  11. # pragma once
  12. # include <openssl/macros.h>
  13. # if !OPENSSL_API_3
  14. # define HEADER_RAND_H
  15. # endif
  16. # include <stdlib.h>
  17. # include <openssl/types.h>
  18. # include <openssl/e_os2.h>
  19. # include <openssl/randerr.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. struct rand_meth_st {
  24. int (*seed) (const void *buf, int num);
  25. int (*bytes) (unsigned char *buf, int num);
  26. void (*cleanup) (void);
  27. int (*add) (const void *buf, int num, double randomness);
  28. int (*pseudorand) (unsigned char *buf, int num);
  29. int (*status) (void);
  30. };
  31. int RAND_set_rand_method(const RAND_METHOD *meth);
  32. const RAND_METHOD *RAND_get_rand_method(void);
  33. # ifndef OPENSSL_NO_ENGINE
  34. int RAND_set_rand_engine(ENGINE *engine);
  35. # endif
  36. RAND_METHOD *RAND_OpenSSL(void);
  37. # if !OPENSSL_API_1_1_0
  38. # define RAND_cleanup() while(0) continue
  39. # endif
  40. int RAND_bytes(unsigned char *buf, int num);
  41. int RAND_priv_bytes(unsigned char *buf, int num);
  42. DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
  43. void RAND_seed(const void *buf, int num);
  44. void RAND_keep_random_devices_open(int keep);
  45. # if defined(__ANDROID__) && defined(__NDK_FPABI__)
  46. __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
  47. # endif
  48. void RAND_add(const void *buf, int num, double randomness);
  49. int RAND_load_file(const char *file, long max_bytes);
  50. int RAND_write_file(const char *file);
  51. const char *RAND_file_name(char *file, size_t num);
  52. int RAND_status(void);
  53. # ifndef OPENSSL_NO_EGD
  54. int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
  55. int RAND_egd(const char *path);
  56. int RAND_egd_bytes(const char *path, int bytes);
  57. # endif
  58. int RAND_poll(void);
  59. # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
  60. /* application has to include <windows.h> in order to use these */
  61. DEPRECATEDIN_1_1_0(void RAND_screen(void))
  62. DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
  63. # endif
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif