RAND_DRBG_new.pod 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. =pod
  2. =head1 NAME
  3. RAND_DRBG_new,
  4. RAND_DRBG_secure_new,
  5. RAND_DRBG_set,
  6. RAND_DRBG_set_defaults,
  7. RAND_DRBG_instantiate,
  8. RAND_DRBG_uninstantiate,
  9. RAND_DRBG_free
  10. - initialize and cleanup a RAND_DRBG instance
  11. =head1 SYNOPSIS
  12. #include <openssl/rand_drbg.h>
  13. RAND_DRBG *RAND_DRBG_new(int type,
  14. unsigned int flags,
  15. RAND_DRBG *parent);
  16. RAND_DRBG *RAND_DRBG_secure_new(int type,
  17. unsigned int flags,
  18. RAND_DRBG *parent);
  19. int RAND_DRBG_set(RAND_DRBG *drbg,
  20. int type, unsigned int flags);
  21. int RAND_DRBG_set_defaults(int type, unsigned int flags);
  22. int RAND_DRBG_instantiate(RAND_DRBG *drbg,
  23. const unsigned char *pers, size_t perslen);
  24. int RAND_DRBG_uninstantiate(RAND_DRBG *drbg);
  25. void RAND_DRBG_free(RAND_DRBG *drbg);
  26. =head1 DESCRIPTION
  27. RAND_DRBG_new() and RAND_DRBG_secure_new()
  28. create a new DRBG instance of the given B<type>, allocated from the heap resp.
  29. the secure heap
  30. (using OPENSSL_zalloc() resp. OPENSSL_secure_zalloc()).
  31. RAND_DRBG_set() initializes the B<drbg> with the given B<type> and B<flags>.
  32. RAND_DRBG_set_defaults() sets the default B<type> and B<flags> for new DRBG
  33. instances.
  34. Currently, all DRBG types are based on AES-CTR, so B<type> can be one of the
  35. following values: NID_aes_128_ctr, NID_aes_192_ctr, NID_aes_256_ctr.
  36. Before the DRBG can be used to generate random bits, it is necessary to set
  37. its type and to instantiate it.
  38. The optional B<flags> argument specifies a set of bit flags which can be
  39. joined using the | operator. Currently, the only flag is
  40. RAND_DRBG_FLAG_CTR_NO_DF, which disables the use of a the derivation function
  41. ctr_df. For an explanation, see [NIST SP 800-90A Rev. 1].
  42. If a B<parent> instance is specified then this will be used instead of
  43. the default entropy source for reseeding the B<drbg>. It is said that the
  44. B<drbg> is I<chained> to its B<parent>.
  45. For more information, see the NOTES section.
  46. RAND_DRBG_instantiate()
  47. seeds the B<drbg> instance using random input from trusted entropy sources.
  48. Optionally, a personalization string B<pers> of length B<perslen> can be
  49. specified.
  50. To omit the personalization string, set B<pers>=NULL and B<perslen>=0;
  51. RAND_DRBG_uninstantiate()
  52. clears the internal state of the B<drbg> and puts it back in the
  53. uninstantiated state.
  54. =head1 RETURN VALUES
  55. RAND_DRBG_new() and RAND_DRBG_secure_new() return a pointer to a DRBG
  56. instance allocated on the heap, resp. secure heap.
  57. RAND_DRBG_set(),
  58. RAND_DRBG_instantiate(), and
  59. RAND_DRBG_uninstantiate()
  60. return 1 on success, and 0 on failure.
  61. RAND_DRBG_free() does not return a value.
  62. =head1 NOTES
  63. The DRBG design supports I<chaining>, which means that a DRBG instance can
  64. use another B<parent> DRBG instance instead of the default entropy source
  65. to obtain fresh random input for reseeding, provided that B<parent> DRBG
  66. instance was properly instantiated, either from a trusted entropy source,
  67. or from yet another parent DRBG instance.
  68. For a detailed description of the reseeding process, see L<RAND_DRBG(7)>.
  69. The default DRBG type and flags are applied only during creation of a DRBG
  70. instance.
  71. To ensure that they are applied to the global and thread-local DRBG instances
  72. (<master>, resp. <public> and <private>), it is necessary to call
  73. RAND_DRBG_set_defaults() before creating any thread and before calling any
  74. cryptographic routines that obtain random data directly or indirectly.
  75. =head1 HISTORY
  76. The RAND_DRBG functions were added in OpenSSL 1.1.1.
  77. =head1 SEE ALSO
  78. L<OPENSSL_zalloc(3)>,
  79. L<OPENSSL_secure_zalloc(3)>,
  80. L<RAND_DRBG_generate(3)>,
  81. L<RAND_DRBG(7)>
  82. =head1 COPYRIGHT
  83. Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  84. Licensed under the OpenSSL license (the "License"). You may not use
  85. this file except in compliance with the License. You can obtain a copy
  86. in the file LICENSE in the source distribution or at
  87. L<https://www.openssl.org/source/license.html>.
  88. =cut