+ int -> bytes conversion fix

This commit is contained in:
titus 2024-12-29 15:23:01 +01:00
parent e5782f5674
commit 91db649c9c
3 changed files with 11 additions and 4 deletions

View File

@ -11,4 +11,4 @@ from pyplayready.system.pssh import *
from pyplayready.system.session import *
__version__ = "0.4.4"
__version__ = "0.4.5"

View File

@ -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()

View File

@ -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"]