diff --git a/pyplayready/__init__.py b/pyplayready/__init__.py index c54646c..7a4435e 100644 --- a/pyplayready/__init__.py +++ b/pyplayready/__init__.py @@ -11,4 +11,4 @@ from pyplayready.system.pssh import * from pyplayready.system.session import * -__version__ = "0.4.4" +__version__ = "0.4.5" diff --git a/pyplayready/crypto/ecc_key.py b/pyplayready/crypto/ecc_key.py index 01c497c..2baab46 100644 --- a/pyplayready/crypto/ecc_key.py +++ b/pyplayready/crypto/ecc_key.py @@ -68,11 +68,18 @@ class ECCKey: path.parent.mkdir(parents=True, exist_ok=True) path.write_bytes(self.dumps(private_only)) + @staticmethod + def _to_bytes(n: int) -> bytes: + byte_len = (n.bit_length() + 7) // 8 + if byte_len % 2 != 0: + byte_len += 1 + return n.to_bytes(byte_len, 'big') + def get_point(self, curve: Curve) -> Point: return Point(self.key.pointQ.x, self.key.pointQ.y, curve) def private_bytes(self) -> bytes: - return self.key.d.to_bytes() + return self._to_bytes(int(self.key.d)) def private_sha256_digest(self) -> bytes: hash_object = SHA256.new() @@ -80,7 +87,7 @@ class ECCKey: return hash_object.digest() def public_bytes(self) -> bytes: - return self.key.pointQ.x.to_bytes() + self.key.pointQ.y.to_bytes() + return self._to_bytes(int(self.key.pointQ.x)) + self._to_bytes(int(self.key.pointQ.y)) def public_sha256_digest(self) -> bytes: hash_object = SHA256.new() diff --git a/pyproject.toml b/pyproject.toml index a817d52..3f725d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pyplayready" -version = "0.4.4" +version = "0.4.5" description = "pyplayready CDM (Content Decryption Module) implementation in Python." license = "CC BY-NC-ND 4.0" authors = ["DevLARLEY, Erevoc", "DevataDev"]