您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.] */
  56. #ifndef OPENSSL_HEADER_OBJ_H
  57. #define OPENSSL_HEADER_OBJ_H
  58. #include <openssl/base.h>
  59. #include <openssl/bytestring.h>
  60. #include <openssl/nid.h>
  61. #if defined(__cplusplus)
  62. extern "C" {
  63. #endif
  64. // The objects library deals with the registration and indexing of ASN.1 object
  65. // identifiers. These values are often written as a dotted sequence of numbers,
  66. // e.g. 1.2.840.113549.1.9.16.3.9.
  67. //
  68. // Internally, OpenSSL likes to deal with these values by numbering them with
  69. // numbers called "nids". OpenSSL has a large, built-in database of common
  70. // object identifiers and also has both short and long names for them.
  71. //
  72. // This library provides functions for translating between object identifiers,
  73. // nids, short names and long names.
  74. //
  75. // The nid values should not be used outside of a single process: they are not
  76. // stable identifiers.
  77. // Basic operations.
  78. // OBJ_dup returns a duplicate copy of |obj| or NULL on allocation failure.
  79. OPENSSL_EXPORT ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *obj);
  80. // OBJ_cmp returns a value less than, equal to or greater than zero if |a| is
  81. // less than, equal to or greater than |b|, respectively.
  82. OPENSSL_EXPORT int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
  83. // OBJ_get0_data returns a pointer to the DER representation of |obj|.
  84. OPENSSL_EXPORT const uint8_t *OBJ_get0_data(const ASN1_OBJECT *obj);
  85. // OBJ_length returns the length of the DER representation of |obj|.
  86. OPENSSL_EXPORT size_t OBJ_length(const ASN1_OBJECT *obj);
  87. // Looking up nids.
  88. // OBJ_obj2nid returns the nid corresponding to |obj|, or |NID_undef| if no
  89. // such object is known.
  90. OPENSSL_EXPORT int OBJ_obj2nid(const ASN1_OBJECT *obj);
  91. // OBJ_cbs2nid returns the nid corresponding to the DER data in |cbs|, or
  92. // |NID_undef| if no such object is known.
  93. OPENSSL_EXPORT int OBJ_cbs2nid(const CBS *cbs);
  94. // OBJ_sn2nid returns the nid corresponding to |short_name|, or |NID_undef| if
  95. // no such short name is known.
  96. OPENSSL_EXPORT int OBJ_sn2nid(const char *short_name);
  97. // OBJ_ln2nid returns the nid corresponding to |long_name|, or |NID_undef| if
  98. // no such long name is known.
  99. OPENSSL_EXPORT int OBJ_ln2nid(const char *long_name);
  100. // OBJ_txt2nid returns the nid corresponding to |s|, which may be a short name,
  101. // long name, or an ASCII string containing a dotted sequence of numbers. It
  102. // returns the nid or NID_undef if unknown.
  103. OPENSSL_EXPORT int OBJ_txt2nid(const char *s);
  104. // Getting information about nids.
  105. // OBJ_nid2obj returns the ASN1_OBJECT corresponding to |nid|, or NULL if |nid|
  106. // is unknown.
  107. OPENSSL_EXPORT const ASN1_OBJECT *OBJ_nid2obj(int nid);
  108. // OBJ_nid2sn returns the short name for |nid|, or NULL if |nid| is unknown.
  109. OPENSSL_EXPORT const char *OBJ_nid2sn(int nid);
  110. // OBJ_nid2ln returns the long name for |nid|, or NULL if |nid| is unknown.
  111. OPENSSL_EXPORT const char *OBJ_nid2ln(int nid);
  112. // OBJ_nid2cbb writes |nid| as an ASN.1 OBJECT IDENTIFIER to |out|. It returns
  113. // one on success or zero otherwise.
  114. OPENSSL_EXPORT int OBJ_nid2cbb(CBB *out, int nid);
  115. // Dealing with textual representations of object identifiers.
  116. // OBJ_txt2obj returns an ASN1_OBJECT for the textual representation in |s|.
  117. // If |dont_search_names| is zero, then |s| will be matched against the long
  118. // and short names of a known objects to find a match. Otherwise |s| must
  119. // contain an ASCII string with a dotted sequence of numbers. The resulting
  120. // object need not be previously known. It returns a freshly allocated
  121. // |ASN1_OBJECT| or NULL on error.
  122. OPENSSL_EXPORT ASN1_OBJECT *OBJ_txt2obj(const char *s, int dont_search_names);
  123. // OBJ_obj2txt converts |obj| to a textual representation. If
  124. // |always_return_oid| is zero then |obj| will be matched against known objects
  125. // and the long (preferably) or short name will be used if found. Otherwise
  126. // |obj| will be converted into a dotted sequence of integers. If |out| is not
  127. // NULL, then at most |out_len| bytes of the textual form will be written
  128. // there. If |out_len| is at least one, then string written to |out| will
  129. // always be NUL terminated. It returns the number of characters that could
  130. // have been written, not including the final NUL, or -1 on error.
  131. OPENSSL_EXPORT int OBJ_obj2txt(char *out, int out_len, const ASN1_OBJECT *obj,
  132. int always_return_oid);
  133. // Adding objects at runtime.
  134. // OBJ_create adds a known object and returns the nid of the new object, or
  135. // NID_undef on error.
  136. OPENSSL_EXPORT int OBJ_create(const char *oid, const char *short_name,
  137. const char *long_name);
  138. // Handling signature algorithm identifiers.
  139. //
  140. // Some NIDs (e.g. sha256WithRSAEncryption) specify both a digest algorithm and
  141. // a public key algorithm. The following functions map between pairs of digest
  142. // and public-key algorithms and the NIDs that specify their combination.
  143. //
  144. // Sometimes the combination NID leaves the digest unspecified (e.g.
  145. // rsassaPss). In these cases, the digest NID is |NID_undef|.
  146. // OBJ_find_sigid_algs finds the digest and public-key NIDs that correspond to
  147. // the signing algorithm |sign_nid|. If successful, it sets |*out_digest_nid|
  148. // and |*out_pkey_nid| and returns one. Otherwise it returns zero. Any of
  149. // |out_digest_nid| or |out_pkey_nid| can be NULL if the caller doesn't need
  150. // that output value.
  151. OPENSSL_EXPORT int OBJ_find_sigid_algs(int sign_nid, int *out_digest_nid,
  152. int *out_pkey_nid);
  153. // OBJ_find_sigid_by_algs finds the signature NID that corresponds to the
  154. // combination of |digest_nid| and |pkey_nid|. If success, it sets
  155. // |*out_sign_nid| and returns one. Otherwise it returns zero. The
  156. // |out_sign_nid| argument can be NULL if the caller only wishes to learn
  157. // whether the combination is valid.
  158. OPENSSL_EXPORT int OBJ_find_sigid_by_algs(int *out_sign_nid, int digest_nid,
  159. int pkey_nid);
  160. // Deprecated functions.
  161. typedef struct obj_name_st {
  162. int type;
  163. int alias;
  164. const char *name;
  165. const char *data;
  166. } OBJ_NAME;
  167. #define OBJ_NAME_TYPE_MD_METH 1
  168. #define OBJ_NAME_TYPE_CIPHER_METH 2
  169. // OBJ_NAME_do_all_sorted calls |callback| zero or more times, each time with
  170. // the name of a different primitive. If |type| is |OBJ_NAME_TYPE_MD_METH| then
  171. // the primitives will be hash functions, alternatively if |type| is
  172. // |OBJ_NAME_TYPE_CIPHER_METH| then the primitives will be ciphers or cipher
  173. // modes.
  174. //
  175. // This function is ill-specified and should never be used.
  176. OPENSSL_EXPORT void OBJ_NAME_do_all_sorted(
  177. int type, void (*callback)(const OBJ_NAME *, void *arg), void *arg);
  178. // OBJ_NAME_do_all calls |OBJ_NAME_do_all_sorted|.
  179. OPENSSL_EXPORT void OBJ_NAME_do_all(int type, void (*callback)(const OBJ_NAME *,
  180. void *arg),
  181. void *arg);
  182. // OBJ_cleanup does nothing.
  183. OPENSSL_EXPORT void OBJ_cleanup(void);
  184. #if defined(__cplusplus)
  185. } // extern C
  186. #endif
  187. #define OBJ_R_UNKNOWN_NID 100
  188. #define OBJ_R_INVALID_OID_STRING 101
  189. #endif // OPENSSL_HEADER_OBJ_H