25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PORTING.md 16 KiB

Switch OPENSSL_VERSION_NUMBER to 1.1.0. Although we are derived from 1.0.2, we mimic 1.1.0 in some ways around our FOO_up_ref functions and opaque libssl types. This causes some difficulties when porting third-party code as any OPENSSL_VERSION_NUMBER checks for 1.1.0 APIs we have will be wrong. Moreover, adding accessors without changing OPENSSL_VERSION_NUMBER can break external projects. It is common to implement a compatibility version of an accessor under #ifdef as a static function. This then conflicts with our headers if we, unlike OpenSSL 1.0.2, have this function. This change switches OPENSSL_VERSION_NUMBER to 1.1.0 and atomically adds enough accessors for software with 1.1.0 support already. The hope is this will unblock hiding SSL_CTX and SSL_SESSION, which will be especially useful with C++-ficiation. The cost is we will hit some growing pains as more 1.1.0 consumers enter the ecosystem and we converge on the right set of APIs to import from upstream. It does not remove any 1.0.2 APIs, so we will not require that all projects support 1.1.0. The exception is APIs which changed in 1.1.0 but did not change the function signature. Those are breaking changes. Specifically: - SSL_CTX_sess_set_get_cb is now const-correct. - X509_get0_signature is now const-correct. For C++ consumers only, this change temporarily includes an overload hack for SSL_CTX_sess_set_get_cb that keeps the old callback working. This is a workaround for Node not yet supporting OpenSSL 1.1.0. The version number is set at (the as yet unreleased) 1.1.0g to denote that this change includes https://github.com/openssl/openssl/pull/4384. Bug: 91 Change-Id: I5eeb27448a6db4c25c244afac37f9604d9608a76 Reviewed-on: https://boringssl-review.googlesource.com/10340 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
8 년 전
Switch OPENSSL_VERSION_NUMBER to 1.1.0. Although we are derived from 1.0.2, we mimic 1.1.0 in some ways around our FOO_up_ref functions and opaque libssl types. This causes some difficulties when porting third-party code as any OPENSSL_VERSION_NUMBER checks for 1.1.0 APIs we have will be wrong. Moreover, adding accessors without changing OPENSSL_VERSION_NUMBER can break external projects. It is common to implement a compatibility version of an accessor under #ifdef as a static function. This then conflicts with our headers if we, unlike OpenSSL 1.0.2, have this function. This change switches OPENSSL_VERSION_NUMBER to 1.1.0 and atomically adds enough accessors for software with 1.1.0 support already. The hope is this will unblock hiding SSL_CTX and SSL_SESSION, which will be especially useful with C++-ficiation. The cost is we will hit some growing pains as more 1.1.0 consumers enter the ecosystem and we converge on the right set of APIs to import from upstream. It does not remove any 1.0.2 APIs, so we will not require that all projects support 1.1.0. The exception is APIs which changed in 1.1.0 but did not change the function signature. Those are breaking changes. Specifically: - SSL_CTX_sess_set_get_cb is now const-correct. - X509_get0_signature is now const-correct. For C++ consumers only, this change temporarily includes an overload hack for SSL_CTX_sess_set_get_cb that keeps the old callback working. This is a workaround for Node not yet supporting OpenSSL 1.1.0. The version number is set at (the as yet unreleased) 1.1.0g to denote that this change includes https://github.com/openssl/openssl/pull/4384. Bug: 91 Change-Id: I5eeb27448a6db4c25c244afac37f9604d9608a76 Reviewed-on: https://boringssl-review.googlesource.com/10340 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
8 년 전
Switch OPENSSL_VERSION_NUMBER to 1.1.0. Although we are derived from 1.0.2, we mimic 1.1.0 in some ways around our FOO_up_ref functions and opaque libssl types. This causes some difficulties when porting third-party code as any OPENSSL_VERSION_NUMBER checks for 1.1.0 APIs we have will be wrong. Moreover, adding accessors without changing OPENSSL_VERSION_NUMBER can break external projects. It is common to implement a compatibility version of an accessor under #ifdef as a static function. This then conflicts with our headers if we, unlike OpenSSL 1.0.2, have this function. This change switches OPENSSL_VERSION_NUMBER to 1.1.0 and atomically adds enough accessors for software with 1.1.0 support already. The hope is this will unblock hiding SSL_CTX and SSL_SESSION, which will be especially useful with C++-ficiation. The cost is we will hit some growing pains as more 1.1.0 consumers enter the ecosystem and we converge on the right set of APIs to import from upstream. It does not remove any 1.0.2 APIs, so we will not require that all projects support 1.1.0. The exception is APIs which changed in 1.1.0 but did not change the function signature. Those are breaking changes. Specifically: - SSL_CTX_sess_set_get_cb is now const-correct. - X509_get0_signature is now const-correct. For C++ consumers only, this change temporarily includes an overload hack for SSL_CTX_sess_set_get_cb that keeps the old callback working. This is a workaround for Node not yet supporting OpenSSL 1.1.0. The version number is set at (the as yet unreleased) 1.1.0g to denote that this change includes https://github.com/openssl/openssl/pull/4384. Bug: 91 Change-Id: I5eeb27448a6db4c25c244afac37f9604d9608a76 Reviewed-on: https://boringssl-review.googlesource.com/10340 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
8 년 전
Switch OPENSSL_VERSION_NUMBER to 1.1.0. Although we are derived from 1.0.2, we mimic 1.1.0 in some ways around our FOO_up_ref functions and opaque libssl types. This causes some difficulties when porting third-party code as any OPENSSL_VERSION_NUMBER checks for 1.1.0 APIs we have will be wrong. Moreover, adding accessors without changing OPENSSL_VERSION_NUMBER can break external projects. It is common to implement a compatibility version of an accessor under #ifdef as a static function. This then conflicts with our headers if we, unlike OpenSSL 1.0.2, have this function. This change switches OPENSSL_VERSION_NUMBER to 1.1.0 and atomically adds enough accessors for software with 1.1.0 support already. The hope is this will unblock hiding SSL_CTX and SSL_SESSION, which will be especially useful with C++-ficiation. The cost is we will hit some growing pains as more 1.1.0 consumers enter the ecosystem and we converge on the right set of APIs to import from upstream. It does not remove any 1.0.2 APIs, so we will not require that all projects support 1.1.0. The exception is APIs which changed in 1.1.0 but did not change the function signature. Those are breaking changes. Specifically: - SSL_CTX_sess_set_get_cb is now const-correct. - X509_get0_signature is now const-correct. For C++ consumers only, this change temporarily includes an overload hack for SSL_CTX_sess_set_get_cb that keeps the old callback working. This is a workaround for Node not yet supporting OpenSSL 1.1.0. The version number is set at (the as yet unreleased) 1.1.0g to denote that this change includes https://github.com/openssl/openssl/pull/4384. Bug: 91 Change-Id: I5eeb27448a6db4c25c244afac37f9604d9608a76 Reviewed-on: https://boringssl-review.googlesource.com/10340 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
8 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. # Porting from OpenSSL to BoringSSL
  2. BoringSSL is an OpenSSL derivative and is mostly source-compatible, for the
  3. subset of OpenSSL retained. Libraries ideally need little to no changes for
  4. BoringSSL support, provided they do not use removed APIs. In general, see if the
  5. library compiles and, on failure, consult the documentation in the header files
  6. and see if problematic features can be removed.
  7. BoringSSL's `OPENSSL_VERSION_NUMBER` matches the OpenSSL version it targets.
  8. Version checks for OpenSSL should ideally work as-is in BoringSSL. BoringSSL
  9. also defines upstream's `OPENSSL_NO_*` feature macros corresponding to removed
  10. features. If the preprocessor is needed, use these version checks or feature
  11. macros where possible, especially when patching third-party projects. Such
  12. patches are more generally useful to OpenSSL consumers and thus more
  13. appropriate to send upstream.
  14. In some cases, BoringSSL-specific code may be necessary. Use the
  15. `OPENSSL_IS_BORINGSSL` preprocessor macro in `#ifdef`s. However, first contact
  16. the BoringSSL maintainers about the missing APIs. We will typically add
  17. compatibility functions for convenience. In particular, *contact BoringSSL
  18. maintainers before working around missing OpenSSL 1.1.0 accessors*. BoringSSL
  19. was originally derived from OpenSSL 1.0.2 but now targets OpenSSL 1.1.0. Some
  20. newer APIs may be missing but can be added on request. (Not all projects have
  21. been ported to OpenSSL 1.1.0, so BoringSSL also remains largely compatible with
  22. OpenSSL 1.0.2.)
  23. The `OPENSSL_IS_BORINGSSL` macro may also be used to distinguish OpenSSL from
  24. BoringSSL in configure scripts. Do not use the presence or absence of particular
  25. symbols to detect BoringSSL.
  26. Note: BoringSSL does *not* have a stable API or ABI. It must be updated with its
  27. consumers. It is not suitable for, say, a system library in a traditional Linux
  28. distribution. For instance, Chromium statically links the specific revision of
  29. BoringSSL it was built against. Likewise, Android's system-internal copy of
  30. BoringSSL is not exposed by the NDK and must not be used by third-party
  31. applications.
  32. ## Major API changes
  33. ### Integer types
  34. Some APIs have been converted to use `size_t` for consistency and to avoid
  35. integer overflows at the API boundary. (Existing logic uses a mismash of `int`,
  36. `long`, and `unsigned`.) For the most part, implicit casts mean that existing
  37. code continues to compile. In some cases, this may require BoringSSL-specific
  38. code, particularly to avoid compiler warnings.
  39. Most notably, the `STACK_OF(T)` types have all been converted to use `size_t`
  40. instead of `int` for indices and lengths.
  41. ### Reference counts and opaque types
  42. Some external consumers increment reference counts directly by calling
  43. `CRYPTO_add` with the corresponding `CRYPTO_LOCK_*` value. These APIs no longer
  44. exist in BoringSSL. Instead, code which increments reference counts should call
  45. the corresponding `FOO_up_ref` function, such as `EVP_PKEY_up_ref`.
  46. BoringSSL also hides some structs which were previously exposed in OpenSSL
  47. 1.0.2, particularly in libssl. Use the relevant accessors instead.
  48. Note that some of these APIs were added in OpenSSL 1.1.0, so projects which do
  49. not yet support 1.1.0 may need additional `#ifdef`s. Projects supporting OpenSSL
  50. 1.1.0 should not require modification.
  51. ### Error codes
  52. OpenSSL's errors are extremely specific, leaking internals of the library,
  53. including even a function code for the function which emitted the error! As some
  54. logic in BoringSSL has been rewritten, code which conditions on the error may
  55. break (grep for `ERR_GET_REASON` and `ERR_GET_FUNC`). This danger also exists
  56. when upgrading OpenSSL versions.
  57. Where possible, avoid conditioning on the exact error reason. Otherwise, a
  58. BoringSSL `#ifdef` may be necessary. Exactly how best to resolve this issue is
  59. still being determined. It's possible some new APIs will be added in the future.
  60. Function codes have been completely removed. Remove code which conditions on
  61. these as it will break with the slightest change in the library, OpenSSL or
  62. BoringSSL.
  63. ### `*_ctrl` functions
  64. Some OpenSSL APIs are implemented with `ioctl`-style functions such as
  65. `SSL_ctrl` and `EVP_PKEY_CTX_ctrl`, combined with convenience macros, such as
  66. # define SSL_CTX_set_mode(ctx,op) \
  67. SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
  68. In BoringSSL, these macros have been replaced with proper functions. The
  69. underlying `_ctrl` functions have been removed.
  70. For convenience, `SSL_CTRL_*` values are retained as macros to `doesnt_exist` so
  71. existing code which uses them (or the wrapper macros) in `#ifdef` expressions
  72. will continue to function. However, the macros themselves will not work.
  73. Switch any `*_ctrl` callers to the macro/function versions. This works in both
  74. OpenSSL and BoringSSL. Note that BoringSSL's function versions will be
  75. type-checked and may require more care with types. See the end of this
  76. document for a table of functions to use.
  77. ### HMAC `EVP_PKEY`s
  78. `EVP_PKEY_HMAC` is removed. Use the `HMAC_*` functions in `hmac.h` instead. This
  79. is compatible with OpenSSL.
  80. ### DSA `EVP_PKEY`s
  81. `EVP_PKEY_DSA` is deprecated. It is currently still possible to parse DER into a
  82. DSA `EVP_PKEY`, but signing or verifying with those objects will not work.
  83. ### DES
  84. The `DES_cblock` type has been switched from an array to a struct to avoid the
  85. pitfalls around array types in C. Where features which require DES cannot be
  86. disabled, BoringSSL-specific codepaths may be necessary.
  87. ### TLS renegotiation
  88. OpenSSL enables TLS renegotiation by default and accepts renegotiation requests
  89. from the peer transparently. Renegotiation is an extremely problematic protocol
  90. feature, so BoringSSL rejects peer renegotiations by default.
  91. To enable renegotiation, call `SSL_set_renegotiate_mode` and set it to
  92. `ssl_renegotiate_once` or `ssl_renegotiate_freely`. Renegotiation is only
  93. supported as a client in TLS and the HelloRequest must be received at a
  94. quiet point in the application protocol. This is sufficient to support the
  95. common use of requesting a new client certificate between an HTTP request and
  96. response in (unpipelined) HTTP/1.1.
  97. Things which do not work:
  98. * There is no support for renegotiation as a server. (Attempts by clients will
  99. result in a fatal alert so that ClientHello messages cannot be used to flood
  100. a server and escape higher-level limits.)
  101. * There is no support for renegotiation in DTLS.
  102. * There is no support for initiating renegotiation; `SSL_renegotiate` always
  103. fails and `SSL_set_state` does nothing.
  104. * Interleaving application data with the new handshake is forbidden.
  105. * If a HelloRequest is received while `SSL_write` has unsent application data,
  106. the renegotiation is rejected.
  107. * Renegotiation does not participate in session resumption. The client will
  108. not offer a session on renegotiation or resume any session established by a
  109. renegotiation handshake.
  110. * The server may not change its certificate in the renegotiation. This mitigates
  111. the [triple handshake attack](https://mitls.org/pages/attacks/3SHAKE). Any new
  112. stapled OCSP response and SCT list will be ignored. As no authentication state
  113. may change, BoringSSL will not re-verify the certificate on a renegotiation.
  114. Callbacks such as `SSL_CTX_set_custom_verify` will only run on the initial
  115. handshake.
  116. ### Lowercase hexadecimal
  117. BoringSSL's `BN_bn2hex` function uses lowercase hexadecimal digits instead of
  118. uppercase. Some code may require changes to avoid being sensitive to this
  119. difference.
  120. ### Legacy ASN.1 functions
  121. OpenSSL's ASN.1 stack uses `d2i` functions for parsing. They have the form:
  122. RSA *d2i_RSAPrivateKey(RSA **out, const uint8_t **inp, long len);
  123. In addition to returning the result, OpenSSL places it in `*out` if `out` is
  124. not `NULL`. On input, if `*out` is not `NULL`, OpenSSL will usually (but not
  125. always) reuse that object rather than allocating a new one. In BoringSSL, these
  126. functions are compatibility wrappers over a newer ASN.1 stack. Even if `*out`
  127. is not `NULL`, these wrappers will always allocate a new object and free the
  128. previous one.
  129. Ensure that callers do not rely on this object reuse behavior. It is
  130. recommended to avoid the `out` parameter completely and always pass in `NULL`.
  131. Note that less error-prone APIs are available for BoringSSL-specific code (see
  132. below).
  133. ### Memory allocation
  134. OpenSSL provides wrappers `OPENSSL_malloc` and `OPENSSL_free` over the standard
  135. `malloc` and `free`. Memory allocated by OpenSSL should be released with
  136. `OPENSSL_free`, not the standard `free`. However, by default, they are
  137. implemented directly using `malloc` and `free`, so code which mixes them up
  138. usually works.
  139. In BoringSSL, these functions maintain additional book-keeping to zero memory
  140. on `OPENSSL_free`, so any mixups must be fixed.
  141. ## Optional BoringSSL-specific simplifications
  142. BoringSSL makes some changes to OpenSSL which simplify the API but remain
  143. compatible with OpenSSL consumers. In general, consult the BoringSSL
  144. documentation for any functions in new BoringSSL-only code.
  145. ### Return values
  146. Most OpenSSL APIs return 1 on success and either 0 or -1 on failure. BoringSSL
  147. has narrowed most of these to 1 on success and 0 on failure. BoringSSL-specific
  148. code may take advantage of the less error-prone APIs and use `!` to check for
  149. errors.
  150. ### Initialization
  151. OpenSSL has a number of different initialization functions for setting up error
  152. strings and loading algorithms, etc. All of these functions still exist in
  153. BoringSSL for convenience, but they do nothing and are not necessary.
  154. The one exception is `CRYPTO_library_init`. In `BORINGSSL_NO_STATIC_INITIALIZER`
  155. builds, it must be called to query CPU capabilities before the rest of the
  156. library. In the default configuration, this is done with a static initializer
  157. and is also unnecessary.
  158. ### Threading
  159. OpenSSL provides a number of APIs to configure threading callbacks and set up
  160. locks. Without initializing these, the library is not thread-safe. Configuring
  161. these does nothing in BoringSSL. Instead, BoringSSL calls pthreads and the
  162. corresponding Windows APIs internally and is always thread-safe where the API
  163. guarantees it.
  164. ### ASN.1
  165. BoringSSL is in the process of deprecating OpenSSL's `d2i` and `i2d` in favor of
  166. new functions using the much less error-prone `CBS` and `CBB` types.
  167. BoringSSL-only code should use those functions where available.
  168. ## Replacements for `CTRL` values
  169. When porting code which uses `SSL_CTX_ctrl` or `SSL_ctrl`, use the replacement
  170. functions below. If a function has both `SSL_CTX` and `SSL` variants, only the
  171. `SSL_CTX` version is listed.
  172. Note some values correspond to multiple functions depending on the `larg`
  173. parameter.
  174. `CTRL` value | Replacement function(s)
  175. -------------|-------------------------
  176. `DTLS_CTRL_GET_TIMEOUT` | `DTLSv1_get_timeout`
  177. `DTLS_CTRL_HANDLE_TIMEOUT` | `DTLSv1_handle_timeout`
  178. `SSL_CTRL_CHAIN` | `SSL_CTX_set0_chain` or `SSL_CTX_set1_chain`
  179. `SSL_CTRL_CHAIN_CERT` | `SSL_add0_chain_cert` or `SSL_add1_chain_cert`
  180. `SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS` | `SSL_CTX_clear_extra_chain_certs`
  181. `SSL_CTRL_CLEAR_MODE` | `SSL_CTX_clear_mode`
  182. `SSL_CTRL_CLEAR_OPTIONS` | `SSL_CTX_clear_options`
  183. `SSL_CTRL_EXTRA_CHAIN_CERT` | `SSL_CTX_add_extra_chain_cert`
  184. `SSL_CTRL_GET_CHAIN_CERTS` | `SSL_CTX_get0_chain_certs`
  185. `SSL_CTRL_GET_CLIENT_CERT_TYPES` | `SSL_get0_certificate_types`
  186. `SSL_CTRL_GET_EXTRA_CHAIN_CERTS` | `SSL_CTX_get_extra_chain_certs` or `SSL_CTX_get_extra_chain_certs_only`
  187. `SSL_CTRL_GET_MAX_CERT_LIST` | `SSL_CTX_get_max_cert_list`
  188. `SSL_CTRL_GET_NUM_RENEGOTIATIONS` | `SSL_num_renegotiations`
  189. `SSL_CTRL_GET_READ_AHEAD` | `SSL_CTX_get_read_ahead`
  190. `SSL_CTRL_GET_RI_SUPPORT` | `SSL_get_secure_renegotiation_support`
  191. `SSL_CTRL_GET_SESSION_REUSED` | `SSL_session_reused`
  192. `SSL_CTRL_GET_SESS_CACHE_MODE` | `SSL_CTX_get_session_cache_mode`
  193. `SSL_CTRL_GET_SESS_CACHE_SIZE` | `SSL_CTX_sess_get_cache_size`
  194. `SSL_CTRL_GET_TLSEXT_TICKET_KEYS` | `SSL_CTX_get_tlsext_ticket_keys`
  195. `SSL_CTRL_GET_TOTAL_RENEGOTIATIONS` | `SSL_total_renegotiations`
  196. `SSL_CTRL_MODE` | `SSL_CTX_get_mode` or `SSL_CTX_set_mode`
  197. `SSL_CTRL_NEED_TMP_RSA` | `SSL_CTX_need_tmp_RSA` is equivalent, but [*do not use this function*](https://freakattack.com/). (It is a no-op in BoringSSL.)
  198. `SSL_CTRL_OPTIONS` | `SSL_CTX_get_options` or `SSL_CTX_set_options`
  199. `SSL_CTRL_SESS_NUMBER` | `SSL_CTX_sess_number`
  200. `SSL_CTRL_SET_CURVES` | `SSL_CTX_set1_curves`
  201. `SSL_CTRL_SET_ECDH_AUTO` | `SSL_CTX_set_ecdh_auto`
  202. `SSL_CTRL_SET_MAX_CERT_LIST` | `SSL_CTX_set_max_cert_list`
  203. `SSL_CTRL_SET_MAX_SEND_FRAGMENT` | `SSL_CTX_set_max_send_fragment`
  204. `SSL_CTRL_SET_MSG_CALLBACK` | `SSL_set_msg_callback`
  205. `SSL_CTRL_SET_MSG_CALLBACK_ARG` | `SSL_set_msg_callback_arg`
  206. `SSL_CTRL_SET_MTU` | `SSL_set_mtu`
  207. `SSL_CTRL_SET_READ_AHEAD` | `SSL_CTX_set_read_ahead`
  208. `SSL_CTRL_SET_SESS_CACHE_MODE` | `SSL_CTX_set_session_cache_mode`
  209. `SSL_CTRL_SET_SESS_CACHE_SIZE` | `SSL_CTX_sess_set_cache_size`
  210. `SSL_CTRL_SET_TLSEXT_HOSTNAME` | `SSL_set_tlsext_host_name`
  211. `SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG` | `SSL_CTX_set_tlsext_servername_arg`
  212. `SSL_CTRL_SET_TLSEXT_SERVERNAME_CB` | `SSL_CTX_set_tlsext_servername_callback`
  213. `SSL_CTRL_SET_TLSEXT_TICKET_KEYS` | `SSL_CTX_set_tlsext_ticket_keys`
  214. `SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB` | `SSL_CTX_set_tlsext_ticket_key_cb`
  215. `SSL_CTRL_SET_TMP_DH` | `SSL_CTX_set_tmp_dh`
  216. `SSL_CTRL_SET_TMP_DH_CB` | `SSL_CTX_set_tmp_dh_callback`
  217. `SSL_CTRL_SET_TMP_ECDH` | `SSL_CTX_set_tmp_ecdh`
  218. `SSL_CTRL_SET_TMP_ECDH_CB` | `SSL_CTX_set_tmp_ecdh_callback`
  219. `SSL_CTRL_SET_TMP_RSA` | `SSL_CTX_set_tmp_rsa` is equivalent, but [*do not use this function*](https://freakattack.com/). (It is a no-op in BoringSSL.)
  220. `SSL_CTRL_SET_TMP_RSA_CB` | `SSL_CTX_set_tmp_rsa_callback` is equivalent, but [*do not use this function*](https://freakattack.com/). (It is a no-op in BoringSSL.)
  221. ## Significant API additions
  222. In some places, BoringSSL has added significant APIs. Use of these APIs goes beyound “porting” and means giving up on OpenSSL compatibility.
  223. One example of this has already been mentioned: the [CBS and CBB](https://commondatastorage.googleapis.com/chromium-boringssl-docs/bytestring.h.html) functions should be used whenever parsing or serialising data.
  224. ### CRYPTO\_BUFFER
  225. With the standard OpenSSL APIs, when making many TLS connections, the certificate data for each connection is retained in memory in an expensive `X509` structure. Additionally, common certificates often appear in the chains for multiple connections and are needlessly duplicated in memory.
  226. A [`CRYPTO_BUFFER`](https://commondatastorage.googleapis.com/chromium-boringssl-docs/pool.h.html) is just an opaque byte string. A `CRYPTO_BUFFER_POOL` is an intern table for these buffers, i.e. it ensures that only a single copy of any given byte string is kept for each pool.
  227. The function `TLS_with_buffers_method` returns an `SSL_METHOD` that avoids creating `X509` objects for certificates. Additionally, `SSL_CTX_set0_buffer_pool` can be used to install a pool on an `SSL_CTX` so that certificates can be deduplicated across connections and across `SSL_CTX`s.
  228. When using these functions, the application also needs to ensure that it doesn't call other functions that deal with `X509` or `X509_NAME` objects. For example, `SSL_get_peer_certificate` or `SSL_get_peer_cert_chain`. Doing so will trigger an assert in debug mode and will result in NULLs in release mode. Instead, call the buffer-based alternatives such as `SSL_get0_peer_certificates`. (See [ssl.h](https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html) for functions taking or returning `CRYPTO_BUFFER`.) The buffer-based alternative functions will work even when not using `TLS_with_buffers_method`, thus application code can transition gradually.
  229. In order to use buffers, the application code also needs to implement its own certificate verification using `SSL_[CTX_]set_custom_verify`. Otherwise all connections will fail with a verification error. Auto-chaining is also disabled when using buffers.
  230. Once those changes have been completed, the whole of the OpenSSL X.509 and ASN.1 code should be eliminated by the linker if BoringSSL is linked statically.
  231. ### Asynchronous and opaque private keys
  232. OpenSSL offers the ENGINE API for implementing opaque private keys (i.e. private keys where software only has oracle access because the secrets are held in special hardware or on another machine). While the ENGINE API has been mostly removed from BoringSSL, it is still possible to support opaque keys in this way. However, when using such keys with TLS and BoringSSL, you should strongly prefer using `SSL_PRIVATE_KEY_METHOD` via `SSL[_CTX]_set_private_key_method`. This allows a handshake to be suspended while the private operation is in progress. It also supports more forms of opaque key as it exposes higher-level information about the operation to be performed.