We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ignore FRP256v1 in wycheproof tests


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cryptography/hazmat/backends/openssl/utils.py`
Content:
```
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4 
5 import typing
6 
7 from cryptography.hazmat.primitives import hashes
8 from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
9 
10 if typing.TYPE_CHECKING:
11     from cryptography.hazmat.backends.openssl.backend import Backend
12 
13 
14 def _evp_pkey_derive(backend: "Backend", evp_pkey, peer_public_key) -> bytes:
15     ctx = backend._lib.EVP_PKEY_CTX_new(evp_pkey, backend._ffi.NULL)
16     backend.openssl_assert(ctx != backend._ffi.NULL)
17     ctx = backend._ffi.gc(ctx, backend._lib.EVP_PKEY_CTX_free)
18     res = backend._lib.EVP_PKEY_derive_init(ctx)
19     backend.openssl_assert(res == 1)
20     res = backend._lib.EVP_PKEY_derive_set_peer(ctx, peer_public_key._evp_pkey)
21     backend.openssl_assert(res == 1)
22     keylen = backend._ffi.new("size_t *")
23     res = backend._lib.EVP_PKEY_derive(ctx, backend._ffi.NULL, keylen)
24     backend.openssl_assert(res == 1)
25     backend.openssl_assert(keylen[0] > 0)
26     buf = backend._ffi.new("unsigned char[]", keylen[0])
27     res = backend._lib.EVP_PKEY_derive(ctx, buf, keylen)
28     if res != 1:
29         errors_with_text = backend._consume_errors_with_text()
30         raise ValueError("Error computing shared key.", errors_with_text)
31 
32     return backend._ffi.buffer(buf, keylen[0])[:]
33 
34 
35 def _calculate_digest_and_algorithm(
36     data: bytes,
37     algorithm: typing.Union[Prehashed, hashes.HashAlgorithm],
38 ) -> typing.Tuple[bytes, hashes.HashAlgorithm]:
39     if not isinstance(algorithm, Prehashed):
40         hash_ctx = hashes.Hash(algorithm)
41         hash_ctx.update(data)
42         data = hash_ctx.finalize()
43     else:
44         algorithm = algorithm._algorithm
45 
46     if len(data) != algorithm.digest_size:
47         raise ValueError(
48             "The provided data must be the same length as the hash "
49             "algorithm's digest size."
50         )
51 
52     return (data, algorithm)
53
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cryptography/hazmat/backends/openssl/utils.py b/src/cryptography/hazmat/backends/openssl/utils.py
--- a/src/cryptography/hazmat/backends/openssl/utils.py
+++ b/src/cryptography/hazmat/backends/openssl/utils.py
@@ -18,7 +18,10 @@
     res = backend._lib.EVP_PKEY_derive_init(ctx)
     backend.openssl_assert(res == 1)
     res = backend._lib.EVP_PKEY_derive_set_peer(ctx, peer_public_key._evp_pkey)
-    backend.openssl_assert(res == 1)
+    if res != 1:
+        errors_with_text = backend._consume_errors_with_text()
+        raise ValueError("Error computing shared key.", errors_with_text)
+
     keylen = backend._ffi.new("size_t *")
     res = backend._lib.EVP_PKEY_derive(ctx, backend._ffi.NULL, keylen)
     backend.openssl_assert(res == 1)

