Skip to content

Commit 33e9cdd

Browse files
author
Dominikus Gierlach
committed
Remove unrelated string decoding change
1 parent 684d7cb commit 33e9cdd

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

pkcs11/types.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from binascii import hexlify
88
from functools import cached_property
99

10-
import chardet
11-
1210
from pkcs11 import CancelStrategy
1311
from pkcs11.constants import (
1412
Attribute,
@@ -43,17 +41,8 @@ def __hash__(self):
4341

4442

4543
def _CK_UTF8CHAR_to_str(data):
46-
"""Convert _CK_UTF8CHAR_to_str to string using chardet for encoding detection."""
47-
cleaned_data = data.rstrip(b"\0")
48-
49-
detected_encoding = chardet.detect(cleaned_data)
50-
encoding = detected_encoding["encoding"] or "utf-8"
51-
52-
try:
53-
return cleaned_data.decode(encoding).rstrip()
54-
except UnicodeDecodeError:
55-
# If decoding fails, try utf-8 with default error replacement character as a last resort
56-
return cleaned_data.decode("utf-8", errors="replace").rstrip()
44+
"""Convert CK_UTF8CHAR to string."""
45+
return data.rstrip(b"\0").decode("utf-8").rstrip()
5746

5847

5948
def _CK_VERSION_to_tuple(data):

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.13",
2424
"Topic :: Security :: Cryptography",
2525
]
26-
dependencies = [
27-
"asn1crypto>=1.5.1",
28-
"chardet>=5.2.0",
29-
]
26+
dependencies = ["asn1crypto>=1.5.1"]
3027
license = "MIT"
3128
requires-python = ">=3.9"
3229
dynamic = ["version"]
@@ -122,4 +119,4 @@ dev = [
122119
{ include-group = "release" },
123120
]
124121

125-
[tool.setuptools_scm]
122+
[tool.setuptools_scm]

uv.lock

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)