diff --git a/setup.py b/setup.py index 2c93a2b..81dcc25 100755 --- a/setup.py +++ b/setup.py @@ -60,7 +60,6 @@ setup( packages=find_packages(), setup_requires=["cffi>=1.17"], - install_requires=["cffi>=1.17"], cffi_modules=["./scripts/build_ffi.py:ffibuilder"], package_data={"wolfcrypt": ["*.dll", "**/*.pyi", "py.typed"]}, diff --git a/wolfcrypt/ciphers.py b/wolfcrypt/ciphers.py index e5a8920..61a9b21 100644 --- a/wolfcrypt/ciphers.py +++ b/wolfcrypt/ciphers.py @@ -2092,6 +2092,14 @@ if _lib.ML_KEM_ENABLED: :return: tuple of a shared secret (first element) and the cipher text (second element) :rtype: tuple[bytes, bytes] """ + + try: + memoryview(rand) + except TypeError as exception: + raise TypeError("rand must support the buffer protocol, such as `bytes` or `bytearray`") from exception + + rand = bytes(rand) + ct_size = self.ct_size ss_size = self.ss_size ct = _ffi.new(f"unsigned char[{ct_size}]")