{"golden_diff": "diff --git a/src/cryptography/hazmat/backends/openssl/utils.py b/src/cryptography/hazmat/backends/openssl/utils.py\n--- a/src/cryptography/hazmat/backends/openssl/utils.py\n+++ b/src/cryptography/hazmat/backends/openssl/utils.py\n@@ -18,7 +18,10 @@\n     res = backend._lib.EVP_PKEY_derive_init(ctx)\n     backend.openssl_assert(res == 1)\n     res = backend._lib.EVP_PKEY_derive_set_peer(ctx, peer_public_key._evp_pkey)\n-    backend.openssl_assert(res == 1)\n+    if res != 1:\n+        errors_with_text = backend._consume_errors_with_text()\n+        raise ValueError(\"Error computing shared key.\", errors_with_text)\n+\n     keylen = backend._ffi.new(\"size_t *\")\n     res = backend._lib.EVP_PKEY_derive(ctx, backend._ffi.NULL, keylen)\n     backend.openssl_assert(res == 1)\n", "issue": "ignore FRP256v1 in wycheproof tests\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nimport typing\n\nfrom cryptography.hazmat.primitives import hashes\nfrom cryptography.hazmat.primitives.asymmetric.utils import Prehashed\n\nif typing.TYPE_CHECKING:\n    from cryptography.hazmat.backends.openssl.backend import Backend\n\n\ndef _evp_pkey_derive(backend: \"Backend\", evp_pkey, peer_public_key) -> bytes:\n    ctx = backend._lib.EVP_PKEY_CTX_new(evp_pkey, backend._ffi.NULL)\n    backend.openssl_assert(ctx != backend._ffi.NULL)\n    ctx = backend._ffi.gc(ctx, backend._lib.EVP_PKEY_CTX_free)\n    res = backend._lib.EVP_PKEY_derive_init(ctx)\n    backend.openssl_assert(res == 1)\n    res = backend._lib.EVP_PKEY_derive_set_peer(ctx, peer_public_key._evp_pkey)\n    backend.openssl_assert(res == 1)\n    keylen = backend._ffi.new(\"size_t *\")\n    res = backend._lib.EVP_PKEY_derive(ctx, backend._ffi.NULL, keylen)\n    backend.openssl_assert(res == 1)\n    backend.openssl_assert(keylen[0] > 0)\n    buf = backend._ffi.new(\"unsigned char[]\", keylen[0])\n    res = backend._lib.EVP_PKEY_derive(ctx, buf, keylen)\n    if res != 1:\n        errors_with_text = backend._consume_errors_with_text()\n        raise ValueError(\"Error computing shared key.\", errors_with_text)\n\n    return backend._ffi.buffer(buf, keylen[0])[:]\n\n\ndef _calculate_digest_and_algorithm(\n    data: bytes,\n    algorithm: typing.Union[Prehashed, hashes.HashAlgorithm],\n) -> typing.Tuple[bytes, hashes.HashAlgorithm]:\n    if not isinstance(algorithm, Prehashed):\n        hash_ctx = hashes.Hash(algorithm)\n        hash_ctx.update(data)\n        data = hash_ctx.finalize()\n    else:\n        algorithm = algorithm._algorithm\n\n    if len(data) != algorithm.digest_size:\n        raise ValueError(\n            \"The provided data must be the same length as the hash \"\n            \"algorithm's digest size.\"\n        )\n\n    return (data, algorithm)\n", "path": "src/cryptography/hazmat/backends/openssl/utils.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nimport typing\n\nfrom cryptography.hazmat.primitives import hashes\nfrom cryptography.hazmat.primitives.asymmetric.utils import Prehashed\n\nif typing.TYPE_CHECKING:\n    from cryptography.hazmat.backends.openssl.backend import Backend\n\n\ndef _evp_pkey_derive(backend: \"Backend\", evp_pkey, peer_public_key) -> bytes:\n    ctx = backend._lib.EVP_PKEY_CTX_new(evp_pkey, backend._ffi.NULL)\n    backend.openssl_assert(ctx != backend._ffi.NULL)\n    ctx = backend._ffi.gc(ctx, backend._lib.EVP_PKEY_CTX_free)\n    res = backend._lib.EVP_PKEY_derive_init(ctx)\n    backend.openssl_assert(res == 1)\n    res = backend._lib.EVP_PKEY_derive_set_peer(ctx, peer_public_key._evp_pkey)\n    if res != 1:\n        errors_with_text = backend._consume_errors_with_text()\n        raise ValueError(\"Error computing shared key.\", errors_with_text)\n\n    keylen = backend._ffi.new(\"size_t *\")\n    res = backend._lib.EVP_PKEY_derive(ctx, backend._ffi.NULL, keylen)\n    backend.openssl_assert(res == 1)\n    backend.openssl_assert(keylen[0] > 0)\n    buf = backend._ffi.new(\"unsigned char[]\", keylen[0])\n    res = backend._lib.EVP_PKEY_derive(ctx, buf, keylen)\n    if res != 1:\n        errors_with_text = backend._consume_errors_with_text()\n        raise ValueError(\"Error computing shared key.\", errors_with_text)\n\n    return backend._ffi.buffer(buf, keylen[0])[:]\n\n\ndef _calculate_digest_and_algorithm(\n    data: bytes,\n    algorithm: typing.Union[Prehashed, hashes.HashAlgorithm],\n) -> typing.Tuple[bytes, hashes.HashAlgorithm]:\n    if not isinstance(algorithm, Prehashed):\n        hash_ctx = hashes.Hash(algorithm)\n        hash_ctx.update(data)\n        data = hash_ctx.finalize()\n    else:\n        algorithm = algorithm._algorithm\n\n    if len(data) != algorithm.digest_size:\n        raise ValueError(\n            \"The provided data must be the same length as the hash \"\n            \"algorithm's digest size.\"\n        )\n\n    return (data, algorithm)\n", "path": "src/cryptography/hazmat/backends/openssl/utils.py"}]}