grpc 0.12.0 → 0.13.0.pre1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (673) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +5707 -22222
  3. data/include/grpc/byte_buffer.h +2 -83
  4. data/include/grpc/census.h +191 -121
  5. data/include/grpc/compression.h +14 -38
  6. data/include/grpc/grpc.h +88 -434
  7. data/include/grpc/grpc_security.h +76 -46
  8. data/include/grpc/grpc_zookeeper.h +1 -1
  9. data/include/grpc/impl/codegen/alloc.h +74 -0
  10. data/include/grpc/impl/codegen/atm.h +92 -0
  11. data/include/grpc/impl/codegen/atm_gcc_atomic.h +72 -0
  12. data/include/grpc/impl/codegen/atm_gcc_sync.h +87 -0
  13. data/include/grpc/impl/codegen/atm_win32.h +125 -0
  14. data/include/grpc/impl/codegen/byte_buffer.h +121 -0
  15. data/include/grpc/impl/codegen/compression_types.h +73 -0
  16. data/include/grpc/impl/codegen/connectivity_state.h +59 -0
  17. data/include/grpc/impl/codegen/grpc_types.h +373 -0
  18. data/include/grpc/impl/codegen/log.h +110 -0
  19. data/include/grpc/impl/codegen/port_platform.h +362 -0
  20. data/include/grpc/impl/codegen/propagation_bits.h +67 -0
  21. data/include/grpc/impl/codegen/slice.h +182 -0
  22. data/include/grpc/impl/codegen/slice_buffer.h +105 -0
  23. data/include/grpc/impl/codegen/status.h +163 -0
  24. data/include/grpc/impl/codegen/sync.h +316 -0
  25. data/include/grpc/impl/codegen/sync_generic.h +55 -0
  26. data/{src/core/census/context.h → include/grpc/impl/codegen/sync_posix.h} +11 -11
  27. data/include/grpc/impl/codegen/sync_win32.h +49 -0
  28. data/include/grpc/impl/codegen/time.h +132 -0
  29. data/include/grpc/status.h +2 -126
  30. data/include/grpc/support/alloc.h +2 -35
  31. data/include/grpc/support/atm.h +2 -55
  32. data/include/grpc/support/atm_gcc_atomic.h +5 -38
  33. data/include/grpc/support/atm_gcc_sync.h +2 -50
  34. data/include/grpc/support/atm_win32.h +2 -88
  35. data/include/grpc/support/avl.h +7 -7
  36. data/include/grpc/support/cmdline.h +15 -13
  37. data/include/grpc/support/cpu.h +5 -3
  38. data/include/grpc/support/histogram.h +23 -20
  39. data/include/grpc/support/host_port.h +5 -3
  40. data/include/grpc/support/log.h +2 -71
  41. data/include/grpc/support/log_win32.h +2 -2
  42. data/include/grpc/support/port_platform.h +2 -319
  43. data/include/grpc/support/slice.h +2 -145
  44. data/include/grpc/support/slice_buffer.h +2 -65
  45. data/include/grpc/support/string_util.h +3 -3
  46. data/include/grpc/support/subprocess.h +8 -6
  47. data/include/grpc/support/sync.h +2 -278
  48. data/include/grpc/support/sync_generic.h +2 -18
  49. data/include/grpc/support/sync_posix.h +2 -10
  50. data/include/grpc/support/sync_win32.h +2 -12
  51. data/include/grpc/support/thd.h +11 -11
  52. data/include/grpc/support/time.h +2 -91
  53. data/include/grpc/support/tls.h +1 -1
  54. data/include/grpc/support/tls_gcc.h +1 -1
  55. data/include/grpc/support/tls_msvc.h +1 -1
  56. data/include/grpc/support/tls_pthread.h +2 -2
  57. data/src/boringssl/err_data.c +1252 -0
  58. data/src/core/census/context.c +492 -8
  59. data/src/core/census/grpc_filter.c +3 -3
  60. data/src/core/census/initialize.c +4 -7
  61. data/src/core/census/operation.c +2 -2
  62. data/src/core/census/placeholders.c +109 -0
  63. data/src/core/census/rpc_metric_id.h +6 -6
  64. data/src/core/census/tracing.c +1 -1
  65. data/src/core/channel/channel_args.c +4 -3
  66. data/src/core/channel/channel_stack.c +1 -1
  67. data/src/core/channel/client_channel.c +18 -14
  68. data/src/core/channel/client_uchannel.c +3 -3
  69. data/src/core/channel/compress_filter.c +8 -8
  70. data/src/core/channel/http_client_filter.c +2 -2
  71. data/src/core/channel/http_server_filter.c +9 -9
  72. data/src/core/channel/subchannel_call_holder.c +12 -10
  73. data/src/core/client_config/lb_policies/pick_first.c +49 -31
  74. data/src/core/client_config/lb_policies/round_robin.c +7 -7
  75. data/src/core/client_config/resolvers/dns_resolver.c +3 -3
  76. data/src/core/client_config/resolvers/sockaddr_resolver.c +5 -5
  77. data/src/core/client_config/subchannel.c +36 -25
  78. data/src/core/compression/algorithm.c +3 -3
  79. data/src/core/httpcli/format_request.c +1 -1
  80. data/src/core/httpcli/httpcli.c +5 -5
  81. data/src/core/httpcli/httpcli_security_connector.c +2 -3
  82. data/src/core/httpcli/parser.c +7 -7
  83. data/src/core/httpcli/parser.h +1 -1
  84. data/src/core/iomgr/closure.c +7 -7
  85. data/src/core/iomgr/closure.h +6 -5
  86. data/src/core/iomgr/exec_ctx.c +12 -8
  87. data/src/core/iomgr/exec_ctx.h +12 -5
  88. data/src/core/iomgr/executor.c +4 -4
  89. data/src/core/iomgr/executor.h +2 -2
  90. data/src/core/iomgr/fd_posix.c +28 -17
  91. data/src/core/iomgr/fd_posix.h +7 -4
  92. data/src/core/iomgr/iocp_windows.c +6 -8
  93. data/src/core/iomgr/pollset_multipoller_with_epoll.c +70 -5
  94. data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +4 -2
  95. data/src/core/iomgr/pollset_posix.c +15 -15
  96. data/src/core/iomgr/pollset_posix.h +4 -2
  97. data/src/core/iomgr/pollset_windows.c +3 -12
  98. data/src/core/iomgr/resolve_address_posix.c +2 -2
  99. data/src/core/iomgr/resolve_address_windows.c +2 -2
  100. data/src/core/iomgr/sockaddr_utils.c +6 -6
  101. data/src/core/iomgr/sockaddr_win32.h +1 -6
  102. data/src/core/iomgr/tcp_client_posix.c +7 -7
  103. data/src/core/iomgr/tcp_client_windows.c +4 -4
  104. data/src/core/iomgr/tcp_posix.c +14 -8
  105. data/src/core/iomgr/tcp_posix.h +7 -1
  106. data/src/core/iomgr/tcp_server.h +40 -20
  107. data/src/core/iomgr/tcp_server_posix.c +106 -49
  108. data/src/core/iomgr/tcp_server_windows.c +98 -49
  109. data/src/core/iomgr/tcp_windows.c +11 -15
  110. data/src/core/iomgr/timer.c +8 -8
  111. data/src/core/iomgr/timer.h +1 -1
  112. data/src/core/iomgr/timer_heap.c +10 -10
  113. data/src/core/iomgr/timer_heap.h +2 -2
  114. data/src/core/iomgr/udp_server.c +2 -12
  115. data/src/core/iomgr/udp_server.h +1 -9
  116. data/src/core/iomgr/workqueue.h +2 -4
  117. data/src/core/iomgr/workqueue_posix.c +3 -3
  118. data/src/core/json/json_reader.c +11 -12
  119. data/src/core/json/json_reader.h +4 -4
  120. data/src/core/json/json_string.c +19 -19
  121. data/src/core/json/json_writer.c +7 -9
  122. data/src/core/profiling/basic_timers.c +1 -1
  123. data/src/core/security/base64.c +9 -9
  124. data/src/core/security/client_auth_filter.c +4 -4
  125. data/src/core/security/credentials.c +5 -5
  126. data/src/core/security/google_default_credentials.c +3 -3
  127. data/src/core/security/handshake.c +6 -5
  128. data/src/core/security/json_token.c +13 -7
  129. data/src/core/security/jwt_verifier.c +3 -2
  130. data/src/core/security/secure_endpoint.c +16 -16
  131. data/src/core/security/security_connector.c +47 -17
  132. data/src/core/security/security_connector.h +5 -5
  133. data/src/core/security/server_auth_filter.c +3 -3
  134. data/src/core/security/server_secure_chttp2.c +30 -31
  135. data/src/core/statistics/census_interface.h +2 -2
  136. data/src/core/statistics/census_rpc_stats.h +3 -3
  137. data/src/core/support/alloc.c +1 -1
  138. data/src/core/support/cpu_posix.c +2 -2
  139. data/src/core/support/env_linux.c +12 -2
  140. data/src/core/support/env_win32.c +15 -7
  141. data/src/core/support/histogram.c +5 -5
  142. data/src/core/support/log_posix.c +1 -1
  143. data/src/core/support/log_win32.c +4 -3
  144. data/src/core/support/murmur_hash.c +11 -11
  145. data/src/core/support/murmur_hash.h +1 -1
  146. data/src/core/support/slice.c +11 -11
  147. data/src/core/support/slice_buffer.c +6 -6
  148. data/src/core/support/stack_lockfree.c +20 -10
  149. data/src/core/support/string.c +15 -15
  150. data/src/core/support/string.h +5 -5
  151. data/src/core/support/string_win32.c +5 -5
  152. data/src/core/support/subprocess_windows.c +141 -0
  153. data/src/core/support/sync.c +4 -4
  154. data/src/core/support/sync_posix.c +2 -2
  155. data/src/core/support/sync_win32.c +10 -5
  156. data/src/core/support/time.c +29 -29
  157. data/src/core/support/time_posix.c +15 -6
  158. data/src/core/support/time_precise.c +2 -2
  159. data/src/core/support/time_win32.c +18 -9
  160. data/src/core/support/tls_pthread.c +1 -1
  161. data/src/core/support/wrap_memcpy.c +53 -0
  162. data/src/core/surface/alarm.c +83 -0
  163. data/src/core/surface/byte_buffer_reader.c +1 -1
  164. data/src/core/surface/call.c +78 -69
  165. data/src/core/surface/call.h +2 -2
  166. data/src/core/surface/call_test_only.h +2 -2
  167. data/src/core/surface/channel.c +9 -9
  168. data/src/core/surface/channel.h +1 -1
  169. data/src/core/surface/channel_connectivity.c +3 -3
  170. data/src/core/surface/channel_create.c +3 -3
  171. data/src/core/surface/channel_ping.c +2 -2
  172. data/src/core/surface/completion_queue.c +11 -12
  173. data/src/core/surface/completion_queue.h +1 -1
  174. data/src/core/surface/init.c +7 -5
  175. data/src/core/surface/lame_client.c +3 -3
  176. data/src/core/surface/secure_channel_create.c +3 -3
  177. data/src/core/surface/server.c +28 -28
  178. data/src/core/surface/server_chttp2.c +8 -8
  179. data/src/core/surface/server_create.c +1 -4
  180. data/src/core/surface/validate_metadata.c +3 -3
  181. data/src/core/surface/version.c +2 -2
  182. data/src/core/transport/byte_stream.c +8 -6
  183. data/src/core/transport/byte_stream.h +6 -5
  184. data/src/core/transport/chttp2/bin_encoder.c +29 -29
  185. data/src/core/transport/chttp2/frame_data.c +29 -26
  186. data/src/core/transport/chttp2/frame_data.h +6 -6
  187. data/src/core/transport/chttp2/frame_goaway.c +30 -30
  188. data/src/core/transport/chttp2/frame_goaway.h +6 -6
  189. data/src/core/transport/chttp2/frame_ping.c +6 -6
  190. data/src/core/transport/chttp2/frame_ping.h +5 -5
  191. data/src/core/transport/chttp2/frame_rst_stream.c +18 -19
  192. data/src/core/transport/chttp2/frame_rst_stream.h +4 -4
  193. data/src/core/transport/chttp2/frame_settings.c +30 -30
  194. data/src/core/transport/chttp2/frame_settings.h +13 -13
  195. data/src/core/transport/chttp2/frame_window_update.c +17 -18
  196. data/src/core/transport/chttp2/frame_window_update.h +5 -7
  197. data/src/core/transport/chttp2/hpack_encoder.c +69 -73
  198. data/src/core/transport/chttp2/hpack_encoder.h +16 -16
  199. data/src/core/transport/chttp2/hpack_parser.c +167 -167
  200. data/src/core/transport/chttp2/hpack_parser.h +16 -16
  201. data/src/core/transport/chttp2/hpack_table.c +13 -13
  202. data/src/core/transport/chttp2/hpack_table.h +11 -11
  203. data/src/core/transport/chttp2/internal.h +97 -86
  204. data/src/core/transport/chttp2/parsing.c +25 -25
  205. data/src/core/transport/chttp2/stream_lists.c +26 -3
  206. data/src/core/transport/chttp2/stream_map.c +13 -14
  207. data/src/core/transport/chttp2/stream_map.h +6 -7
  208. data/src/core/transport/chttp2/timeout_encoding.c +19 -16
  209. data/src/core/transport/chttp2/varint.c +8 -9
  210. data/src/core/transport/chttp2/varint.h +7 -8
  211. data/src/core/transport/chttp2/writing.c +26 -23
  212. data/src/core/transport/chttp2_transport.c +133 -92
  213. data/src/core/transport/connectivity_state.c +6 -6
  214. data/src/core/transport/metadata.c +18 -18
  215. data/src/core/transport/metadata.h +5 -5
  216. data/src/core/transport/static_metadata.c +15 -16
  217. data/src/core/transport/static_metadata.h +5 -5
  218. data/src/core/transport/transport.c +5 -5
  219. data/src/core/transport/transport.h +14 -1
  220. data/src/core/tsi/fake_transport_security.c +7 -7
  221. data/src/core/tsi/ssl_transport_security.c +6 -4
  222. data/src/core/tsi/ssl_types.h +55 -0
  223. data/src/ruby/ext/grpc/extconf.rb +51 -14
  224. data/src/ruby/ext/grpc/rb_byte_buffer.c +3 -1
  225. data/src/ruby/ext/grpc/rb_call.c +6 -3
  226. data/src/ruby/ext/grpc/rb_call_credentials.c +4 -0
  227. data/src/ruby/ext/grpc/rb_channel.c +4 -2
  228. data/src/ruby/ext/grpc/rb_channel_args.c +3 -1
  229. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -1
  230. data/src/ruby/ext/grpc/rb_completion_queue.c +3 -1
  231. data/src/ruby/ext/grpc/rb_event_thread.c +5 -0
  232. data/src/ruby/ext/grpc/rb_grpc.c +11 -3
  233. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +560 -0
  234. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +843 -0
  235. data/src/ruby/ext/grpc/rb_loader.c +72 -0
  236. data/src/ruby/ext/grpc/rb_loader.h +40 -0
  237. data/src/ruby/ext/grpc/rb_server.c +3 -1
  238. data/src/ruby/ext/grpc/rb_server_credentials.c +4 -2
  239. data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
  240. data/src/ruby/lib/grpc/generic/rpc_desc.rb +1 -1
  241. data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
  242. data/src/ruby/lib/grpc/grpc.rb +34 -0
  243. data/src/ruby/lib/grpc/version.rb +1 -1
  244. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  245. data/third_party/boringssl/crypto/aes/aes.c +1142 -0
  246. data/third_party/boringssl/crypto/aes/internal.h +87 -0
  247. data/third_party/boringssl/crypto/aes/mode_wrappers.c +108 -0
  248. data/third_party/boringssl/crypto/asn1/a_bitstr.c +255 -0
  249. data/third_party/boringssl/crypto/asn1/a_bool.c +112 -0
  250. data/third_party/boringssl/crypto/asn1/a_bytes.c +317 -0
  251. data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +286 -0
  252. data/third_party/boringssl/crypto/asn1/a_dup.c +103 -0
  253. data/third_party/boringssl/crypto/asn1/a_enum.c +183 -0
  254. data/third_party/boringssl/crypto/asn1/a_gentm.c +255 -0
  255. data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +154 -0
  256. data/third_party/boringssl/crypto/asn1/a_int.c +456 -0
  257. data/third_party/boringssl/crypto/asn1/a_mbstr.c +390 -0
  258. data/third_party/boringssl/crypto/asn1/a_object.c +412 -0
  259. data/third_party/boringssl/crypto/asn1/a_octet.c +70 -0
  260. data/third_party/boringssl/crypto/asn1/a_print.c +119 -0
  261. data/third_party/boringssl/crypto/asn1/a_strnid.c +286 -0
  262. data/third_party/boringssl/crypto/asn1/a_time.c +221 -0
  263. data/third_party/boringssl/crypto/asn1/a_type.c +160 -0
  264. data/third_party/boringssl/crypto/asn1/a_utctm.c +342 -0
  265. data/third_party/boringssl/crypto/asn1/a_utf8.c +210 -0
  266. data/third_party/boringssl/crypto/asn1/asn1_lib.c +510 -0
  267. data/third_party/boringssl/crypto/asn1/asn1_locl.h +73 -0
  268. data/third_party/boringssl/crypto/asn1/asn1_par.c +444 -0
  269. data/third_party/boringssl/crypto/asn1/asn_pack.c +104 -0
  270. data/third_party/boringssl/crypto/asn1/bio_asn1.c +496 -0
  271. data/third_party/boringssl/crypto/asn1/bio_ndef.c +254 -0
  272. data/third_party/boringssl/crypto/asn1/f_enum.c +206 -0
  273. data/third_party/boringssl/crypto/asn1/f_int.c +210 -0
  274. data/third_party/boringssl/crypto/asn1/f_string.c +204 -0
  275. data/third_party/boringssl/crypto/asn1/t_bitst.c +102 -0
  276. data/third_party/boringssl/crypto/asn1/t_pkey.c +112 -0
  277. data/third_party/boringssl/crypto/asn1/tasn_dec.c +1342 -0
  278. data/third_party/boringssl/crypto/asn1/tasn_enc.c +695 -0
  279. data/third_party/boringssl/crypto/asn1/tasn_fre.c +264 -0
  280. data/third_party/boringssl/crypto/asn1/tasn_new.c +398 -0
  281. data/third_party/boringssl/crypto/asn1/tasn_prn.c +642 -0
  282. data/third_party/boringssl/crypto/asn1/tasn_typ.c +137 -0
  283. data/third_party/boringssl/crypto/asn1/tasn_utl.c +266 -0
  284. data/third_party/boringssl/crypto/asn1/x_bignum.c +143 -0
  285. data/third_party/boringssl/crypto/asn1/x_long.c +182 -0
  286. data/third_party/boringssl/crypto/base64/base64.c +478 -0
  287. data/third_party/boringssl/crypto/bio/bio.c +608 -0
  288. data/third_party/boringssl/crypto/bio/bio_mem.c +327 -0
  289. data/third_party/boringssl/crypto/bio/buffer.c +496 -0
  290. data/third_party/boringssl/crypto/bio/connect.c +544 -0
  291. data/third_party/boringssl/crypto/bio/fd.c +270 -0
  292. data/third_party/boringssl/crypto/bio/file.c +349 -0
  293. data/third_party/boringssl/crypto/bio/hexdump.c +192 -0
  294. data/third_party/boringssl/crypto/bio/internal.h +108 -0
  295. data/third_party/boringssl/crypto/bio/pair.c +803 -0
  296. data/third_party/boringssl/crypto/bio/printf.c +119 -0
  297. data/third_party/boringssl/crypto/bio/socket.c +195 -0
  298. data/third_party/boringssl/crypto/bio/socket_helper.c +113 -0
  299. data/third_party/boringssl/crypto/bn/add.c +377 -0
  300. data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +599 -0
  301. data/third_party/boringssl/crypto/bn/bn.c +341 -0
  302. data/third_party/boringssl/crypto/bn/bn_asn1.c +93 -0
  303. data/third_party/boringssl/crypto/bn/cmp.c +200 -0
  304. data/third_party/boringssl/crypto/bn/convert.c +597 -0
  305. data/third_party/boringssl/crypto/bn/ctx.c +311 -0
  306. data/third_party/boringssl/crypto/bn/div.c +625 -0
  307. data/third_party/boringssl/crypto/bn/exponentiation.c +1544 -0
  308. data/third_party/boringssl/crypto/bn/gcd.c +711 -0
  309. data/third_party/boringssl/crypto/bn/generic.c +1019 -0
  310. data/third_party/boringssl/crypto/bn/internal.h +294 -0
  311. data/third_party/boringssl/crypto/bn/kronecker.c +175 -0
  312. data/third_party/boringssl/crypto/bn/montgomery.c +561 -0
  313. data/third_party/boringssl/crypto/bn/mul.c +888 -0
  314. data/third_party/boringssl/crypto/bn/prime.c +845 -0
  315. data/third_party/boringssl/crypto/bn/random.c +326 -0
  316. data/third_party/boringssl/crypto/bn/rsaz_exp.c +326 -0
  317. data/third_party/boringssl/crypto/bn/rsaz_exp.h +56 -0
  318. data/third_party/boringssl/crypto/bn/shift.c +299 -0
  319. data/third_party/boringssl/crypto/bn/sqrt.c +505 -0
  320. data/third_party/boringssl/crypto/buf/buf.c +235 -0
  321. data/third_party/boringssl/crypto/bytestring/ber.c +221 -0
  322. data/third_party/boringssl/crypto/bytestring/cbb.c +411 -0
  323. data/third_party/boringssl/crypto/bytestring/cbs.c +415 -0
  324. data/third_party/boringssl/crypto/bytestring/internal.h +46 -0
  325. data/third_party/boringssl/crypto/chacha/chacha_generic.c +140 -0
  326. data/third_party/boringssl/crypto/chacha/chacha_vec.c +323 -0
  327. data/third_party/boringssl/crypto/cipher/aead.c +167 -0
  328. data/third_party/boringssl/crypto/cipher/cipher.c +652 -0
  329. data/third_party/boringssl/crypto/cipher/derive_key.c +154 -0
  330. data/third_party/boringssl/crypto/cipher/e_aes.c +1767 -0
  331. data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +311 -0
  332. data/third_party/boringssl/crypto/cipher/e_des.c +207 -0
  333. data/third_party/boringssl/crypto/cipher/e_null.c +85 -0
  334. data/third_party/boringssl/crypto/cipher/e_rc2.c +443 -0
  335. data/third_party/boringssl/crypto/cipher/e_rc4.c +87 -0
  336. data/third_party/boringssl/crypto/cipher/e_ssl3.c +463 -0
  337. data/third_party/boringssl/crypto/cipher/e_tls.c +673 -0
  338. data/third_party/boringssl/crypto/cipher/internal.h +164 -0
  339. data/third_party/boringssl/crypto/cipher/tls_cbc.c +495 -0
  340. data/third_party/boringssl/crypto/cmac/cmac.c +239 -0
  341. data/third_party/boringssl/crypto/conf/conf.c +778 -0
  342. data/third_party/boringssl/crypto/conf/conf_def.h +127 -0
  343. data/third_party/boringssl/crypto/conf/internal.h +31 -0
  344. data/third_party/boringssl/crypto/cpu-arm.c +199 -0
  345. data/third_party/boringssl/crypto/cpu-intel.c +261 -0
  346. data/third_party/boringssl/crypto/crypto.c +140 -0
  347. data/third_party/boringssl/crypto/curve25519/curve25519.c +4897 -0
  348. data/third_party/boringssl/crypto/des/des.c +771 -0
  349. data/third_party/boringssl/crypto/des/internal.h +212 -0
  350. data/third_party/boringssl/crypto/dh/check.c +180 -0
  351. data/third_party/boringssl/crypto/dh/dh.c +463 -0
  352. data/third_party/boringssl/crypto/dh/dh_asn1.c +84 -0
  353. data/third_party/boringssl/crypto/dh/internal.h +80 -0
  354. data/third_party/boringssl/crypto/dh/params.c +301 -0
  355. data/third_party/boringssl/crypto/digest/digest.c +248 -0
  356. data/third_party/boringssl/crypto/digest/digests.c +321 -0
  357. data/third_party/boringssl/crypto/digest/internal.h +112 -0
  358. data/third_party/boringssl/crypto/digest/md32_common.h +322 -0
  359. data/third_party/boringssl/crypto/directory.h +66 -0
  360. data/third_party/boringssl/crypto/directory_posix.c +108 -0
  361. data/third_party/boringssl/crypto/directory_win.c +144 -0
  362. data/third_party/boringssl/crypto/dsa/dsa.c +908 -0
  363. data/third_party/boringssl/crypto/dsa/dsa_asn1.c +150 -0
  364. data/third_party/boringssl/crypto/dsa/internal.h +78 -0
  365. data/third_party/boringssl/crypto/ec/ec.c +889 -0
  366. data/third_party/boringssl/crypto/ec/ec_asn1.c +586 -0
  367. data/third_party/boringssl/crypto/ec/ec_key.c +482 -0
  368. data/third_party/boringssl/crypto/ec/ec_montgomery.c +280 -0
  369. data/third_party/boringssl/crypto/ec/internal.h +318 -0
  370. data/third_party/boringssl/crypto/ec/oct.c +416 -0
  371. data/third_party/boringssl/crypto/ec/p224-64.c +1305 -0
  372. data/third_party/boringssl/crypto/ec/p256-64.c +1878 -0
  373. data/third_party/boringssl/crypto/ec/p256-x86_64-table.h +9548 -0
  374. data/third_party/boringssl/crypto/ec/p256-x86_64.c +596 -0
  375. data/third_party/boringssl/crypto/ec/simple.c +1313 -0
  376. data/third_party/boringssl/crypto/ec/util-64.c +183 -0
  377. data/third_party/boringssl/crypto/ec/wnaf.c +449 -0
  378. data/third_party/boringssl/crypto/ecdh/ecdh.c +153 -0
  379. data/third_party/boringssl/crypto/ecdsa/ecdsa.c +496 -0
  380. data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +240 -0
  381. data/third_party/boringssl/crypto/engine/engine.c +96 -0
  382. data/third_party/boringssl/crypto/err/err.c +756 -0
  383. data/third_party/boringssl/crypto/evp/algorithm.c +153 -0
  384. data/third_party/boringssl/crypto/evp/digestsign.c +159 -0
  385. data/third_party/boringssl/crypto/evp/evp.c +411 -0
  386. data/third_party/boringssl/crypto/evp/evp_asn1.c +179 -0
  387. data/third_party/boringssl/crypto/evp/evp_ctx.c +477 -0
  388. data/third_party/boringssl/crypto/evp/internal.h +278 -0
  389. data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +588 -0
  390. data/third_party/boringssl/crypto/evp/p_ec.c +283 -0
  391. data/third_party/boringssl/crypto/evp/p_ec_asn1.c +562 -0
  392. data/third_party/boringssl/crypto/evp/p_rsa.c +596 -0
  393. data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +737 -0
  394. data/third_party/boringssl/crypto/evp/pbkdf.c +151 -0
  395. data/third_party/boringssl/crypto/evp/sign.c +151 -0
  396. data/third_party/boringssl/crypto/ex_data.c +294 -0
  397. data/third_party/boringssl/crypto/hkdf/hkdf.c +89 -0
  398. data/third_party/boringssl/crypto/hmac/hmac.c +213 -0
  399. data/third_party/boringssl/crypto/internal.h +532 -0
  400. data/third_party/boringssl/crypto/lhash/lhash.c +346 -0
  401. data/third_party/boringssl/crypto/md4/md4.c +225 -0
  402. data/third_party/boringssl/crypto/md5/md5.c +275 -0
  403. data/third_party/boringssl/crypto/mem.c +200 -0
  404. data/third_party/boringssl/crypto/modes/cbc.c +216 -0
  405. data/third_party/boringssl/crypto/modes/cfb.c +231 -0
  406. data/third_party/boringssl/crypto/modes/ctr.c +226 -0
  407. data/third_party/boringssl/crypto/modes/gcm.c +1252 -0
  408. data/third_party/boringssl/crypto/modes/internal.h +370 -0
  409. data/third_party/boringssl/crypto/modes/ofb.c +108 -0
  410. data/third_party/boringssl/crypto/obj/obj.c +664 -0
  411. data/third_party/boringssl/crypto/obj/obj_dat.h +5257 -0
  412. data/third_party/boringssl/crypto/obj/obj_xref.c +124 -0
  413. data/third_party/boringssl/crypto/obj/obj_xref.h +96 -0
  414. data/third_party/boringssl/crypto/pem/pem_all.c +281 -0
  415. data/third_party/boringssl/crypto/pem/pem_info.c +404 -0
  416. data/third_party/boringssl/crypto/pem/pem_lib.c +835 -0
  417. data/third_party/boringssl/crypto/pem/pem_oth.c +89 -0
  418. data/third_party/boringssl/crypto/pem/pem_pk8.c +244 -0
  419. data/third_party/boringssl/crypto/pem/pem_pkey.c +312 -0
  420. data/third_party/boringssl/crypto/pem/pem_x509.c +65 -0
  421. data/third_party/boringssl/crypto/pem/pem_xaux.c +66 -0
  422. data/third_party/boringssl/crypto/pkcs8/internal.h +83 -0
  423. data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +150 -0
  424. data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +440 -0
  425. data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +85 -0
  426. data/third_party/boringssl/crypto/pkcs8/pkcs8.c +1217 -0
  427. data/third_party/boringssl/crypto/poly1305/poly1305.c +331 -0
  428. data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +301 -0
  429. data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +892 -0
  430. data/third_party/boringssl/crypto/rand/internal.h +32 -0
  431. data/third_party/boringssl/crypto/rand/rand.c +239 -0
  432. data/third_party/boringssl/crypto/rand/urandom.c +223 -0
  433. data/third_party/boringssl/crypto/rand/windows.c +56 -0
  434. data/third_party/boringssl/crypto/rc4/rc4.c +283 -0
  435. data/third_party/boringssl/crypto/refcount_c11.c +67 -0
  436. data/third_party/boringssl/crypto/refcount_lock.c +53 -0
  437. data/third_party/boringssl/crypto/rsa/blinding.c +462 -0
  438. data/third_party/boringssl/crypto/rsa/internal.h +164 -0
  439. data/third_party/boringssl/crypto/rsa/padding.c +711 -0
  440. data/third_party/boringssl/crypto/rsa/rsa.c +808 -0
  441. data/third_party/boringssl/crypto/rsa/rsa_asn1.c +473 -0
  442. data/third_party/boringssl/crypto/rsa/rsa_impl.c +1138 -0
  443. data/third_party/boringssl/crypto/sha/sha1.c +337 -0
  444. data/third_party/boringssl/crypto/sha/sha256.c +327 -0
  445. data/third_party/boringssl/crypto/sha/sha512.c +607 -0
  446. data/third_party/boringssl/crypto/stack/stack.c +386 -0
  447. data/third_party/boringssl/crypto/test/scoped_types.h +137 -0
  448. data/third_party/boringssl/crypto/test/test_util.h +35 -0
  449. data/third_party/boringssl/crypto/thread.c +101 -0
  450. data/third_party/boringssl/crypto/thread_none.c +55 -0
  451. data/third_party/boringssl/crypto/thread_pthread.c +167 -0
  452. data/third_party/boringssl/crypto/thread_win.c +282 -0
  453. data/third_party/boringssl/crypto/time_support.c +212 -0
  454. data/third_party/boringssl/crypto/x509/a_digest.c +97 -0
  455. data/third_party/boringssl/crypto/x509/a_sign.c +136 -0
  456. data/third_party/boringssl/crypto/x509/a_strex.c +564 -0
  457. data/third_party/boringssl/crypto/x509/a_verify.c +133 -0
  458. data/third_party/boringssl/crypto/x509/asn1_gen.c +873 -0
  459. data/third_party/boringssl/crypto/x509/by_dir.c +491 -0
  460. data/third_party/boringssl/crypto/x509/by_file.c +295 -0
  461. data/third_party/boringssl/crypto/x509/charmap.h +15 -0
  462. data/third_party/boringssl/crypto/x509/i2d_pr.c +84 -0
  463. data/third_party/boringssl/crypto/x509/pkcs7.c +353 -0
  464. data/third_party/boringssl/crypto/x509/t_crl.c +129 -0
  465. data/third_party/boringssl/crypto/x509/t_req.c +246 -0
  466. data/third_party/boringssl/crypto/x509/t_x509.c +500 -0
  467. data/third_party/boringssl/crypto/x509/t_x509a.c +109 -0
  468. data/third_party/boringssl/crypto/x509/vpm_int.h +70 -0
  469. data/third_party/boringssl/crypto/x509/x509.c +152 -0
  470. data/third_party/boringssl/crypto/x509/x509_att.c +353 -0
  471. data/third_party/boringssl/crypto/x509/x509_cmp.c +490 -0
  472. data/third_party/boringssl/crypto/x509/x509_d2.c +105 -0
  473. data/third_party/boringssl/crypto/x509/x509_def.c +88 -0
  474. data/third_party/boringssl/crypto/x509/x509_ext.c +206 -0
  475. data/third_party/boringssl/crypto/x509/x509_lu.c +738 -0
  476. data/third_party/boringssl/crypto/x509/x509_obj.c +191 -0
  477. data/third_party/boringssl/crypto/x509/x509_r2x.c +113 -0
  478. data/third_party/boringssl/crypto/x509/x509_req.c +315 -0
  479. data/third_party/boringssl/crypto/x509/x509_set.c +154 -0
  480. data/third_party/boringssl/crypto/x509/x509_trs.c +304 -0
  481. data/third_party/boringssl/crypto/x509/x509_txt.c +209 -0
  482. data/third_party/boringssl/crypto/x509/x509_v3.c +271 -0
  483. data/third_party/boringssl/crypto/x509/x509_vfy.c +2456 -0
  484. data/third_party/boringssl/crypto/x509/x509_vpm.c +672 -0
  485. data/third_party/boringssl/crypto/x509/x509cset.c +172 -0
  486. data/third_party/boringssl/crypto/x509/x509name.c +381 -0
  487. data/third_party/boringssl/crypto/x509/x509rset.c +80 -0
  488. data/third_party/boringssl/crypto/x509/x509spki.c +135 -0
  489. data/third_party/boringssl/crypto/x509/x509type.c +128 -0
  490. data/third_party/boringssl/crypto/x509/x_algor.c +154 -0
  491. data/third_party/boringssl/crypto/x509/x_all.c +547 -0
  492. data/third_party/boringssl/crypto/x509/x_attrib.c +117 -0
  493. data/third_party/boringssl/crypto/x509/x_crl.c +560 -0
  494. data/third_party/boringssl/crypto/x509/x_exten.c +75 -0
  495. data/third_party/boringssl/crypto/x509/x_info.c +95 -0
  496. data/third_party/boringssl/crypto/x509/x_name.c +538 -0
  497. data/third_party/boringssl/crypto/x509/x_pkey.c +100 -0
  498. data/third_party/boringssl/crypto/x509/x_pubkey.c +384 -0
  499. data/third_party/boringssl/crypto/x509/x_req.c +112 -0
  500. data/third_party/boringssl/crypto/x509/x_sig.c +69 -0
  501. data/third_party/boringssl/crypto/x509/x_spki.c +78 -0
  502. data/third_party/boringssl/crypto/x509/x_val.c +69 -0
  503. data/third_party/boringssl/crypto/x509/x_x509.c +227 -0
  504. data/third_party/boringssl/crypto/x509/x_x509a.c +197 -0
  505. data/third_party/boringssl/crypto/x509v3/ext_dat.h +129 -0
  506. data/third_party/boringssl/crypto/x509v3/pcy_cache.c +299 -0
  507. data/third_party/boringssl/crypto/x509v3/pcy_data.c +137 -0
  508. data/third_party/boringssl/crypto/x509v3/pcy_int.h +212 -0
  509. data/third_party/boringssl/crypto/x509v3/pcy_lib.c +165 -0
  510. data/third_party/boringssl/crypto/x509v3/pcy_map.c +133 -0
  511. data/third_party/boringssl/crypto/x509v3/pcy_node.c +197 -0
  512. data/third_party/boringssl/crypto/x509v3/pcy_tree.c +876 -0
  513. data/third_party/boringssl/crypto/x509v3/v3_akey.c +212 -0
  514. data/third_party/boringssl/crypto/x509v3/v3_akeya.c +71 -0
  515. data/third_party/boringssl/crypto/x509v3/v3_alt.c +622 -0
  516. data/third_party/boringssl/crypto/x509v3/v3_bcons.c +126 -0
  517. data/third_party/boringssl/crypto/x509v3/v3_bitst.c +141 -0
  518. data/third_party/boringssl/crypto/x509v3/v3_conf.c +459 -0
  519. data/third_party/boringssl/crypto/x509v3/v3_cpols.c +475 -0
  520. data/third_party/boringssl/crypto/x509v3/v3_crld.c +616 -0
  521. data/third_party/boringssl/crypto/x509v3/v3_enum.c +98 -0
  522. data/third_party/boringssl/crypto/x509v3/v3_extku.c +145 -0
  523. data/third_party/boringssl/crypto/x509v3/v3_genn.c +252 -0
  524. data/third_party/boringssl/crypto/x509v3/v3_ia5.c +117 -0
  525. data/third_party/boringssl/crypto/x509v3/v3_info.c +200 -0
  526. data/third_party/boringssl/crypto/x509v3/v3_int.c +87 -0
  527. data/third_party/boringssl/crypto/x509v3/v3_lib.c +335 -0
  528. data/third_party/boringssl/crypto/x509v3/v3_ncons.c +510 -0
  529. data/third_party/boringssl/crypto/x509v3/v3_pci.c +335 -0
  530. data/third_party/boringssl/crypto/x509v3/v3_pcia.c +56 -0
  531. data/third_party/boringssl/crypto/x509v3/v3_pcons.c +142 -0
  532. data/third_party/boringssl/crypto/x509v3/v3_pku.c +109 -0
  533. data/third_party/boringssl/crypto/x509v3/v3_pmaps.c +156 -0
  534. data/third_party/boringssl/crypto/x509v3/v3_prn.c +207 -0
  535. data/third_party/boringssl/crypto/x509v3/v3_purp.c +805 -0
  536. data/third_party/boringssl/crypto/x509v3/v3_skey.c +148 -0
  537. data/third_party/boringssl/crypto/x509v3/v3_sxnet.c +266 -0
  538. data/third_party/boringssl/crypto/x509v3/v3_utl.c +1322 -0
  539. data/third_party/boringssl/include/openssl/aead.h +346 -0
  540. data/third_party/boringssl/include/openssl/aes.h +158 -0
  541. data/third_party/boringssl/include/openssl/arm_arch.h +127 -0
  542. data/third_party/boringssl/include/openssl/asn1.h +1168 -0
  543. data/third_party/boringssl/include/openssl/asn1_mac.h +75 -0
  544. data/third_party/boringssl/include/openssl/asn1t.h +906 -0
  545. data/third_party/boringssl/include/openssl/base.h +261 -0
  546. data/third_party/boringssl/include/openssl/base64.h +184 -0
  547. data/third_party/boringssl/include/openssl/bio.h +902 -0
  548. data/third_party/boringssl/include/openssl/blowfish.h +93 -0
  549. data/third_party/boringssl/include/openssl/bn.h +885 -0
  550. data/third_party/boringssl/include/openssl/buf.h +118 -0
  551. data/third_party/boringssl/include/openssl/buffer.h +18 -0
  552. data/third_party/boringssl/include/openssl/bytestring.h +360 -0
  553. data/third_party/boringssl/include/openssl/cast.h +96 -0
  554. data/third_party/boringssl/include/openssl/chacha.h +37 -0
  555. data/third_party/boringssl/include/openssl/cipher.h +571 -0
  556. data/third_party/boringssl/include/openssl/cmac.h +76 -0
  557. data/third_party/boringssl/include/openssl/conf.h +145 -0
  558. data/third_party/boringssl/include/openssl/cpu.h +184 -0
  559. data/third_party/boringssl/include/openssl/crypto.h +68 -0
  560. data/third_party/boringssl/include/openssl/curve25519.h +88 -0
  561. data/third_party/boringssl/include/openssl/des.h +177 -0
  562. data/third_party/boringssl/include/openssl/dh.h +238 -0
  563. data/third_party/boringssl/include/openssl/digest.h +258 -0
  564. data/third_party/boringssl/include/openssl/dsa.h +343 -0
  565. data/third_party/boringssl/include/openssl/dtls1.h +16 -0
  566. data/third_party/boringssl/include/openssl/ec.h +355 -0
  567. data/third_party/boringssl/include/openssl/ec_key.h +280 -0
  568. data/third_party/boringssl/include/openssl/ecdh.h +102 -0
  569. data/third_party/boringssl/include/openssl/ecdsa.h +206 -0
  570. data/third_party/boringssl/include/openssl/engine.h +98 -0
  571. data/third_party/boringssl/include/openssl/err.h +487 -0
  572. data/third_party/boringssl/include/openssl/evp.h +750 -0
  573. data/third_party/boringssl/include/openssl/ex_data.h +213 -0
  574. data/third_party/boringssl/include/openssl/hkdf.h +44 -0
  575. data/third_party/boringssl/include/openssl/hmac.h +160 -0
  576. data/third_party/boringssl/include/openssl/lhash.h +192 -0
  577. data/third_party/boringssl/include/openssl/lhash_macros.h +132 -0
  578. data/third_party/boringssl/include/openssl/md4.h +102 -0
  579. data/third_party/boringssl/include/openssl/md5.h +107 -0
  580. data/third_party/boringssl/include/openssl/mem.h +140 -0
  581. data/third_party/boringssl/include/openssl/obj.h +198 -0
  582. data/third_party/boringssl/include/openssl/obj_mac.h +4140 -0
  583. data/third_party/boringssl/include/openssl/objects.h +18 -0
  584. data/third_party/boringssl/include/openssl/opensslfeatures.h +60 -0
  585. data/third_party/boringssl/include/openssl/opensslv.h +18 -0
  586. data/third_party/boringssl/include/openssl/ossl_typ.h +18 -0
  587. data/third_party/boringssl/include/openssl/pem.h +521 -0
  588. data/third_party/boringssl/include/openssl/pkcs12.h +18 -0
  589. data/third_party/boringssl/include/openssl/pkcs7.h +16 -0
  590. data/third_party/boringssl/include/openssl/pkcs8.h +220 -0
  591. data/third_party/boringssl/include/openssl/poly1305.h +51 -0
  592. data/third_party/boringssl/include/openssl/pqueue.h +146 -0
  593. data/third_party/boringssl/include/openssl/rand.h +113 -0
  594. data/third_party/boringssl/include/openssl/rc4.h +90 -0
  595. data/third_party/boringssl/include/openssl/rsa.h +637 -0
  596. data/third_party/boringssl/include/openssl/safestack.h +16 -0
  597. data/third_party/boringssl/include/openssl/sha.h +256 -0
  598. data/third_party/boringssl/include/openssl/srtp.h +18 -0
  599. data/third_party/boringssl/include/openssl/ssl.h +4466 -0
  600. data/third_party/boringssl/include/openssl/ssl3.h +441 -0
  601. data/third_party/boringssl/include/openssl/stack.h +298 -0
  602. data/third_party/boringssl/include/openssl/stack_macros.h +4190 -0
  603. data/third_party/boringssl/include/openssl/thread.h +173 -0
  604. data/third_party/boringssl/include/openssl/time_support.h +90 -0
  605. data/third_party/boringssl/include/openssl/tls1.h +653 -0
  606. data/third_party/boringssl/include/openssl/type_check.h +91 -0
  607. data/third_party/boringssl/include/openssl/x509.h +1258 -0
  608. data/third_party/boringssl/include/openssl/x509_vfy.h +611 -0
  609. data/third_party/boringssl/include/openssl/x509v3.h +798 -0
  610. data/third_party/boringssl/ssl/custom_extensions.c +257 -0
  611. data/third_party/boringssl/ssl/d1_both.c +880 -0
  612. data/third_party/boringssl/ssl/d1_clnt.c +566 -0
  613. data/third_party/boringssl/ssl/d1_lib.c +340 -0
  614. data/third_party/boringssl/ssl/d1_meth.c +130 -0
  615. data/third_party/boringssl/ssl/d1_pkt.c +578 -0
  616. data/third_party/boringssl/ssl/d1_srtp.c +234 -0
  617. data/third_party/boringssl/ssl/d1_srvr.c +485 -0
  618. data/third_party/boringssl/ssl/dtls_record.c +308 -0
  619. data/third_party/boringssl/ssl/internal.h +1276 -0
  620. data/third_party/boringssl/ssl/pqueue/pqueue.c +197 -0
  621. data/third_party/boringssl/ssl/s3_both.c +571 -0
  622. data/third_party/boringssl/ssl/s3_clnt.c +2241 -0
  623. data/third_party/boringssl/ssl/s3_enc.c +494 -0
  624. data/third_party/boringssl/ssl/s3_lib.c +587 -0
  625. data/third_party/boringssl/ssl/s3_meth.c +166 -0
  626. data/third_party/boringssl/ssl/s3_pkt.c +732 -0
  627. data/third_party/boringssl/ssl/s3_srvr.c +2536 -0
  628. data/third_party/boringssl/ssl/ssl_aead_ctx.c +300 -0
  629. data/third_party/boringssl/ssl/ssl_asn1.c +718 -0
  630. data/third_party/boringssl/ssl/ssl_buffer.c +319 -0
  631. data/third_party/boringssl/ssl/ssl_cert.c +539 -0
  632. data/third_party/boringssl/ssl/ssl_cipher.c +2003 -0
  633. data/third_party/boringssl/ssl/ssl_file.c +633 -0
  634. data/third_party/boringssl/ssl/ssl_lib.c +2653 -0
  635. data/third_party/boringssl/ssl/ssl_rsa.c +423 -0
  636. data/third_party/boringssl/ssl/ssl_session.c +764 -0
  637. data/third_party/boringssl/ssl/ssl_stat.c +591 -0
  638. data/third_party/boringssl/ssl/t1_enc.c +708 -0
  639. data/third_party/boringssl/ssl/t1_lib.c +2905 -0
  640. data/third_party/boringssl/ssl/test/async_bio.h +45 -0
  641. data/third_party/boringssl/ssl/test/packeted_bio.h +44 -0
  642. data/third_party/boringssl/ssl/test/scoped_types.h +28 -0
  643. data/third_party/boringssl/ssl/test/test_config.h +108 -0
  644. data/third_party/boringssl/ssl/tls_record.c +342 -0
  645. data/third_party/zlib/adler32.c +179 -0
  646. data/third_party/zlib/compress.c +80 -0
  647. data/third_party/zlib/crc32.c +425 -0
  648. data/third_party/zlib/crc32.h +441 -0
  649. data/third_party/zlib/deflate.c +1967 -0
  650. data/third_party/zlib/deflate.h +346 -0
  651. data/third_party/zlib/gzclose.c +25 -0
  652. data/third_party/zlib/gzguts.h +209 -0
  653. data/third_party/zlib/gzlib.c +634 -0
  654. data/third_party/zlib/gzread.c +594 -0
  655. data/third_party/zlib/gzwrite.c +577 -0
  656. data/third_party/zlib/infback.c +640 -0
  657. data/third_party/zlib/inffast.c +340 -0
  658. data/third_party/zlib/inffast.h +11 -0
  659. data/third_party/zlib/inffixed.h +94 -0
  660. data/third_party/zlib/inflate.c +1512 -0
  661. data/third_party/zlib/inflate.h +122 -0
  662. data/third_party/zlib/inftrees.c +306 -0
  663. data/third_party/zlib/inftrees.h +62 -0
  664. data/third_party/zlib/trees.c +1226 -0
  665. data/third_party/zlib/trees.h +128 -0
  666. data/third_party/zlib/uncompr.c +59 -0
  667. data/third_party/zlib/zconf.h +511 -0
  668. data/third_party/zlib/zlib.h +1768 -0
  669. data/third_party/zlib/zutil.c +324 -0
  670. data/third_party/zlib/zutil.h +253 -0
  671. metadata +492 -25
  672. data/Rakefile +0 -63
  673. data/src/ruby/lib/grpc/grpc.so +0 -0
