deprecation.pod 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. =pod
  2. =head1 NAME
  3. OPENSSL_NO_DEPRECATED_3_2, OSSL_DEPRECATEDIN_3_2,
  4. OPENSSL_NO_DEPRECATED_3_0, OSSL_DEPRECATEDIN_3_0,
  5. OPENSSL_NO_DEPRECATED_1_1_1, OSSL_DEPRECATEDIN_1_1_1,
  6. OPENSSL_NO_DEPRECATED_1_1_0, OSSL_DEPRECATEDIN_1_1_0,
  7. OPENSSL_NO_DEPRECATED_1_0_2, OSSL_DEPRECATEDIN_1_0_2,
  8. OPENSSL_NO_DEPRECATED_1_0_1, OSSL_DEPRECATEDIN_1_0_1,
  9. OPENSSL_NO_DEPRECATED_1_0_0, OSSL_DEPRECATEDIN_1_0_0,
  10. OPENSSL_NO_DEPRECATED_0_9_8, OSSL_DEPRECATEDIN_0_9_8,
  11. deprecation - How to do deprecation
  12. =head1 DESCRIPTION
  13. Deprecation of a symbol is adding an attribute to the declaration of that
  14. symbol (function, type, variable, but we currently only do that for
  15. functions in our public header files, F<< <openssl/*.h> >>).
  16. Removal of a symbol is not the same thing as deprecation, as it actually
  17. explicitly removes the symbol from public view.
  18. OpenSSL configuration supports deprecation as well as simulating removal of
  19. symbols from public view (with the configuration option C<no-deprecated>, or
  20. if the user chooses to do so, with L<OPENSSL_NO_DEPRECATED(7)>), and also
  21. supports doing this in terms of a specified OpenSSL version (with the
  22. configuration option C<--api>, or if the user chooses to do so, with
  23. L<OPENSSL_API_COMPAT(7)>).
  24. Deprecation is done using attribute macros named
  25. B<OSSL_DEPRECATEDIN_I<version>>, used with any declaration it applies to.
  26. Simulating removal is done with C<#ifndef> preprocessor guards using macros
  27. named B<OPENSSL_NO_DEPRECATED_I<version>>.
  28. B<OSSL_DEPRECATEDIN_I<version>> and B<OPENSSL_NO_DEPRECATED_I<version>> are
  29. defined in F<< <openssl/macros.h> >>.
  30. In those macro names, B<I<version>> corresponds to the OpenSSL release since
  31. which the deprecation applies, with underscores instead of periods. Because
  32. of the change in version scheme with OpenSSL 3.0, the B<I<version>> for
  33. versions before that are three numbers (such as C<1_1_0>), while they are
  34. two numbers (such as C<3_0>) from 3.0 and on.
  35. The implementation of a deprecated symbol is kept for one of two reasons:
  36. =over 4
  37. =item Planned to be removed
  38. The symbol and its implementation are planned to be removed some time in the
  39. future, but needs to remain available until that time.
  40. Such an implementation needs to be guarded appropriately, as shown in
  41. L</Implementations to be removed> below.
  42. =item Planned to remain internally
  43. The symbol is planned to be removed from public view, but will otherwise
  44. remain for internal purposes. In this case, the implementation doesn't need
  45. to change or be guarded.
  46. However, it's necessary to ensure that the declaration remains available for
  47. the translation unit where the symbol is used or implemented, even when the
  48. symbol is publicly unavailable through simulated removal. That's done by
  49. including an internal header file very early in the affected translation
  50. units. See L</Implementations to remain internally> below.
  51. In the future, when the deprecated declaration is to actually be removed
  52. from public view, it should be moved to an internal header file, with the
  53. deprecation attribute removed, and the translation units that implement or
  54. use that symbol should adjust their header inclusions accordingly.
  55. =back
  56. =head1 EXAMPLES
  57. =head2 Header files
  58. In public header files (F<< <openssl/*.h> >>), this is what a deprecation is
  59. expected to look like, including the preprocessor wrapping for simulated
  60. removal:
  61. # ifndef OPENSSL_NO_DEPRECATED_3_0
  62. /* ... */
  63. OSSL_DEPRECATEDIN_3_0 RSA *RSA_new_method(ENGINE *engine);
  64. /* ... */
  65. # endif
  66. =head2 Implementations to be removed
  67. For a deprecated function that we plan to remove in the future, for example
  68. RSA_new_method(), the following should be found very early (before including
  69. any OpenSSL header file) in the translation unit that implements it and in
  70. any translation unit that uses it:
  71. /*
  72. * Suppress deprecation warnings for RSA low level implementations that are
  73. * kept until removal.
  74. */
  75. #define OPENSSL_SUPPRESS_DEPRECATED
  76. The RSA_new_method() implementation itself must be guarded the same way as
  77. its declaration in the public header file is:
  78. #ifndef OPENSSL_NO_DEPRECATED_3_0
  79. RSA *RSA_new_method(ENGINE *engine)
  80. {
  81. /* ... */
  82. }
  83. #endif
  84. =head2 Implementations to remain internally
  85. For a deprecated function that we plan to keep internally, for example
  86. RSA_size(), the following should be found very early (before including any
  87. other OpenSSL header file) in the translation unit that implements it and in
  88. any translation unit that uses it:
  89. /*
  90. * RSA low level APIs are deprecated for public use, but are kept for
  91. * internal use.
  92. */
  93. #include "internal/deprecated.h"
  94. =head1 SEE ALSO
  95. L<openssl_user_macros(7)>
  96. =head1 COPYRIGHT
  97. Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  98. Licensed under the Apache License 2.0 (the "License"). You may not use
  99. this file except in compliance with the License. You can obtain a copy
  100. in the file LICENSE in the source distribution or at
  101. L<https://www.openssl.org/source/license.html>.
  102. =cut