prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  TLS logging broken with new cryptography
  https://github.com/pyca/cryptography/pull/8391 dropped `SSL_get_server_tmp_key()` so we need to disable the code that uses it if it's not available.
  
  </issue>
  <code>
  [start of scrapy/utils/ssl.py]
  1 import OpenSSL._util as pyOpenSSLutil
  2 import OpenSSL.SSL
  3 
  4 from scrapy.utils.python import to_unicode
  5 
  6 
  7 def ffi_buf_to_string(buf):
  8     return to_unicode(pyOpenSSLutil.ffi.string(buf))
  9 
  10 
  11 def x509name_to_string(x509name):
  12     # from OpenSSL.crypto.X509Name.__repr__
  13     result_buffer = pyOpenSSLutil.ffi.new("char[]", 512)
  14     pyOpenSSLutil.lib.X509_NAME_oneline(
  15         x509name._name, result_buffer, len(result_buffer)
  16     )
  17 
  18     return ffi_buf_to_string(result_buffer)
  19 
  20 
  21 def get_temp_key_info(ssl_object):
  22     # adapted from OpenSSL apps/s_cb.c::ssl_print_tmp_key()
  23     temp_key_p = pyOpenSSLutil.ffi.new("EVP_PKEY **")
  24     if not pyOpenSSLutil.lib.SSL_get_server_tmp_key(ssl_object, temp_key_p):
  25         return None
  26     temp_key = temp_key_p[0]
  27     if temp_key == pyOpenSSLutil.ffi.NULL:
  28         return None
  29     temp_key = pyOpenSSLutil.ffi.gc(temp_key, pyOpenSSLutil.lib.EVP_PKEY_free)
  30     key_info = []
  31     key_type = pyOpenSSLutil.lib.EVP_PKEY_id(temp_key)
  32     if key_type == pyOpenSSLutil.lib.EVP_PKEY_RSA:
  33         key_info.append("RSA")
  34     elif key_type == pyOpenSSLutil.lib.EVP_PKEY_DH:
  35         key_info.append("DH")
  36     elif key_type == pyOpenSSLutil.lib.EVP_PKEY_EC:
  37         key_info.append("ECDH")
  38         ec_key = pyOpenSSLutil.lib.EVP_PKEY_get1_EC_KEY(temp_key)
  39         ec_key = pyOpenSSLutil.ffi.gc(ec_key, pyOpenSSLutil.lib.EC_KEY_free)
  40         nid = pyOpenSSLutil.lib.EC_GROUP_get_curve_name(
  41             pyOpenSSLutil.lib.EC_KEY_get0_group(ec_key)
  42         )
  43         cname = pyOpenSSLutil.lib.EC_curve_nid2nist(nid)
  44         if cname == pyOpenSSLutil.ffi.NULL:
  45             cname = pyOpenSSLutil.lib.OBJ_nid2sn(nid)
  46         key_info.append(ffi_buf_to_string(cname))
  47     else:
  48         key_info.append(ffi_buf_to_string(pyOpenSSLutil.lib.OBJ_nid2sn(key_type)))
  49     key_info.append(f"{pyOpenSSLutil.lib.EVP_PKEY_bits(temp_key)} bits")
  50     return ", ".join(key_info)
  51 
  52 
  53 def get_openssl_version():
  54     system_openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION).decode(
  55         "ascii", errors="replace"
  56     )
  57     return f"{OpenSSL.version.__version__} ({system_openssl})"
  58
  [end of scrapy/utils/ssl.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/scrapy/utils/ssl.py b/scrapy/utils/ssl.py
  --- a/scrapy/utils/ssl.py
  +++ b/scrapy/utils/ssl.py
  @@ -20,6 +20,9 @@
   
   def get_temp_key_info(ssl_object):
       # adapted from OpenSSL apps/s_cb.c::ssl_print_tmp_key()
  +    if not hasattr(pyOpenSSLutil.lib, "SSL_get_server_tmp_key"):
  +        # removed in cryptography 40.0.0
  +        return None
       temp_key_p = pyOpenSSLutil.ffi.new("EVP_PKEY **")
       if not pyOpenSSLutil.lib.SSL_get_server_tmp_key(ssl_object, temp_key_p):
           return None
  
verification_info: {"golden_diff": "diff --git a/scrapy/utils/ssl.py b/scrapy/utils/ssl.py\n--- a/scrapy/utils/ssl.py\n+++ b/scrapy/utils/ssl.py\n@@ -20,6 +20,9 @@\n \n def get_temp_key_info(ssl_object):\n     # adapted from OpenSSL apps/s_cb.c::ssl_print_tmp_key()\n+    if not hasattr(pyOpenSSLutil.lib, \"SSL_get_server_tmp_key\"):\n+        # removed in cryptography 40.0.0\n+        return None\n     temp_key_p = pyOpenSSLutil.ffi.new(\"EVP_PKEY **\")\n     if not pyOpenSSLutil.lib.SSL_get_server_tmp_key(ssl_object, temp_key_p):\n         return None\n", "issue": "TLS logging broken with new cryptography\nhttps://github.com/pyca/cryptography/pull/8391 dropped `SSL_get_server_tmp_key()` so we need to disable the code that uses it if it's not available.\n", "before_files": [{"content": "import OpenSSL._util as pyOpenSSLutil\nimport OpenSSL.SSL\n\nfrom scrapy.utils.python import to_unicode\n\n\ndef ffi_buf_to_string(buf):\n    return to_unicode(pyOpenSSLutil.ffi.string(buf))\n\n\ndef x509name_to_string(x509name):\n    # from OpenSSL.crypto.X509Name.__repr__\n    result_buffer = pyOpenSSLutil.ffi.new(\"char[]\", 512)\n    pyOpenSSLutil.lib.X509_NAME_oneline(\n        x509name._name, result_buffer, len(result_buffer)\n    )\n\n    return ffi_buf_to_string(result_buffer)\n\n\ndef get_temp_key_info(ssl_object):\n    # adapted from OpenSSL apps/s_cb.c::ssl_print_tmp_key()\n    temp_key_p = pyOpenSSLutil.ffi.new(\"EVP_PKEY **\")\n    if not pyOpenSSLutil.lib.SSL_get_server_tmp_key(ssl_object, temp_key_p):\n        return None\n    temp_key = temp_key_p[0]\n    if temp_key == pyOpenSSLutil.ffi.NULL:\n        return None\n    temp_key = pyOpenSSLutil.ffi.gc(temp_key, pyOpenSSLutil.lib.EVP_PKEY_free)\n    key_info = []\n    key_type = pyOpenSSLutil.lib.EVP_PKEY_id(temp_key)\n    if key_type == pyOpenSSLutil.lib.EVP_PKEY_RSA:\n        key_info.append(\"RSA\")\n    elif key_type == pyOpenSSLutil.lib.EVP_PKEY_DH:\n        key_info.append(\"DH\")\n    elif key_type == pyOpenSSLutil.lib.EVP_PKEY_EC:\n        key_info.append(\"ECDH\")\n        ec_key = pyOpenSSLutil.lib.EVP_PKEY_get1_EC_KEY(temp_key)\n        ec_key = pyOpenSSLutil.ffi.gc(ec_key, pyOpenSSLutil.lib.EC_KEY_free)\n        nid = pyOpenSSLutil.lib.EC_GROUP_get_curve_name(\n            pyOpenSSLutil.lib.EC_KEY_get0_group(ec_key)\n        )\n        cname = pyOpenSSLutil.lib.EC_curve_nid2nist(nid)\n        if cname == pyOpenSSLutil.ffi.NULL:\n            cname = pyOpenSSLutil.lib.OBJ_nid2sn(nid)\n        key_info.append(ffi_buf_to_string(cname))\n    else:\n        key_info.append(ffi_buf_to_string(pyOpenSSLutil.lib.OBJ_nid2sn(key_type)))\n    key_info.append(f\"{pyOpenSSLutil.lib.EVP_PKEY_bits(temp_key)} bits\")\n    return \", \".join(key_info)\n\n\ndef get_openssl_version():\n    system_openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION).decode(\n        \"ascii\", errors=\"replace\"\n    )\n    return f\"{OpenSSL.version.__version__} ({system_openssl})\"\n", "path": "scrapy/utils/ssl.py"}]}