@@ -0,0 +1,2456 @@
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
+
57
+ #include <string.h>
58
+ #include <time.h>
59
+
60
+ #include <openssl/asn1.h>
61
+ #include <openssl/buf.h>
62
+ #include <openssl/err.h>
63
+ #include <openssl/evp.h>
64
+ #include <openssl/lhash.h>
65
+ #include <openssl/mem.h>
66
+ #include <openssl/obj.h>
67
+ #include <openssl/thread.h>
68
+ #include <openssl/x509.h>
69
+ #include <openssl/x509v3.h>
70
+
71
+ #include "vpm_int.h"
72
+ #include "../internal.h"
73
+
74
+
75
+ static CRYPTO_EX_DATA_CLASS g_ex_data_class =
76
+ CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA;
77
+
78
+ /* CRL score values */
79
+
80
+ /* No unhandled critical extensions */
81
+
82
+ #define CRL_SCORE_NOCRITICAL 0x100
83
+
84
+ /* certificate is within CRL scope */
85
+
86
+ #define CRL_SCORE_SCOPE 0x080
87
+
88
+ /* CRL times valid */
89
+
90
+ #define CRL_SCORE_TIME 0x040
91
+
92
+ /* Issuer name matches certificate */
93
+
94
+ #define CRL_SCORE_ISSUER_NAME 0x020
95
+
96
+ /* If this score or above CRL is probably valid */
97
+
98
+ #define CRL_SCORE_VALID (CRL_SCORE_NOCRITICAL|CRL_SCORE_TIME|CRL_SCORE_SCOPE)
99
+
100
+ /* CRL issuer is certificate issuer */
101
+
102
+ #define CRL_SCORE_ISSUER_CERT 0x018
103
+
104
+ /* CRL issuer is on certificate path */
105
+
106
+ #define CRL_SCORE_SAME_PATH 0x008
107
+
108
+ /* CRL issuer matches CRL AKID */
109
+
110
+ #define CRL_SCORE_AKID 0x004
111
+
112
+ /* Have a delta CRL with valid times */
113
+
114
+ #define CRL_SCORE_TIME_DELTA 0x002
115
+
116
+ static int null_callback(int ok,X509_STORE_CTX *e);
117
+ static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
118
+ static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x);
119
+ static int check_chain_extensions(X509_STORE_CTX *ctx);
120
+ static int check_name_constraints(X509_STORE_CTX *ctx);
121
+ static int check_id(X509_STORE_CTX *ctx);
122
+ static int check_trust(X509_STORE_CTX *ctx);
123
+ static int check_revocation(X509_STORE_CTX *ctx);
124
+ static int check_cert(X509_STORE_CTX *ctx);
125
+ static int check_policy(X509_STORE_CTX *ctx);
126
+
127
+ static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
128
+ unsigned int *preasons,
129
+ X509_CRL *crl, X509 *x);
130
+ static int get_crl_delta(X509_STORE_CTX *ctx,
131
+ X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x);
132
+ static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pcrl_score,
133
+ X509_CRL *base, STACK_OF(X509_CRL) *crls);
134
+ static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
135
+ X509 **pissuer, int *pcrl_score);
136
+ static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
137
+ unsigned int *preasons);
138
+ static int check_crl_path(X509_STORE_CTX *ctx, X509 *x);
139
+ static int check_crl_chain(X509_STORE_CTX *ctx,
140
+ STACK_OF(X509) *cert_path,
141
+ STACK_OF(X509) *crl_path);
142
+
143
+ static int internal_verify(X509_STORE_CTX *ctx);
144
+
145
+
146
+ static int null_callback(int ok, X509_STORE_CTX *e)
147
+ {
148
+ return ok;
149
+ }
150
+
151
+ #if 0
152
+ static int x509_subject_cmp(X509 **a, X509 **b)
153
+ {
154
+ return X509_subject_name_cmp(*a,*b);
155
+ }
156
+ #endif
157
+ /* Return 1 is a certificate is self signed */
158
+ static int cert_self_signed(X509 *x)
159
+ {
160
+ X509_check_purpose(x, -1, 0);
161
+ if (x->ex_flags & EXFLAG_SS)
162
+ return 1;
163
+ else
164
+ return 0;
165
+ }
166
+
167
+ /* Given a certificate try and find an exact match in the store */
168
+
169
+ static X509 *lookup_cert_match(X509_STORE_CTX *ctx, X509 *x)
170
+ {
171
+ STACK_OF(X509) *certs;
172
+ X509 *xtmp = NULL;
173
+ size_t i;
174
+ /* Lookup all certs with matching subject name */
175
+ certs = ctx->lookup_certs(ctx, X509_get_subject_name(x));
176
+ if (certs == NULL)
177
+ return NULL;
178
+ /* Look for exact match */
179
+ for (i = 0; i < sk_X509_num(certs); i++)
180
+ {
181
+ xtmp = sk_X509_value(certs, i);
182
+ if (!X509_cmp(xtmp, x))
183
+ break;
184
+ }
185
+ if (i < sk_X509_num(certs))
186
+ X509_up_ref(xtmp);
187
+ else
188
+ xtmp = NULL;
189
+ sk_X509_pop_free(certs, X509_free);
190
+ return xtmp;
191
+ }
192
+
193
+ int X509_verify_cert(X509_STORE_CTX *ctx)
194
+ {
195
+ X509 *x,*xtmp,*chain_ss=NULL;
196
+ int bad_chain = 0;
197
+ X509_VERIFY_PARAM *param = ctx->param;
198
+ int depth,i,ok=0;
199
+ int num;
200
+ int (*cb)(int xok,X509_STORE_CTX *xctx);
201
+ STACK_OF(X509) *sktmp=NULL;
202
+ if (ctx->cert == NULL)
203
+ {
204
+ OPENSSL_PUT_ERROR(X509, X509_R_NO_CERT_SET_FOR_US_TO_VERIFY);
205
+ return -1;
206
+ }
207
+
208
+ cb=ctx->verify_cb;
209
+
210
+ /* first we make sure the chain we are going to build is
211
+ * present and that the first entry is in place */
212
+ if (ctx->chain == NULL)
213
+ {
214
+ if ( ((ctx->chain=sk_X509_new_null()) == NULL) ||
215
+ (!sk_X509_push(ctx->chain,ctx->cert)))
216
+ {
217
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
218
+ goto end;
219
+ }
220
+ X509_up_ref(ctx->cert);
221
+ ctx->last_untrusted=1;
222
+ }
223
+
224
+ /* We use a temporary STACK so we can chop and hack at it */
225
+ if (ctx->untrusted != NULL
226
+ && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)
227
+ {
228
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
229
+ goto end;
230
+ }
231
+
232
+ num=sk_X509_num(ctx->chain);
233
+ x=sk_X509_value(ctx->chain,num-1);
234
+ depth=param->depth;
235
+
236
+
237
+ for (;;)
238
+ {
239
+ /* If we have enough, we break */
240
+ if (depth < num) break; /* FIXME: If this happens, we should take
241
+ * note of it and, if appropriate, use the
242
+ * X509_V_ERR_CERT_CHAIN_TOO_LONG error
243
+ * code later.
244
+ */
245
+
246
+ /* If we are self signed, we break */
247
+ if (cert_self_signed(x))
248
+ break;
249
+ /* If asked see if we can find issuer in trusted store first */
250
+ if (ctx->param->flags & X509_V_FLAG_TRUSTED_FIRST)
251
+ {
252
+ ok = ctx->get_issuer(&xtmp, ctx, x);
253
+ if (ok < 0)
254
+ goto end;
255
+ /* If successful for now free up cert so it
256
+ * will be picked up again later.
257
+ */
258
+ if (ok > 0)
259
+ {
260
+ X509_free(xtmp);
261
+ break;
262
+ }
263
+ }
264
+
265
+ /* If we were passed a cert chain, use it first */
266
+ if (ctx->untrusted != NULL)
267
+ {
268
+ xtmp=find_issuer(ctx, sktmp,x);
269
+ if (xtmp != NULL)
270
+ {
271
+ if (!sk_X509_push(ctx->chain,xtmp))
272
+ {
273
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
274
+ goto end;
275
+ }
276
+ X509_up_ref(xtmp);
277
+ (void)sk_X509_delete_ptr(sktmp,xtmp);
278
+ ctx->last_untrusted++;
279
+ x=xtmp;
280
+ num++;
281
+ /* reparse the full chain for
282
+ * the next one */
283
+ continue;
284
+ }
285
+ }
286
+ break;
287
+ }
288
+
289
+ /* at this point, chain should contain a list of untrusted
290
+ * certificates. We now need to add at least one trusted one,
291
+ * if possible, otherwise we complain. */
292
+
293
+ /* Examine last certificate in chain and see if it
294
+ * is self signed.
295
+ */
296
+
297
+ i=sk_X509_num(ctx->chain);
298
+ x=sk_X509_value(ctx->chain,i-1);
299
+ if (cert_self_signed(x))
300
+ {
301
+ /* we have a self signed certificate */
302
+ if (sk_X509_num(ctx->chain) == 1)
303
+ {
304
+ /* We have a single self signed certificate: see if
305
+ * we can find it in the store. We must have an exact
306
+ * match to avoid possible impersonation.
307
+ */
308
+ ok = ctx->get_issuer(&xtmp, ctx, x);
309
+ if ((ok <= 0) || X509_cmp(x, xtmp))
310
+ {
311
+ ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;
312
+ ctx->current_cert=x;
313
+ ctx->error_depth=i-1;
314
+ if (ok == 1) X509_free(xtmp);
315
+ bad_chain = 1;
316
+ ok=cb(0,ctx);
317
+ if (!ok) goto end;
318
+ }
319
+ else
320
+ {
321
+ /* We have a match: replace certificate with store version
322
+ * so we get any trust settings.
323
+ */
324
+ X509_free(x);
325
+ x = xtmp;
326
+ (void)sk_X509_set(ctx->chain, i - 1, x);
327
+ ctx->last_untrusted=0;
328
+ }
329
+ }
330
+ else
331
+ {
332
+ /* extract and save self signed certificate for later use */
333
+ chain_ss=sk_X509_pop(ctx->chain);
334
+ ctx->last_untrusted--;
335
+ num--;
336
+ x=sk_X509_value(ctx->chain,num-1);
337
+ }
338
+ }
339
+
340
+ /* We now lookup certs from the certificate store */
341
+ for (;;)
342
+ {
343
+ /* If we have enough, we break */
344
+ if (depth < num) break;
345
+
346
+ /* If we are self signed, we break */
347
+ if (cert_self_signed(x))
348
+ break;
349
+
350
+ ok = ctx->get_issuer(&xtmp, ctx, x);
351
+
352
+ if (ok < 0) goto end;
353
+ if (ok == 0) break;
354
+
355
+ x = xtmp;
356
+ if (!sk_X509_push(ctx->chain,x))
357
+ {
358
+ X509_free(xtmp);
359
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
360
+ ok = 0;
361
+ goto end;
362
+ }
363
+ num++;
364
+ }
365
+
366
+ /* we now have our chain, lets check it... */
367
+
368
+ i = check_trust(ctx);
369
+
370
+ /* If explicitly rejected error */
371
+ if (i == X509_TRUST_REJECTED)
372
+ goto end;
373
+ /* If not explicitly trusted then indicate error unless it's
374
+ * a single self signed certificate in which case we've indicated
375
+ * an error already and set bad_chain == 1
376
+ */
377
+ if (i != X509_TRUST_TRUSTED && !bad_chain)
378
+ {
379
+ if ((chain_ss == NULL) || !ctx->check_issued(ctx, x, chain_ss))
380
+ {
381
+ if (ctx->last_untrusted >= num)
382
+ ctx->error=X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;
383
+ else
384
+ ctx->error=X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT;
385
+ ctx->current_cert=x;
386
+ }
387
+ else
388
+ {
389
+
390
+ sk_X509_push(ctx->chain,chain_ss);
391
+ num++;
392
+ ctx->last_untrusted=num;
393
+ ctx->current_cert=chain_ss;
394
+ ctx->error=X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN;
395
+ chain_ss=NULL;
396
+ }
397
+
398
+ ctx->error_depth=num-1;
399
+ bad_chain = 1;
400
+ ok=cb(0,ctx);
401
+ if (!ok) goto end;
402
+ }
403
+
404
+ /* We have the chain complete: now we need to check its purpose */
405
+ ok = check_chain_extensions(ctx);
406
+
407
+ if (!ok) goto end;
408
+
409
+ /* Check name constraints */
410
+
411
+ ok = check_name_constraints(ctx);
412
+
413
+ if (!ok) goto end;
414
+
415
+ ok = check_id(ctx);
416
+
417
+ if (!ok) goto end;
418
+
419
+ /* Check revocation status: we do this after copying parameters
420
+ * because they may be needed for CRL signature verification.
421
+ */
422
+
423
+ ok = ctx->check_revocation(ctx);
424
+ if(!ok) goto end;
425
+
426
+ i = X509_chain_check_suiteb(&ctx->error_depth, NULL, ctx->chain,
427
+ ctx->param->flags);
428
+ if (i != X509_V_OK)
429
+ {
430
+ ctx->error = i;
431
+ ctx->current_cert = sk_X509_value(ctx->chain, ctx->error_depth);
432
+ ok = cb(0, ctx);
433
+ if (!ok)
434
+ goto end;
435
+ }
436
+
437
+ /* At this point, we have a chain and need to verify it */
438
+ if (ctx->verify != NULL)
439
+ ok=ctx->verify(ctx);
440
+ else
441
+ ok=internal_verify(ctx);
442
+ if(!ok) goto end;
443
+
444
+ /* If we get this far evaluate policies */
445
+ if (!bad_chain && (ctx->param->flags & X509_V_FLAG_POLICY_CHECK))
446
+ ok = ctx->check_policy(ctx);
447
+
448
+ end:
449
+ if (sktmp != NULL) sk_X509_free(sktmp);
450
+ if (chain_ss != NULL) X509_free(chain_ss);
451
+ return ok;
452
+ }
453
+
454
+
455
+ /* Given a STACK_OF(X509) find the issuer of cert (if any)
456
+ */
457
+
458
+ static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
459
+ {
460
+ size_t i;
461
+ X509 *issuer;
462
+ for (i = 0; i < sk_X509_num(sk); i++)
463
+ {
464
+ issuer = sk_X509_value(sk, i);
465
+ if (ctx->check_issued(ctx, x, issuer))
466
+ return issuer;
467
+ }
468
+ return NULL;
469
+ }
470
+
471
+ /* Given a possible certificate and issuer check them */
472
+
473
+ static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer)
474
+ {
475
+ int ret;
476
+ ret = X509_check_issued(issuer, x);
477
+ if (ret == X509_V_OK)
478
+ return 1;
479
+ /* If we haven't asked for issuer errors don't set ctx */
480
+ if (!(ctx->param->flags & X509_V_FLAG_CB_ISSUER_CHECK))
481
+ return 0;
482
+
483
+ ctx->error = ret;
484
+ ctx->current_cert = x;
485
+ ctx->current_issuer = issuer;
486
+ return ctx->verify_cb(0, ctx);
487
+ }
488
+
489
+ /* Alternative lookup method: look from a STACK stored in other_ctx */
490
+
491
+ static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
492
+ {
493
+ *issuer = find_issuer(ctx, ctx->other_ctx, x);
494
+ if (*issuer)
495
+ {
496
+ X509_up_ref(*issuer);
497
+ return 1;
498
+ }
499
+ else
500
+ return 0;
501
+ }
502
+
503
+
504
+ /* Check a certificate chains extensions for consistency
505
+ * with the supplied purpose
506
+ */
507
+
508
+ static int check_chain_extensions(X509_STORE_CTX *ctx)
509
+ {
510
+ int i, ok=0, must_be_ca, plen = 0;
511
+ X509 *x;
512
+ int (*cb)(int xok,X509_STORE_CTX *xctx);
513
+ int proxy_path_length = 0;
514
+ int purpose;
515
+ int allow_proxy_certs;
516
+ cb=ctx->verify_cb;
517
+
518
+ /* must_be_ca can have 1 of 3 values:
519
+ -1: we accept both CA and non-CA certificates, to allow direct
520
+ use of self-signed certificates (which are marked as CA).
521
+ 0: we only accept non-CA certificates. This is currently not
522
+ used, but the possibility is present for future extensions.
523
+ 1: we only accept CA certificates. This is currently used for
524
+ all certificates in the chain except the leaf certificate.
525
+ */
526
+ must_be_ca = -1;
527
+
528
+ /* CRL path validation */
529
+ if (ctx->parent)
530
+ {
531
+ allow_proxy_certs = 0;
532
+ purpose = X509_PURPOSE_CRL_SIGN;
533
+ }
534
+ else
535
+ {
536
+ allow_proxy_certs =
537
+ !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
538
+ /* A hack to keep people who don't want to modify their
539
+ software happy */
540
+ if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
541
+ allow_proxy_certs = 1;
542
+ purpose = ctx->param->purpose;
543
+ }
544
+
545
+ /* Check all untrusted certificates */
546
+ for (i = 0; i < ctx->last_untrusted; i++)
547
+ {
548
+ int ret;
549
+ x = sk_X509_value(ctx->chain, i);
550
+ if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
551
+ && (x->ex_flags & EXFLAG_CRITICAL))
552
+ {
553
+ ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION;
554
+ ctx->error_depth = i;
555
+ ctx->current_cert = x;
556
+ ok=cb(0,ctx);
557
+ if (!ok) goto end;
558
+ }
559
+ if (!allow_proxy_certs && (x->ex_flags & EXFLAG_PROXY))
560
+ {
561
+ ctx->error = X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED;
562
+ ctx->error_depth = i;
563
+ ctx->current_cert = x;
564
+ ok=cb(0,ctx);
565
+ if (!ok) goto end;
566
+ }
567
+ ret = X509_check_ca(x);
568
+ switch(must_be_ca)
569
+ {
570
+ case -1:
571
+ if ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
572
+ && (ret != 1) && (ret != 0))
573
+ {
574
+ ret = 0;
575
+ ctx->error = X509_V_ERR_INVALID_CA;
576
+ }
577
+ else
578
+ ret = 1;
579
+ break;
580
+ case 0:
581
+ if (ret != 0)
582
+ {
583
+ ret = 0;
584
+ ctx->error = X509_V_ERR_INVALID_NON_CA;
585
+ }
586
+ else
587
+ ret = 1;
588
+ break;
589
+ default:
590
+ if ((ret == 0)
591
+ || ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
592
+ && (ret != 1)))
593
+ {
594
+ ret = 0;
595
+ ctx->error = X509_V_ERR_INVALID_CA;
596
+ }
597
+ else
598
+ ret = 1;
599
+ break;
600
+ }
601
+ if (ret == 0)
602
+ {
603
+ ctx->error_depth = i;
604
+ ctx->current_cert = x;
605
+ ok=cb(0,ctx);
606
+ if (!ok) goto end;
607
+ }
608
+ if (ctx->param->purpose > 0)
609
+ {
610
+ ret = X509_check_purpose(x, purpose, must_be_ca > 0);
611
+ if ((ret == 0)
612
+ || ((ctx->param->flags & X509_V_FLAG_X509_STRICT)
613
+ && (ret != 1)))
614
+ {
615
+ ctx->error = X509_V_ERR_INVALID_PURPOSE;
616
+ ctx->error_depth = i;
617
+ ctx->current_cert = x;
618
+ ok=cb(0,ctx);
619
+ if (!ok) goto end;
620
+ }
621
+ }
622
+ /* Check pathlen if not self issued */
623
+ if ((i > 1) && !(x->ex_flags & EXFLAG_SI)
624
+ && (x->ex_pathlen != -1)
625
+ && (plen > (x->ex_pathlen + proxy_path_length + 1)))
626
+ {
627
+ ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED;
628
+ ctx->error_depth = i;
629
+ ctx->current_cert = x;
630
+ ok=cb(0,ctx);
631
+ if (!ok) goto end;
632
+ }
633
+ /* Increment path length if not self issued */
634
+ if (!(x->ex_flags & EXFLAG_SI))
635
+ plen++;
636
+ /* If this certificate is a proxy certificate, the next
637
+ certificate must be another proxy certificate or a EE
638
+ certificate. If not, the next certificate must be a
639
+ CA certificate. */
640
+ if (x->ex_flags & EXFLAG_PROXY)
641
+ {
642
+ if (x->ex_pcpathlen != -1 && i > x->ex_pcpathlen)
643
+ {
644
+ ctx->error =
645
+ X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED;
646
+ ctx->error_depth = i;
647
+ ctx->current_cert = x;
648
+ ok=cb(0,ctx);
649
+ if (!ok) goto end;
650
+ }
651
+ proxy_path_length++;
652
+ must_be_ca = 0;
653
+ }
654
+ else
655
+ must_be_ca = 1;
656
+ }
657
+ ok = 1;
658
+ end:
659
+ return ok;
660
+ }
661
+
662
+ static int check_name_constraints(X509_STORE_CTX *ctx)
663
+ {
664
+ X509 *x;
665
+ int i, j, rv;
666
+ /* Check name constraints for all certificates */
667
+ for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--)
668
+ {
669
+ x = sk_X509_value(ctx->chain, i);
670
+ /* Ignore self issued certs unless last in chain */
671
+ if (i && (x->ex_flags & EXFLAG_SI))
672
+ continue;
673
+ /* Check against constraints for all certificates higher in
674
+ * chain including trust anchor. Trust anchor not strictly
675
+ * speaking needed but if it includes constraints it is to be
676
+ * assumed it expects them to be obeyed.
677
+ */
678
+ for (j = sk_X509_num(ctx->chain) - 1; j > i; j--)
679
+ {
680
+ NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc;
681
+ if (nc)
682
+ {
683
+ rv = NAME_CONSTRAINTS_check(x, nc);
684
+ if (rv != X509_V_OK)
685
+ {
686
+ ctx->error = rv;
687
+ ctx->error_depth = i;
688
+ ctx->current_cert = x;
689
+ if (!ctx->verify_cb(0,ctx))
690
+ return 0;
691
+ }
692
+ }
693
+ }
694
+ }
695
+ return 1;
696
+ }
697
+
698
+ static int check_id_error(X509_STORE_CTX *ctx, int errcode)
699
+ {
700
+ ctx->error = errcode;
701
+ ctx->current_cert = ctx->cert;
702
+ ctx->error_depth = 0;
703
+ return ctx->verify_cb(0, ctx);
704
+ }
705
+
706
+ static int check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id)
707
+ {
708
+ size_t i;
709
+ size_t n = sk_OPENSSL_STRING_num(id->hosts);
710
+ char *name;
711
+
712
+ for (i = 0; i < n; ++i)
713
+ {
714
+ name = sk_OPENSSL_STRING_value(id->hosts, i);
715
+ if (X509_check_host(x, name, strlen(name), id->hostflags,
716
+ &id->peername) > 0)
717
+ return 1;
718
+ }
719
+ return n == 0;
720
+ }
721
+
722
+ static int check_id(X509_STORE_CTX *ctx)
723
+ {
724
+ X509_VERIFY_PARAM *vpm = ctx->param;
725
+ X509_VERIFY_PARAM_ID *id = vpm->id;
726
+ X509 *x = ctx->cert;
727
+ if (id->hosts && check_hosts(x, id) <= 0)
728
+ {
729
+ if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH))
730
+ return 0;
731
+ }
732
+ if (id->email && X509_check_email(x, id->email, id->emaillen, 0) <= 0)
733
+ {
734
+ if (!check_id_error(ctx, X509_V_ERR_EMAIL_MISMATCH))
735
+ return 0;
736
+ }
737
+ if (id->ip && X509_check_ip(x, id->ip, id->iplen, 0) <= 0)
738
+ {
739
+ if (!check_id_error(ctx, X509_V_ERR_IP_ADDRESS_MISMATCH))
740
+ return 0;
741
+ }
742
+ return 1;
743
+ }
744
+
745
+ static int check_trust(X509_STORE_CTX *ctx)
746
+ {
747
+ size_t i;
748
+ int ok;
749
+ X509 *x = NULL;
750
+ int (*cb)(int xok,X509_STORE_CTX *xctx);
751
+ cb=ctx->verify_cb;
752
+ /* Check all trusted certificates in chain */
753
+ for (i = ctx->last_untrusted; i < sk_X509_num(ctx->chain); i++)
754
+ {
755
+ x = sk_X509_value(ctx->chain, i);
756
+ ok = X509_check_trust(x, ctx->param->trust, 0);
757
+ /* If explicitly trusted return trusted */
758
+ if (ok == X509_TRUST_TRUSTED)
759
+ return X509_TRUST_TRUSTED;
760
+ /* If explicitly rejected notify callback and reject if
761
+ * not overridden.
762
+ */
763
+ if (ok == X509_TRUST_REJECTED)
764
+ {
765
+ ctx->error_depth = i;
766
+ ctx->current_cert = x;
767
+ ctx->error = X509_V_ERR_CERT_REJECTED;
768
+ ok = cb(0, ctx);
769
+ if (!ok)
770
+ return X509_TRUST_REJECTED;
771
+ }
772
+ }
773
+ /* If we accept partial chains and have at least one trusted
774
+ * certificate return success.
775
+ */
776
+ if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN)
777
+ {
778
+ X509 *mx;
779
+ if (ctx->last_untrusted < (int) sk_X509_num(ctx->chain))
780
+ return X509_TRUST_TRUSTED;
781
+ x = sk_X509_value(ctx->chain, 0);
782
+ mx = lookup_cert_match(ctx, x);
783
+ if (mx)
784
+ {
785
+ (void)sk_X509_set(ctx->chain, 0, mx);
786
+ X509_free(x);
787
+ ctx->last_untrusted = 0;
788
+ return X509_TRUST_TRUSTED;
789
+ }
790
+ }
791
+
792
+ /* If no trusted certs in chain at all return untrusted and
793
+ * allow standard (no issuer cert) etc errors to be indicated.
794
+ */
795
+ return X509_TRUST_UNTRUSTED;
796
+ }
797
+
798
+ static int check_revocation(X509_STORE_CTX *ctx)
799
+ {
800
+ int i, last, ok;
801
+ if (!(ctx->param->flags & X509_V_FLAG_CRL_CHECK))
802
+ return 1;
803
+ if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL)
804
+ last = sk_X509_num(ctx->chain) - 1;
805
+ else
806
+ {
807
+ /* If checking CRL paths this isn't the EE certificate */
808
+ if (ctx->parent)
809
+ return 1;
810
+ last = 0;
811
+ }
812
+ for(i = 0; i <= last; i++)
813
+ {
814
+ ctx->error_depth = i;
815
+ ok = check_cert(ctx);
816
+ if (!ok) return ok;
817
+ }
818
+ return 1;
819
+ }
820
+
821
+ static int check_cert(X509_STORE_CTX *ctx)
822
+ OPENSSL_SUPPRESS_POTENTIALLY_UNINITIALIZED_WARNINGS
823
+ {
824
+ X509_CRL *crl = NULL, *dcrl = NULL;
825
+ X509 *x;
826
+ int ok, cnum;
827
+ unsigned int last_reasons;
828
+ cnum = ctx->error_depth;
829
+ x = sk_X509_value(ctx->chain, cnum);
830
+ ctx->current_cert = x;
831
+ ctx->current_issuer = NULL;
832
+ ctx->current_crl_score = 0;
833
+ ctx->current_reasons = 0;
834
+ while (ctx->current_reasons != CRLDP_ALL_REASONS)
835
+ {
836
+ last_reasons = ctx->current_reasons;
837
+ /* Try to retrieve relevant CRL */
838
+ if (ctx->get_crl)
839
+ ok = ctx->get_crl(ctx, &crl, x);
840
+ else
841
+ ok = get_crl_delta(ctx, &crl, &dcrl, x);
842
+ /* If error looking up CRL, nothing we can do except
843
+ * notify callback
844
+ */
845
+ if(!ok)
846
+ {
847
+ ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
848
+ ok = ctx->verify_cb(0, ctx);
849
+ goto err;
850
+ }
851
+ ctx->current_crl = crl;
852
+ ok = ctx->check_crl(ctx, crl);
853
+ if (!ok)
854
+ goto err;
855
+
856
+ if (dcrl)
857
+ {
858
+ ok = ctx->check_crl(ctx, dcrl);
859
+ if (!ok)
860
+ goto err;
861
+ ok = ctx->cert_crl(ctx, dcrl, x);
862
+ if (!ok)
863
+ goto err;
864
+ }
865
+ else
866
+ ok = 1;
867
+
868
+ /* Don't look in full CRL if delta reason is removefromCRL */
869
+ if (ok != 2)
870
+ {
871
+ ok = ctx->cert_crl(ctx, crl, x);
872
+ if (!ok)
873
+ goto err;
874
+ }
875
+
876
+ X509_CRL_free(crl);
877
+ X509_CRL_free(dcrl);
878
+ crl = NULL;
879
+ dcrl = NULL;
880
+ /* If reasons not updated we wont get anywhere by
881
+ * another iteration, so exit loop.
882
+ */
883
+ if (last_reasons == ctx->current_reasons)
884
+ {
885
+ ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
886
+ ok = ctx->verify_cb(0, ctx);
887
+ goto err;
888
+ }
889
+ }
890
+ err:
891
+ X509_CRL_free(crl);
892
+ X509_CRL_free(dcrl);
893
+
894
+ ctx->current_crl = NULL;
895
+ return ok;
896
+
897
+ }
898
+
899
+ /* Check CRL times against values in X509_STORE_CTX */
900
+
901
+ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify)
902
+ {
903
+ time_t *ptime;
904
+ int i;
905
+ if (notify)
906
+ ctx->current_crl = crl;
907
+ if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
908
+ ptime = &ctx->param->check_time;
909
+ else
910
+ ptime = NULL;
911
+
912
+ i=X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime);
913
+ if (i == 0)
914
+ {
915
+ if (!notify)
916
+ return 0;
917
+ ctx->error=X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD;
918
+ if (!ctx->verify_cb(0, ctx))
919
+ return 0;
920
+ }
921
+
922
+ if (i > 0)
923
+ {
924
+ if (!notify)
925
+ return 0;
926
+ ctx->error=X509_V_ERR_CRL_NOT_YET_VALID;
927
+ if (!ctx->verify_cb(0, ctx))
928
+ return 0;
929
+ }
930
+
931
+ if(X509_CRL_get_nextUpdate(crl))
932
+ {
933
+ i=X509_cmp_time(X509_CRL_get_nextUpdate(crl), ptime);
934
+
935
+ if (i == 0)
936
+ {
937
+ if (!notify)
938
+ return 0;
939
+ ctx->error=X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD;
940
+ if (!ctx->verify_cb(0, ctx))
941
+ return 0;
942
+ }
943
+ /* Ignore expiry of base CRL is delta is valid */
944
+ if ((i < 0) && !(ctx->current_crl_score & CRL_SCORE_TIME_DELTA))
945
+ {
946
+ if (!notify)
947
+ return 0;
948
+ ctx->error=X509_V_ERR_CRL_HAS_EXPIRED;
949
+ if (!ctx->verify_cb(0, ctx))
950
+ return 0;
951
+ }
952
+ }
953
+
954
+ if (notify)
955
+ ctx->current_crl = NULL;
956
+
957
+ return 1;
958
+ }
959
+
960
+ static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
961
+ X509 **pissuer, int *pscore, unsigned int *preasons,
962
+ STACK_OF(X509_CRL) *crls)
963
+ {
964
+ int crl_score, best_score = *pscore;
965
+ size_t i;
966
+ unsigned int reasons, best_reasons = 0;
967
+ X509 *x = ctx->current_cert;
968
+ X509_CRL *crl, *best_crl = NULL;
969
+ X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
970
+
971
+ for (i = 0; i < sk_X509_CRL_num(crls); i++)
972
+ {
973
+ crl = sk_X509_CRL_value(crls, i);
974
+ reasons = *preasons;
975
+ crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
976
+
977
+ if (crl_score > best_score)
978
+ {
979
+ best_crl = crl;
980
+ best_crl_issuer = crl_issuer;
981
+ best_score = crl_score;
982
+ best_reasons = reasons;
983
+ }
984
+ }
985
+
986
+ if (best_crl)
987
+ {
988
+ if (*pcrl)
989
+ X509_CRL_free(*pcrl);
990
+ *pcrl = best_crl;
991
+ *pissuer = best_crl_issuer;
992
+ *pscore = best_score;
993
+ *preasons = best_reasons;
994
+ X509_CRL_up_ref(best_crl);
995
+ if (*pdcrl)
996
+ {
997
+ X509_CRL_free(*pdcrl);
998
+ *pdcrl = NULL;
999
+ }
1000
+ get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
1001
+ }
1002
+
1003
+ if (best_score >= CRL_SCORE_VALID)
1004
+ return 1;
1005
+
1006
+ return 0;
1007
+ }
1008
+
1009
+ /* Compare two CRL extensions for delta checking purposes. They should be
1010
+ * both present or both absent. If both present all fields must be identical.
1011
+ */
1012
+
1013
+ static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid)
1014
+ {
1015
+ ASN1_OCTET_STRING *exta, *extb;
1016
+ int i;
1017
+ i = X509_CRL_get_ext_by_NID(a, nid, -1);
1018
+ if (i >= 0)
1019
+ {
1020
+ /* Can't have multiple occurrences */
1021
+ if (X509_CRL_get_ext_by_NID(a, nid, i) != -1)
1022
+ return 0;
1023
+ exta = X509_EXTENSION_get_data(X509_CRL_get_ext(a, i));
1024
+ }
1025
+ else
1026
+ exta = NULL;
1027
+
1028
+ i = X509_CRL_get_ext_by_NID(b, nid, -1);
1029
+
1030
+ if (i >= 0)
1031
+ {
1032
+
1033
+ if (X509_CRL_get_ext_by_NID(b, nid, i) != -1)
1034
+ return 0;
1035
+ extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i));
1036
+ }
1037
+ else
1038
+ extb = NULL;
1039
+
1040
+ if (!exta && !extb)
1041
+ return 1;
1042
+
1043
+ if (!exta || !extb)
1044
+ return 0;
1045
+
1046
+
1047
+ if (ASN1_OCTET_STRING_cmp(exta, extb))
1048
+ return 0;
1049
+
1050
+ return 1;
1051
+ }
1052
+
1053
+ /* See if a base and delta are compatible */
1054
+
1055
+ static int check_delta_base(X509_CRL *delta, X509_CRL *base)
1056
+ {
1057
+ /* Delta CRL must be a delta */
1058
+ if (!delta->base_crl_number)
1059
+ return 0;
1060
+ /* Base must have a CRL number */
1061
+ if (!base->crl_number)
1062
+ return 0;
1063
+ /* Issuer names must match */
1064
+ if (X509_NAME_cmp(X509_CRL_get_issuer(base),
1065
+ X509_CRL_get_issuer(delta)))
1066
+ return 0;
1067
+ /* AKID and IDP must match */
1068
+ if (!crl_extension_match(delta, base, NID_authority_key_identifier))
1069
+ return 0;
1070
+ if (!crl_extension_match(delta, base, NID_issuing_distribution_point))
1071
+ return 0;
1072
+ /* Delta CRL base number must not exceed Full CRL number. */
1073
+ if (ASN1_INTEGER_cmp(delta->base_crl_number, base->crl_number) > 0)
1074
+ return 0;
1075
+ /* Delta CRL number must exceed full CRL number */
1076
+ if (ASN1_INTEGER_cmp(delta->crl_number, base->crl_number) > 0)
1077
+ return 1;
1078
+ return 0;
1079
+ }
1080
+
1081
+ /* For a given base CRL find a delta... maybe extend to delta scoring
1082
+ * or retrieve a chain of deltas...
1083
+ */
1084
+
1085
+ static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
1086
+ X509_CRL *base, STACK_OF(X509_CRL) *crls)
1087
+ {
1088
+ X509_CRL *delta;
1089
+ size_t i;
1090
+ if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS))
1091
+ return;
1092
+ if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST))
1093
+ return;
1094
+ for (i = 0; i < sk_X509_CRL_num(crls); i++)
1095
+ {
1096
+ delta = sk_X509_CRL_value(crls, i);
1097
+ if (check_delta_base(delta, base))
1098
+ {
1099
+ if (check_crl_time(ctx, delta, 0))
1100
+ *pscore |= CRL_SCORE_TIME_DELTA;
1101
+ X509_CRL_up_ref(delta);
1102
+ *dcrl = delta;
1103
+ return;
1104
+ }
1105
+ }
1106
+ *dcrl = NULL;
1107
+ }
1108
+
1109
+ /* For a given CRL return how suitable it is for the supplied certificate 'x'.
1110
+ * The return value is a mask of several criteria.
1111
+ * If the issuer is not the certificate issuer this is returned in *pissuer.
1112
+ * The reasons mask is also used to determine if the CRL is suitable: if
1113
+ * no new reasons the CRL is rejected, otherwise reasons is updated.
1114
+ */
1115
+
1116
+ static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
1117
+ unsigned int *preasons,
1118
+ X509_CRL *crl, X509 *x)
1119
+ {
1120
+
1121
+ int crl_score = 0;
1122
+ unsigned int tmp_reasons = *preasons, crl_reasons;
1123
+
1124
+ /* First see if we can reject CRL straight away */
1125
+
1126
+ /* Invalid IDP cannot be processed */
1127
+ if (crl->idp_flags & IDP_INVALID)
1128
+ return 0;
1129
+ /* Reason codes or indirect CRLs need extended CRL support */
1130
+ if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
1131
+ {
1132
+ if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS))
1133
+ return 0;
1134
+ }
1135
+ else if (crl->idp_flags & IDP_REASONS)
1136
+ {
1137
+ /* If no new reasons reject */
1138
+ if (!(crl->idp_reasons & ~tmp_reasons))
1139
+ return 0;
1140
+ }
1141
+ /* Don't process deltas at this stage */
1142
+ else if (crl->base_crl_number)
1143
+ return 0;
1144
+ /* If issuer name doesn't match certificate need indirect CRL */
1145
+ if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl)))
1146
+ {
1147
+ if (!(crl->idp_flags & IDP_INDIRECT))
1148
+ return 0;
1149
+ }
1150
+ else
1151
+ crl_score |= CRL_SCORE_ISSUER_NAME;
1152
+
1153
+ if (!(crl->flags & EXFLAG_CRITICAL))
1154
+ crl_score |= CRL_SCORE_NOCRITICAL;
1155
+
1156
+ /* Check expiry */
1157
+ if (check_crl_time(ctx, crl, 0))
1158
+ crl_score |= CRL_SCORE_TIME;
1159
+
1160
+ /* Check authority key ID and locate certificate issuer */
1161
+ crl_akid_check(ctx, crl, pissuer, &crl_score);
1162
+
1163
+ /* If we can't locate certificate issuer at this point forget it */
1164
+
1165
+ if (!(crl_score & CRL_SCORE_AKID))
1166
+ return 0;
1167
+
1168
+ /* Check cert for matching CRL distribution points */
1169
+
1170
+ if (crl_crldp_check(x, crl, crl_score, &crl_reasons))
1171
+ {
1172
+ /* If no new reasons reject */
1173
+ if (!(crl_reasons & ~tmp_reasons))
1174
+ return 0;
1175
+ tmp_reasons |= crl_reasons;
1176
+ crl_score |= CRL_SCORE_SCOPE;
1177
+ }
1178
+
1179
+ *preasons = tmp_reasons;
1180
+
1181
+ return crl_score;
1182
+
1183
+ }
1184
+
1185
+ static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
1186
+ X509 **pissuer, int *pcrl_score)
1187
+ {
1188
+ X509 *crl_issuer = NULL;
1189
+ X509_NAME *cnm = X509_CRL_get_issuer(crl);
1190
+ int cidx = ctx->error_depth;
1191
+ size_t i;
1192
+
1193
+ if ((size_t) cidx != sk_X509_num(ctx->chain) - 1)
1194
+ cidx++;
1195
+
1196
+ crl_issuer = sk_X509_value(ctx->chain, cidx);
1197
+
1198
+ if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
1199
+ {
1200
+ if (*pcrl_score & CRL_SCORE_ISSUER_NAME)
1201
+ {
1202
+ *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_ISSUER_CERT;
1203
+ *pissuer = crl_issuer;
1204
+ return;
1205
+ }
1206
+ }
1207
+
1208
+ for (cidx++; cidx < (int) sk_X509_num(ctx->chain); cidx++)
1209
+ {
1210
+ crl_issuer = sk_X509_value(ctx->chain, cidx);
1211
+ if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1212
+ continue;
1213
+ if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
1214
+ {
1215
+ *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_SAME_PATH;
1216
+ *pissuer = crl_issuer;
1217
+ return;
1218
+ }
1219
+ }
1220
+
1221
+ /* Anything else needs extended CRL support */
1222
+
1223
+ if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
1224
+ return;
1225
+
1226
+ /* Otherwise the CRL issuer is not on the path. Look for it in the
1227
+ * set of untrusted certificates.
1228
+ */
1229
+ for (i = 0; i < sk_X509_num(ctx->untrusted); i++)
1230
+ {
1231
+ crl_issuer = sk_X509_value(ctx->untrusted, i);
1232
+ if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1233
+ continue;
1234
+ if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
1235
+ {
1236
+ *pissuer = crl_issuer;
1237
+ *pcrl_score |= CRL_SCORE_AKID;
1238
+ return;
1239
+ }
1240
+ }
1241
+ }
1242
+
1243
+ /* Check the path of a CRL issuer certificate. This creates a new
1244
+ * X509_STORE_CTX and populates it with most of the parameters from the
1245
+ * parent. This could be optimised somewhat since a lot of path checking
1246
+ * will be duplicated by the parent, but this will rarely be used in
1247
+ * practice.
1248
+ */
1249
+
1250
+ static int check_crl_path(X509_STORE_CTX *ctx, X509 *x)
1251
+ {
1252
+ X509_STORE_CTX crl_ctx;
1253
+ int ret;
1254
+ /* Don't allow recursive CRL path validation */
1255
+ if (ctx->parent)
1256
+ return 0;
1257
+ if (!X509_STORE_CTX_init(&crl_ctx, ctx->ctx, x, ctx->untrusted))
1258
+ return -1;
1259
+
1260
+ crl_ctx.crls = ctx->crls;
1261
+ /* Copy verify params across */
1262
+ X509_STORE_CTX_set0_param(&crl_ctx, ctx->param);
1263
+
1264
+ crl_ctx.parent = ctx;
1265
+ crl_ctx.verify_cb = ctx->verify_cb;
1266
+
1267
+ /* Verify CRL issuer */
1268
+ ret = X509_verify_cert(&crl_ctx);
1269
+
1270
+ if (ret <= 0)
1271
+ goto err;
1272
+
1273
+ /* Check chain is acceptable */
1274
+
1275
+ ret = check_crl_chain(ctx, ctx->chain, crl_ctx.chain);
1276
+ err:
1277
+ X509_STORE_CTX_cleanup(&crl_ctx);
1278
+ return ret;
1279
+ }
1280
+
1281
+ /* RFC3280 says nothing about the relationship between CRL path
1282
+ * and certificate path, which could lead to situations where a
1283
+ * certificate could be revoked or validated by a CA not authorised
1284
+ * to do so. RFC5280 is more strict and states that the two paths must
1285
+ * end in the same trust anchor, though some discussions remain...
1286
+ * until this is resolved we use the RFC5280 version
1287
+ */
1288
+
1289
+ static int check_crl_chain(X509_STORE_CTX *ctx,
1290
+ STACK_OF(X509) *cert_path,
1291
+ STACK_OF(X509) *crl_path)
1292
+ {
1293
+ X509 *cert_ta, *crl_ta;
1294
+ cert_ta = sk_X509_value(cert_path, sk_X509_num(cert_path) - 1);
1295
+ crl_ta = sk_X509_value(crl_path, sk_X509_num(crl_path) - 1);
1296
+ if (!X509_cmp(cert_ta, crl_ta))
1297
+ return 1;
1298
+ return 0;
1299
+ }
1300
+
1301
+ /* Check for match between two dist point names: three separate cases.
1302
+ * 1. Both are relative names and compare X509_NAME types.
1303
+ * 2. One full, one relative. Compare X509_NAME to GENERAL_NAMES.
1304
+ * 3. Both are full names and compare two GENERAL_NAMES.
1305
+ * 4. One is NULL: automatic match.
1306
+ */
1307
+
1308
+
1309
+ static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
1310
+ {
1311
+ X509_NAME *nm = NULL;
1312
+ GENERAL_NAMES *gens = NULL;
1313
+ GENERAL_NAME *gena, *genb;
1314
+ size_t i, j;
1315
+ if (!a || !b)
1316
+ return 1;
1317
+ if (a->type == 1)
1318
+ {
1319
+ if (!a->dpname)
1320
+ return 0;
1321
+ /* Case 1: two X509_NAME */
1322
+ if (b->type == 1)
1323
+ {
1324
+ if (!b->dpname)
1325
+ return 0;
1326
+ if (!X509_NAME_cmp(a->dpname, b->dpname))
1327
+ return 1;
1328
+ else
1329
+ return 0;
1330
+ }
1331
+ /* Case 2: set name and GENERAL_NAMES appropriately */
1332
+ nm = a->dpname;
1333
+ gens = b->name.fullname;
1334
+ }
1335
+ else if (b->type == 1)
1336
+ {
1337
+ if (!b->dpname)
1338
+ return 0;
1339
+ /* Case 2: set name and GENERAL_NAMES appropriately */
1340
+ gens = a->name.fullname;
1341
+ nm = b->dpname;
1342
+ }
1343
+
1344
+ /* Handle case 2 with one GENERAL_NAMES and one X509_NAME */
1345
+ if (nm)
1346
+ {
1347
+ for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
1348
+ {
1349
+ gena = sk_GENERAL_NAME_value(gens, i);
1350
+ if (gena->type != GEN_DIRNAME)
1351
+ continue;
1352
+ if (!X509_NAME_cmp(nm, gena->d.directoryName))
1353
+ return 1;
1354
+ }
1355
+ return 0;
1356
+ }
1357
+
1358
+ /* Else case 3: two GENERAL_NAMES */
1359
+
1360
+ for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++)
1361
+ {
1362
+ gena = sk_GENERAL_NAME_value(a->name.fullname, i);
1363
+ for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++)
1364
+ {
1365
+ genb = sk_GENERAL_NAME_value(b->name.fullname, j);
1366
+ if (!GENERAL_NAME_cmp(gena, genb))
1367
+ return 1;
1368
+ }
1369
+ }
1370
+
1371
+ return 0;
1372
+
1373
+ }
1374
+
1375
+ static int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score)
1376
+ {
1377
+ size_t i;
1378
+ X509_NAME *nm = X509_CRL_get_issuer(crl);
1379
+ /* If no CRLissuer return is successful iff don't need a match */
1380
+ if (!dp->CRLissuer)
1381
+ return !!(crl_score & CRL_SCORE_ISSUER_NAME);
1382
+ for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++)
1383
+ {
1384
+ GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
1385
+ if (gen->type != GEN_DIRNAME)
1386
+ continue;
1387
+ if (!X509_NAME_cmp(gen->d.directoryName, nm))
1388
+ return 1;
1389
+ }
1390
+ return 0;
1391
+ }
1392
+
1393
+ /* Check CRLDP and IDP */
1394
+
1395
+ static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score,
1396
+ unsigned int *preasons)
1397
+ {
1398
+ size_t i;
1399
+ if (crl->idp_flags & IDP_ONLYATTR)
1400
+ return 0;
1401
+ if (x->ex_flags & EXFLAG_CA)
1402
+ {
1403
+ if (crl->idp_flags & IDP_ONLYUSER)
1404
+ return 0;
1405
+ }
1406
+ else
1407
+ {
1408
+ if (crl->idp_flags & IDP_ONLYCA)
1409
+ return 0;
1410
+ }
1411
+ *preasons = crl->idp_reasons;
1412
+ for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
1413
+ {
1414
+ DIST_POINT *dp = sk_DIST_POINT_value(x->crldp, i);
1415
+ if (crldp_check_crlissuer(dp, crl, crl_score))
1416
+ {
1417
+ if (!crl->idp ||
1418
+ idp_check_dp(dp->distpoint, crl->idp->distpoint))
1419
+ {
1420
+ *preasons &= dp->dp_reasons;
1421
+ return 1;
1422
+ }
1423
+ }
1424
+ }
1425
+ if ((!crl->idp || !crl->idp->distpoint) && (crl_score & CRL_SCORE_ISSUER_NAME))
1426
+ return 1;
1427
+ return 0;
1428
+ }
1429
+
1430
+ /* Retrieve CRL corresponding to current certificate.
1431
+ * If deltas enabled try to find a delta CRL too
1432
+ */
1433
+
1434
+ static int get_crl_delta(X509_STORE_CTX *ctx,
1435
+ X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x)
1436
+ {
1437
+ int ok;
1438
+ X509 *issuer = NULL;
1439
+ int crl_score = 0;
1440
+ unsigned int reasons;
1441
+ X509_CRL *crl = NULL, *dcrl = NULL;
1442
+ STACK_OF(X509_CRL) *skcrl;
1443
+ X509_NAME *nm = X509_get_issuer_name(x);
1444
+ reasons = ctx->current_reasons;
1445
+ ok = get_crl_sk(ctx, &crl, &dcrl,
1446
+ &issuer, &crl_score, &reasons, ctx->crls);
1447
+
1448
+ if (ok)
1449
+ goto done;
1450
+
1451
+ /* Lookup CRLs from store */
1452
+
1453
+ skcrl = ctx->lookup_crls(ctx, nm);
1454
+
1455
+ /* If no CRLs found and a near match from get_crl_sk use that */
1456
+ if (!skcrl && crl)
1457
+ goto done;
1458
+
1459
+ get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl);
1460
+
1461
+ sk_X509_CRL_pop_free(skcrl, X509_CRL_free);
1462
+
1463
+ done:
1464
+
1465
+ /* If we got any kind of CRL use it and return success */
1466
+ if (crl)
1467
+ {
1468
+ ctx->current_issuer = issuer;
1469
+ ctx->current_crl_score = crl_score;
1470
+ ctx->current_reasons = reasons;
1471
+ *pcrl = crl;
1472
+ *pdcrl = dcrl;
1473
+ return 1;
1474
+ }
1475
+
1476
+ return 0;
1477
+ }
1478
+
1479
+ /* Check CRL validity */
1480
+ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
1481
+ {
1482
+ X509 *issuer = NULL;
1483
+ EVP_PKEY *ikey = NULL;
1484
+ int ok = 0, chnum, cnum;
1485
+ cnum = ctx->error_depth;
1486
+ chnum = sk_X509_num(ctx->chain) - 1;
1487
+ /* if we have an alternative CRL issuer cert use that */
1488
+ if (ctx->current_issuer)
1489
+ issuer = ctx->current_issuer;
1490
+
1491
+ /* Else find CRL issuer: if not last certificate then issuer
1492
+ * is next certificate in chain.
1493
+ */
1494
+ else if (cnum < chnum)
1495
+ issuer = sk_X509_value(ctx->chain, cnum + 1);
1496
+ else
1497
+ {
1498
+ issuer = sk_X509_value(ctx->chain, chnum);
1499
+ /* If not self signed, can't check signature */
1500
+ if(!ctx->check_issued(ctx, issuer, issuer))
1501
+ {
1502
+ ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER;
1503
+ ok = ctx->verify_cb(0, ctx);
1504
+ if(!ok) goto err;
1505
+ }
1506
+ }
1507
+
1508
+ if(issuer)
1509
+ {
1510
+ /* Skip most tests for deltas because they have already
1511
+ * been done
1512
+ */
1513
+ if (!crl->base_crl_number)
1514
+ {
1515
+ /* Check for cRLSign bit if keyUsage present */
1516
+ if ((issuer->ex_flags & EXFLAG_KUSAGE) &&
1517
+ !(issuer->ex_kusage & KU_CRL_SIGN))
1518
+ {
1519
+ ctx->error = X509_V_ERR_KEYUSAGE_NO_CRL_SIGN;
1520
+ ok = ctx->verify_cb(0, ctx);
1521
+ if(!ok) goto err;
1522
+ }
1523
+
1524
+ if (!(ctx->current_crl_score & CRL_SCORE_SCOPE))
1525
+ {
1526
+ ctx->error = X509_V_ERR_DIFFERENT_CRL_SCOPE;
1527
+ ok = ctx->verify_cb(0, ctx);
1528
+ if(!ok) goto err;
1529
+ }
1530
+
1531
+ if (!(ctx->current_crl_score & CRL_SCORE_SAME_PATH))
1532
+ {
1533
+ if (check_crl_path(ctx, ctx->current_issuer) <= 0)
1534
+ {
1535
+ ctx->error = X509_V_ERR_CRL_PATH_VALIDATION_ERROR;
1536
+ ok = ctx->verify_cb(0, ctx);
1537
+ if(!ok) goto err;
1538
+ }
1539
+ }
1540
+
1541
+ if (crl->idp_flags & IDP_INVALID)
1542
+ {
1543
+ ctx->error = X509_V_ERR_INVALID_EXTENSION;
1544
+ ok = ctx->verify_cb(0, ctx);
1545
+ if(!ok) goto err;
1546
+ }
1547
+
1548
+
1549
+ }
1550
+
1551
+ if (!(ctx->current_crl_score & CRL_SCORE_TIME))
1552
+ {
1553
+ ok = check_crl_time(ctx, crl, 1);
1554
+ if (!ok)
1555
+ goto err;
1556
+ }
1557
+
1558
+ /* Attempt to get issuer certificate public key */
1559
+ ikey = X509_get_pubkey(issuer);
1560
+
1561
+ if(!ikey)
1562
+ {
1563
+ ctx->error=X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
1564
+ ok = ctx->verify_cb(0, ctx);
1565
+ if (!ok) goto err;
1566
+ }
1567
+ else
1568
+ {
1569
+ int rv;
1570
+ rv = X509_CRL_check_suiteb(crl, ikey, ctx->param->flags);
1571
+ if (rv != X509_V_OK)
1572
+ {
1573
+ ctx->error=rv;
1574
+ ok = ctx->verify_cb(0, ctx);
1575
+ if (!ok)
1576
+ goto err;
1577
+ }
1578
+ /* Verify CRL signature */
1579
+ if(X509_CRL_verify(crl, ikey) <= 0)
1580
+ {
1581
+ ctx->error=X509_V_ERR_CRL_SIGNATURE_FAILURE;
1582
+ ok = ctx->verify_cb(0, ctx);
1583
+ if (!ok) goto err;
1584
+ }
1585
+ }
1586
+ }
1587
+
1588
+ ok = 1;
1589
+
1590
+ err:
1591
+ EVP_PKEY_free(ikey);
1592
+ return ok;
1593
+ }
1594
+
1595
+ /* Check certificate against CRL */
1596
+ static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x)
1597
+ {
1598
+ int ok;
1599
+ X509_REVOKED *rev;
1600
+ /* The rules changed for this... previously if a CRL contained
1601
+ * unhandled critical extensions it could still be used to indicate
1602
+ * a certificate was revoked. This has since been changed since
1603
+ * critical extension can change the meaning of CRL entries.
1604
+ */
1605
+ if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
1606
+ && (crl->flags & EXFLAG_CRITICAL))
1607
+ {
1608
+ ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION;
1609
+ ok = ctx->verify_cb(0, ctx);
1610
+ if(!ok)
1611
+ return 0;
1612
+ }
1613
+ /* Look for serial number of certificate in CRL
1614
+ * If found make sure reason is not removeFromCRL.
1615
+ */
1616
+ if (X509_CRL_get0_by_cert(crl, &rev, x))
1617
+ {
1618
+ if (rev->reason == CRL_REASON_REMOVE_FROM_CRL)
1619
+ return 2;
1620
+ ctx->error = X509_V_ERR_CERT_REVOKED;
1621
+ ok = ctx->verify_cb(0, ctx);
1622
+ if (!ok)
1623
+ return 0;
1624
+ }
1625
+
1626
+ return 1;
1627
+ }
1628
+
1629
+ static int check_policy(X509_STORE_CTX *ctx)
1630
+ {
1631
+ int ret;
1632
+ if (ctx->parent)
1633
+ return 1;
1634
+ ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain,
1635
+ ctx->param->policies, ctx->param->flags);
1636
+ if (ret == 0)
1637
+ {
1638
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
1639
+ return 0;
1640
+ }
1641
+ /* Invalid or inconsistent extensions */
1642
+ if (ret == -1)
1643
+ {
1644
+ /* Locate certificates with bad extensions and notify
1645
+ * callback.
1646
+ */
1647
+ X509 *x;
1648
+ size_t i;
1649
+ for (i = 1; i < sk_X509_num(ctx->chain); i++)
1650
+ {
1651
+ x = sk_X509_value(ctx->chain, i);
1652
+ if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
1653
+ continue;
1654
+ ctx->current_cert = x;
1655
+ ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION;
1656
+ if(!ctx->verify_cb(0, ctx))
1657
+ return 0;
1658
+ }
1659
+ return 1;
1660
+ }
1661
+ if (ret == -2)
1662
+ {
1663
+ ctx->current_cert = NULL;
1664
+ ctx->error = X509_V_ERR_NO_EXPLICIT_POLICY;
1665
+ return ctx->verify_cb(0, ctx);
1666
+ }
1667
+
1668
+ if (ctx->param->flags & X509_V_FLAG_NOTIFY_POLICY)
1669
+ {
1670
+ ctx->current_cert = NULL;
1671
+ ctx->error = X509_V_OK;
1672
+ if (!ctx->verify_cb(2, ctx))
1673
+ return 0;
1674
+ }
1675
+
1676
+ return 1;
1677
+ }
1678
+
1679
+ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
1680
+ {
1681
+ time_t *ptime;
1682
+ int i;
1683
+
1684
+ if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME)
1685
+ ptime = &ctx->param->check_time;
1686
+ else
1687
+ ptime = NULL;
1688
+
1689
+ i=X509_cmp_time(X509_get_notBefore(x), ptime);
1690
+ if (i == 0)
1691
+ {
1692
+ ctx->error=X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD;
1693
+ ctx->current_cert=x;
1694
+ if (!ctx->verify_cb(0, ctx))
1695
+ return 0;
1696
+ }
1697
+
1698
+ if (i > 0)
1699
+ {
1700
+ ctx->error=X509_V_ERR_CERT_NOT_YET_VALID;
1701
+ ctx->current_cert=x;
1702
+ if (!ctx->verify_cb(0, ctx))
1703
+ return 0;
1704
+ }
1705
+
1706
+ i=X509_cmp_time(X509_get_notAfter(x), ptime);
1707
+ if (i == 0)
1708
+ {
1709
+ ctx->error=X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD;
1710
+ ctx->current_cert=x;
1711
+ if (!ctx->verify_cb(0, ctx))
1712
+ return 0;
1713
+ }
1714
+
1715
+ if (i < 0)
1716
+ {
1717
+ ctx->error=X509_V_ERR_CERT_HAS_EXPIRED;
1718
+ ctx->current_cert=x;
1719
+ if (!ctx->verify_cb(0, ctx))
1720
+ return 0;
1721
+ }
1722
+
1723
+ return 1;
1724
+ }
1725
+
1726
+ static int internal_verify(X509_STORE_CTX *ctx)
1727
+ {
1728
+ int ok=0,n;
1729
+ X509 *xs,*xi;
1730
+ EVP_PKEY *pkey=NULL;
1731
+ int (*cb)(int xok,X509_STORE_CTX *xctx);
1732
+
1733
+ cb=ctx->verify_cb;
1734
+
1735
+ n=sk_X509_num(ctx->chain);
1736
+ ctx->error_depth=n-1;
1737
+ n--;
1738
+ xi=sk_X509_value(ctx->chain,n);
1739
+
1740
+ if (ctx->check_issued(ctx, xi, xi))
1741
+ xs=xi;
1742
+ else
1743
+ {
1744
+ if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN)
1745
+ {
1746
+ xs = xi;
1747
+ goto check_cert;
1748
+ }
1749
+ if (n <= 0)
1750
+ {
1751
+ ctx->error=X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
1752
+ ctx->current_cert=xi;
1753
+ ok=cb(0,ctx);
1754
+ goto end;
1755
+ }
1756
+ else
1757
+ {
1758
+ n--;
1759
+ ctx->error_depth=n;
1760
+ xs=sk_X509_value(ctx->chain,n);
1761
+ }
1762
+ }
1763
+
1764
+ /* ctx->error=0; not needed */
1765
+ while (n >= 0)
1766
+ {
1767
+ ctx->error_depth=n;
1768
+
1769
+ /* Skip signature check for self signed certificates unless
1770
+ * explicitly asked for. It doesn't add any security and
1771
+ * just wastes time.
1772
+ */
1773
+ if (!xs->valid && (xs != xi || (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE)))
1774
+ {
1775
+ if ((pkey=X509_get_pubkey(xi)) == NULL)
1776
+ {
1777
+ ctx->error=X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
1778
+ ctx->current_cert=xi;
1779
+ ok=(*cb)(0,ctx);
1780
+ if (!ok) goto end;
1781
+ }
1782
+ else if (X509_verify(xs,pkey) <= 0)
1783
+ {
1784
+ ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE;
1785
+ ctx->current_cert=xs;
1786
+ ok=(*cb)(0,ctx);
1787
+ if (!ok)
1788
+ {
1789
+ EVP_PKEY_free(pkey);
1790
+ goto end;
1791
+ }
1792
+ }
1793
+ EVP_PKEY_free(pkey);
1794
+ pkey=NULL;
1795
+ }
1796
+
1797
+ xs->valid = 1;
1798
+
1799
+ check_cert:
1800
+ ok = check_cert_time(ctx, xs);
1801
+ if (!ok)
1802
+ goto end;
1803
+
1804
+ /* The last error (if any) is still in the error value */
1805
+ ctx->current_issuer=xi;
1806
+ ctx->current_cert=xs;
1807
+ ok=(*cb)(1,ctx);
1808
+ if (!ok) goto end;
1809
+
1810
+ n--;
1811
+ if (n >= 0)
1812
+ {
1813
+ xi=xs;
1814
+ xs=sk_X509_value(ctx->chain,n);
1815
+ }
1816
+ }
1817
+ ok=1;
1818
+ end:
1819
+ return ok;
1820
+ }
1821
+
1822
+ int X509_cmp_current_time(const ASN1_TIME *ctm)
1823
+ {
1824
+ return X509_cmp_time(ctm, NULL);
1825
+ }
1826
+
1827
+ int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
1828
+ {
1829
+ char *str;
1830
+ ASN1_TIME atm;
1831
+ long offset;
1832
+ char buff1[24],buff2[24],*p;
1833
+ int i, j, remaining;
1834
+
1835
+ p=buff1;
1836
+ remaining = ctm->length;
1837
+ str=(char *)ctm->data;
1838
+ /* Note that the following (historical) code allows much more slack in
1839
+ * the time format than RFC5280. In RFC5280, the representation is
1840
+ * fixed:
1841
+ * UTCTime: YYMMDDHHMMSSZ
1842
+ * GeneralizedTime: YYYYMMDDHHMMSSZ */
1843
+ if (ctm->type == V_ASN1_UTCTIME)
1844
+ {
1845
+ /* YYMMDDHHMM[SS]Z or YYMMDDHHMM[SS](+-)hhmm */
1846
+ int min_length = sizeof("YYMMDDHHMMZ") - 1;
1847
+ int max_length = sizeof("YYMMDDHHMMSS+hhmm") - 1;
1848
+ if (remaining < min_length || remaining > max_length)
1849
+ return 0;
1850
+ memcpy(p,str,10);
1851
+ p+=10;
1852
+ str+=10;
1853
+ remaining -= 10;
1854
+ }
1855
+ else
1856
+ {
1857
+ /* YYYYMMDDHHMM[SS[.fff]]Z or YYYYMMDDHHMM[SS[.f[f[f]]]](+-)hhmm */
1858
+ int min_length = sizeof("YYYYMMDDHHMMZ") - 1;
1859
+ int max_length = sizeof("YYYYMMDDHHMMSS.fff+hhmm") - 1;
1860
+ if (remaining < min_length || remaining > max_length)
1861
+ return 0;
1862
+ memcpy(p,str,12);
1863
+ p+=12;
1864
+ str+=12;
1865
+ remaining -= 12;
1866
+ }
1867
+
1868
+ if ((*str == 'Z') || (*str == '-') || (*str == '+'))
1869
+ { *(p++)='0'; *(p++)='0'; }
1870
+ else
1871
+ {
1872
+ /* SS (seconds) */
1873
+ if (remaining < 2)
1874
+ return 0;
1875
+ *(p++)= *(str++);
1876
+ *(p++)= *(str++);
1877
+ remaining -= 2;
1878
+ /* Skip any (up to three) fractional seconds...
1879
+ * TODO(emilia): in RFC5280, fractional seconds are forbidden.
1880
+ * Can we just kill them altogether? */
1881
+ if (remaining && *str == '.')
1882
+ {
1883
+ str++;
1884
+ remaining--;
1885
+ for (i = 0; i < 3 && remaining; i++, str++, remaining--)
1886
+ {
1887
+ if (*str < '0' || *str > '9')
1888
+ break;
1889
+ }
1890
+ }
1891
+
1892
+ }
1893
+ *(p++)='Z';
1894
+ *(p++)='\0';
1895
+
1896
+ /* We now need either a terminating 'Z' or an offset. */
1897
+ if (!remaining)
1898
+ return 0;
1899
+ if (*str == 'Z')
1900
+ {
1901
+ if (remaining != 1)
1902
+ return 0;
1903
+ offset=0;
1904
+ }
1905
+ else
1906
+ {
1907
+ /* (+-)HHMM */
1908
+ if ((*str != '+') && (*str != '-'))
1909
+ return 0;
1910
+ /* Historical behaviour: the (+-)hhmm offset is forbidden in RFC5280. */
1911
+ if (remaining != 5)
1912
+ return 0;
1913
+ if (str[1] < '0' || str[1] > '9' || str[2] < '0' || str[2] > '9' ||
1914
+ str[3] < '0' || str[3] > '9' || str[4] < '0' || str[4] > '9')
1915
+ return 0;
1916
+ offset=((str[1]-'0')*10+(str[2]-'0'))*60;
1917
+ offset+=(str[3]-'0')*10+(str[4]-'0');
1918
+ if (*str == '-')
1919
+ offset= -offset;
1920
+ }
1921
+ atm.type=ctm->type;
1922
+ atm.flags = 0;
1923
+ atm.length=sizeof(buff2);
1924
+ atm.data=(unsigned char *)buff2;
1925
+
1926
+ if (X509_time_adj(&atm, offset*60, cmp_time) == NULL)
1927
+ return 0;
1928
+
1929
+ if (ctm->type == V_ASN1_UTCTIME)
1930
+ {
1931
+ i=(buff1[0]-'0')*10+(buff1[1]-'0');
1932
+ if (i < 50) i+=100; /* cf. RFC 2459 */
1933
+ j=(buff2[0]-'0')*10+(buff2[1]-'0');
1934
+ if (j < 50) j+=100;
1935
+
1936
+ if (i < j) return -1;
1937
+ if (i > j) return 1;
1938
+ }
1939
+ i=strcmp(buff1,buff2);
1940
+ if (i == 0) /* wait a second then return younger :-) */
1941
+ return -1;
1942
+ else
1943
+ return i;
1944
+ }
1945
+
1946
+ ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj)
1947
+ {
1948
+ return X509_time_adj(s, adj, NULL);
1949
+ }
1950
+
1951
+ ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_tm)
1952
+ {
1953
+ return X509_time_adj_ex(s, 0, offset_sec, in_tm);
1954
+ }
1955
+
1956
+ ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
1957
+ int offset_day, long offset_sec, time_t *in_tm)
1958
+ {
1959
+ time_t t = 0;
1960
+
1961
+ if (in_tm) t = *in_tm;
1962
+ else time(&t);
1963
+
1964
+ if (s && !(s->flags & ASN1_STRING_FLAG_MSTRING))
1965
+ {
1966
+ if (s->type == V_ASN1_UTCTIME)
1967
+ return ASN1_UTCTIME_adj(s,t, offset_day, offset_sec);
1968
+ if (s->type == V_ASN1_GENERALIZEDTIME)
1969
+ return ASN1_GENERALIZEDTIME_adj(s, t, offset_day,
1970
+ offset_sec);
1971
+ }
1972
+ return ASN1_TIME_adj(s, t, offset_day, offset_sec);
1973
+ }
1974
+
1975
+ /* Make a delta CRL as the diff between two full CRLs */
1976
+
1977
+ X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
1978
+ EVP_PKEY *skey, const EVP_MD *md, unsigned int flags)
1979
+ {
1980
+ X509_CRL *crl = NULL;
1981
+ int i;
1982
+ size_t j;
1983
+ STACK_OF(X509_REVOKED) *revs = NULL;
1984
+ /* CRLs can't be delta already */
1985
+ if (base->base_crl_number || newer->base_crl_number)
1986
+ {
1987
+ OPENSSL_PUT_ERROR(X509, X509_R_CRL_ALREADY_DELTA);
1988
+ return NULL;
1989
+ }
1990
+ /* Base and new CRL must have a CRL number */
1991
+ if (!base->crl_number || !newer->crl_number)
1992
+ {
1993
+ OPENSSL_PUT_ERROR(X509, X509_R_NO_CRL_NUMBER);
1994
+ return NULL;
1995
+ }
1996
+ /* Issuer names must match */
1997
+ if (X509_NAME_cmp(X509_CRL_get_issuer(base),
1998
+ X509_CRL_get_issuer(newer)))
1999
+ {
2000
+ OPENSSL_PUT_ERROR(X509, X509_R_ISSUER_MISMATCH);
2001
+ return NULL;
2002
+ }
2003
+ /* AKID and IDP must match */
2004
+ if (!crl_extension_match(base, newer, NID_authority_key_identifier))
2005
+ {
2006
+ OPENSSL_PUT_ERROR(X509, X509_R_AKID_MISMATCH);
2007
+ return NULL;
2008
+ }
2009
+ if (!crl_extension_match(base, newer, NID_issuing_distribution_point))
2010
+ {
2011
+ OPENSSL_PUT_ERROR(X509, X509_R_IDP_MISMATCH);
2012
+ return NULL;
2013
+ }
2014
+ /* Newer CRL number must exceed full CRL number */
2015
+ if (ASN1_INTEGER_cmp(newer->crl_number, base->crl_number) <= 0)
2016
+ {
2017
+ OPENSSL_PUT_ERROR(X509, X509_R_NEWER_CRL_NOT_NEWER);
2018
+ return NULL;
2019
+ }
2020
+ /* CRLs must verify */
2021
+ if (skey && (X509_CRL_verify(base, skey) <= 0 ||
2022
+ X509_CRL_verify(newer, skey) <= 0))
2023
+ {
2024
+ OPENSSL_PUT_ERROR(X509, X509_R_CRL_VERIFY_FAILURE);
2025
+ return NULL;
2026
+ }
2027
+ /* Create new CRL */
2028
+ crl = X509_CRL_new();
2029
+ if (!crl || !X509_CRL_set_version(crl, 1))
2030
+ goto memerr;
2031
+ /* Set issuer name */
2032
+ if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer)))
2033
+ goto memerr;
2034
+
2035
+ if (!X509_CRL_set_lastUpdate(crl, X509_CRL_get_lastUpdate(newer)))
2036
+ goto memerr;
2037
+ if (!X509_CRL_set_nextUpdate(crl, X509_CRL_get_nextUpdate(newer)))
2038
+ goto memerr;
2039
+
2040
+ /* Set base CRL number: must be critical */
2041
+
2042
+ if (!X509_CRL_add1_ext_i2d(crl, NID_delta_crl, base->crl_number, 1, 0))
2043
+ goto memerr;
2044
+
2045
+ /* Copy extensions across from newest CRL to delta: this will set
2046
+ * CRL number to correct value too.
2047
+ */
2048
+
2049
+ for (i = 0; i < X509_CRL_get_ext_count(newer); i++)
2050
+ {
2051
+ X509_EXTENSION *ext;
2052
+ ext = X509_CRL_get_ext(newer, i);
2053
+ if (!X509_CRL_add_ext(crl, ext, -1))
2054
+ goto memerr;
2055
+ }
2056
+
2057
+ /* Go through revoked entries, copying as needed */
2058
+
2059
+ revs = X509_CRL_get_REVOKED(newer);
2060
+
2061
+ for (j = 0; j < sk_X509_REVOKED_num(revs); j++)
2062
+ {
2063
+ X509_REVOKED *rvn, *rvtmp;
2064
+ rvn = sk_X509_REVOKED_value(revs, j);
2065
+ /* Add only if not also in base.
2066
+ * TODO: need something cleverer here for some more complex
2067
+ * CRLs covering multiple CAs.
2068
+ */
2069
+ if (!X509_CRL_get0_by_serial(base, &rvtmp, rvn->serialNumber))
2070
+ {
2071
+ rvtmp = X509_REVOKED_dup(rvn);
2072
+ if (!rvtmp)
2073
+ goto memerr;
2074
+ if (!X509_CRL_add0_revoked(crl, rvtmp))
2075
+ {
2076
+ X509_REVOKED_free(rvtmp);
2077
+ goto memerr;
2078
+ }
2079
+ }
2080
+ }
2081
+ /* TODO: optionally prune deleted entries */
2082
+
2083
+ if (skey && md && !X509_CRL_sign(crl, skey, md))
2084
+ goto memerr;
2085
+
2086
+ return crl;
2087
+
2088
+ memerr:
2089
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
2090
+ if (crl)
2091
+ X509_CRL_free(crl);
2092
+ return NULL;
2093
+ }
2094
+
2095
+ int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
2096
+ CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
2097
+ {
2098
+ /* This function is (usually) called only once, by
2099
+ * SSL_get_ex_data_X509_STORE_CTX_idx (ssl/ssl_cert.c). */
2100
+ int index;
2101
+ if (!CRYPTO_get_ex_new_index(&g_ex_data_class, &index, argl, argp,
2102
+ dup_func, free_func))
2103
+ {
2104
+ return -1;
2105
+ }
2106
+ return index;
2107
+ }
2108
+
2109
+ int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data)
2110
+ {
2111
+ return CRYPTO_set_ex_data(&ctx->ex_data,idx,data);
2112
+ }
2113
+
2114
+ void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx)
2115
+ {
2116
+ return CRYPTO_get_ex_data(&ctx->ex_data,idx);
2117
+ }
2118
+
2119
+ int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx)
2120
+ {
2121
+ return ctx->error;
2122
+ }
2123
+
2124
+ void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err)
2125
+ {
2126
+ ctx->error=err;
2127
+ }
2128
+
2129
+ int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx)
2130
+ {
2131
+ return ctx->error_depth;
2132
+ }
2133
+
2134
+ X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx)
2135
+ {
2136
+ return ctx->current_cert;
2137
+ }
2138
+
2139
+ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
2140
+ {
2141
+ return ctx->chain;
2142
+ }
2143
+
2144
+ STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
2145
+ {
2146
+ if (!ctx->chain)
2147
+ return NULL;
2148
+ return X509_chain_up_ref(ctx->chain);
2149
+ }
2150
+
2151
+ X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx)
2152
+ {
2153
+ return ctx->current_issuer;
2154
+ }
2155
+
2156
+ X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx)
2157
+ {
2158
+ return ctx->current_crl;
2159
+ }
2160
+
2161
+ X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx)
2162
+ {
2163
+ return ctx->parent;
2164
+ }
2165
+
2166
+ void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
2167
+ {
2168
+ ctx->cert=x;
2169
+ }
2170
+
2171
+ void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
2172
+ {
2173
+ ctx->untrusted=sk;
2174
+ }
2175
+
2176
+ void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk)
2177
+ {
2178
+ ctx->crls=sk;
2179
+ }
2180
+
2181
+ int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose)
2182
+ {
2183
+ return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0);
2184
+ }
2185
+
2186
+ int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust)
2187
+ {
2188
+ return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust);
2189
+ }
2190
+
2191
+ /* This function is used to set the X509_STORE_CTX purpose and trust
2192
+ * values. This is intended to be used when another structure has its
2193
+ * own trust and purpose values which (if set) will be inherited by
2194
+ * the ctx. If they aren't set then we will usually have a default
2195
+ * purpose in mind which should then be used to set the trust value.
2196
+ * An example of this is SSL use: an SSL structure will have its own
2197
+ * purpose and trust settings which the application can set: if they
2198
+ * aren't set then we use the default of SSL client/server.
2199
+ */
2200
+
2201
+ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
2202
+ int purpose, int trust)
2203
+ {
2204
+ int idx;
2205
+ /* If purpose not set use default */
2206
+ if (!purpose) purpose = def_purpose;
2207
+ /* If we have a purpose then check it is valid */
2208
+ if (purpose)
2209
+ {
2210
+ X509_PURPOSE *ptmp;
2211
+ idx = X509_PURPOSE_get_by_id(purpose);
2212
+ if (idx == -1)
2213
+ {
2214
+ OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_PURPOSE_ID);
2215
+ return 0;
2216
+ }
2217
+ ptmp = X509_PURPOSE_get0(idx);
2218
+ if (ptmp->trust == X509_TRUST_DEFAULT)
2219
+ {
2220
+ idx = X509_PURPOSE_get_by_id(def_purpose);
2221
+ if (idx == -1)
2222
+ {
2223
+ OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_PURPOSE_ID);
2224
+ return 0;
2225
+ }
2226
+ ptmp = X509_PURPOSE_get0(idx);
2227
+ }
2228
+ /* If trust not set then get from purpose default */
2229
+ if (!trust) trust = ptmp->trust;
2230
+ }
2231
+ if (trust)
2232
+ {
2233
+ idx = X509_TRUST_get_by_id(trust);
2234
+ if (idx == -1)
2235
+ {
2236
+ OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_TRUST_ID);
2237
+ return 0;
2238
+ }
2239
+ }
2240
+
2241
+ if (purpose && !ctx->param->purpose) ctx->param->purpose = purpose;
2242
+ if (trust && !ctx->param->trust) ctx->param->trust = trust;
2243
+ return 1;
2244
+ }
2245
+
2246
+ X509_STORE_CTX *X509_STORE_CTX_new(void)
2247
+ {
2248
+ X509_STORE_CTX *ctx;
2249
+ ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX));
2250
+ if (!ctx)
2251
+ {
2252
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
2253
+ return NULL;
2254
+ }
2255
+ memset(ctx, 0, sizeof(X509_STORE_CTX));
2256
+ return ctx;
2257
+ }
2258
+
2259
+ void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
2260
+ {
2261
+ X509_STORE_CTX_cleanup(ctx);
2262
+ OPENSSL_free(ctx);
2263
+ }
2264
+
2265
+ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
2266
+ STACK_OF(X509) *chain)
2267
+ {
2268
+ int ret = 1;
2269
+
2270
+ memset(ctx, 0, sizeof(X509_STORE_CTX));
2271
+ ctx->ctx=store;
2272
+ ctx->cert=x509;
2273
+ ctx->untrusted=chain;
2274
+
2275
+ CRYPTO_new_ex_data(&ctx->ex_data);
2276
+
2277
+ ctx->param = X509_VERIFY_PARAM_new();
2278
+ if (!ctx->param)
2279
+ goto err;
2280
+
2281
+ /* Inherit callbacks and flags from X509_STORE if not set
2282
+ * use defaults. */
2283
+
2284
+ if (store)
2285
+ ret = X509_VERIFY_PARAM_inherit(ctx->param, store->param);
2286
+ else
2287
+ ctx->param->inh_flags |= X509_VP_FLAG_DEFAULT|X509_VP_FLAG_ONCE;
2288
+
2289
+ if (store)
2290
+ {
2291
+ ctx->verify_cb = store->verify_cb;
2292
+ ctx->cleanup = store->cleanup;
2293
+ }
2294
+ else
2295
+ ctx->cleanup = 0;
2296
+
2297
+ if (ret)
2298
+ ret = X509_VERIFY_PARAM_inherit(ctx->param,
2299
+ X509_VERIFY_PARAM_lookup("default"));
2300
+
2301
+ if (ret == 0)
2302
+ goto err;
2303
+
2304
+ if (store && store->check_issued)
2305
+ ctx->check_issued = store->check_issued;
2306
+ else
2307
+ ctx->check_issued = check_issued;
2308
+
2309
+ if (store && store->get_issuer)
2310
+ ctx->get_issuer = store->get_issuer;
2311
+ else
2312
+ ctx->get_issuer = X509_STORE_CTX_get1_issuer;
2313
+
2314
+ if (store && store->verify_cb)
2315
+ ctx->verify_cb = store->verify_cb;
2316
+ else
2317
+ ctx->verify_cb = null_callback;
2318
+
2319
+ if (store && store->verify)
2320
+ ctx->verify = store->verify;
2321
+ else
2322
+ ctx->verify = internal_verify;
2323
+
2324
+ if (store && store->check_revocation)
2325
+ ctx->check_revocation = store->check_revocation;
2326
+ else
2327
+ ctx->check_revocation = check_revocation;
2328
+
2329
+ if (store && store->get_crl)
2330
+ ctx->get_crl = store->get_crl;
2331
+ else
2332
+ ctx->get_crl = NULL;
2333
+
2334
+ if (store && store->check_crl)
2335
+ ctx->check_crl = store->check_crl;
2336
+ else
2337
+ ctx->check_crl = check_crl;
2338
+
2339
+ if (store && store->cert_crl)
2340
+ ctx->cert_crl = store->cert_crl;
2341
+ else
2342
+ ctx->cert_crl = cert_crl;
2343
+
2344
+ if (store && store->lookup_certs)
2345
+ ctx->lookup_certs = store->lookup_certs;
2346
+ else
2347
+ ctx->lookup_certs = X509_STORE_get1_certs;
2348
+
2349
+ if (store && store->lookup_crls)
2350
+ ctx->lookup_crls = store->lookup_crls;
2351
+ else
2352
+ ctx->lookup_crls = X509_STORE_get1_crls;
2353
+
2354
+ ctx->check_policy = check_policy;
2355
+
2356
+ return 1;
2357
+
2358
+ err:
2359
+ CRYPTO_free_ex_data(&g_ex_data_class, ctx, &ctx->ex_data);
2360
+ if (ctx->param != NULL)
2361
+ {
2362
+ X509_VERIFY_PARAM_free(ctx->param);
2363
+ }
2364
+
2365
+ memset(ctx, 0, sizeof(X509_STORE_CTX));
2366
+ OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
2367
+ return 0;
2368
+ }
2369
+
2370
+ /* Set alternative lookup method: just a STACK of trusted certificates.
2371
+ * This avoids X509_STORE nastiness where it isn't needed.
2372
+ */
2373
+
2374
+ void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
2375
+ {
2376
+ ctx->other_ctx = sk;
2377
+ ctx->get_issuer = get_issuer_sk;
2378
+ }
2379
+
2380
+ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
2381
+ {
2382
+ if (ctx->cleanup) ctx->cleanup(ctx);
2383
+ if (ctx->param != NULL)
2384
+ {
2385
+ if (ctx->parent == NULL)
2386
+ X509_VERIFY_PARAM_free(ctx->param);
2387
+ ctx->param=NULL;
2388
+ }
2389
+ if (ctx->tree != NULL)
2390
+ {
2391
+ X509_policy_tree_free(ctx->tree);
2392
+ ctx->tree=NULL;
2393
+ }
2394
+ if (ctx->chain != NULL)
2395
+ {
2396
+ sk_X509_pop_free(ctx->chain,X509_free);
2397
+ ctx->chain=NULL;
2398
+ }
2399
+ CRYPTO_free_ex_data(&g_ex_data_class, ctx, &(ctx->ex_data));
2400
+ memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA));
2401
+ }
2402
+
2403
+ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth)
2404
+ {
2405
+ X509_VERIFY_PARAM_set_depth(ctx->param, depth);
2406
+ }
2407
+
2408
+ void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags)
2409
+ {
2410
+ X509_VERIFY_PARAM_set_flags(ctx->param, flags);
2411
+ }
2412
+
2413
+ void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, time_t t)
2414
+ {
2415
+ X509_VERIFY_PARAM_set_time(ctx->param, t);
2416
+ }
2417
+
2418
+ void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
2419
+ int (*verify_cb)(int, X509_STORE_CTX *))
2420
+ {
2421
+ ctx->verify_cb=verify_cb;
2422
+ }
2423
+
2424
+ X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx)
2425
+ {
2426
+ return ctx->tree;
2427
+ }
2428
+
2429
+ int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx)
2430
+ {
2431
+ return ctx->explicit_policy;
2432
+ }
2433
+
2434
+ int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name)
2435
+ {
2436
+ const X509_VERIFY_PARAM *param;
2437
+ param = X509_VERIFY_PARAM_lookup(name);
2438
+ if (!param)
2439
+ return 0;
2440
+ return X509_VERIFY_PARAM_inherit(ctx->param, param);
2441
+ }
2442
+
2443
+ X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx)
2444
+ {
2445
+ return ctx->param;
2446
+ }
2447
+
2448
+ void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param)
2449
+ {
2450
+ if (ctx->param)
2451
+ X509_VERIFY_PARAM_free(ctx->param);
2452
+ ctx->param = param;
2453
+ }
2454
+
2455
+ IMPLEMENT_ASN1_SET_OF(X509)
2456
+ IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)