mirror of
https://github.com/glomatico/votify.git
synced 2026-10-01 05:22:30 +02:00
Specify big-endian counter bytes
This commit is contained in:
+3
-3
@@ -14,13 +14,13 @@ class TOTP:
|
||||
|
||||
@staticmethod
|
||||
def derive(ciphertext: Collection[int]) -> bytes:
|
||||
return ''.join(
|
||||
return "".join(
|
||||
str(byte ^ ((i % 33) + 9)) for i, byte in enumerate(ciphertext)
|
||||
).encode('ascii')
|
||||
).encode("ascii")
|
||||
|
||||
def generate(self, timestamp: int) -> str:
|
||||
counter = int(timestamp) // 1000 // self.PERIOD
|
||||
counter_bytes = counter.to_bytes(8)
|
||||
counter_bytes = counter.to_bytes(8, "big")
|
||||
|
||||
h = hmac.new(self.secret, counter_bytes, hashlib.sha1)
|
||||
hmac_result = h.digest()
|
||||
|
||||
Reference in New Issue
Block a user