sibna 1.5.0__tar.gz → 1.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sibna-1.5.0/sibna.egg-info → sibna-1.7.0}/PKG-INFO +1 -1
- {sibna-1.5.0 → sibna-1.7.0}/pyproject.toml +1 -1
- {sibna-1.5.0 → sibna-1.7.0}/sibna/client.py +15 -12
- {sibna-1.5.0 → sibna-1.7.0/sibna.egg-info}/PKG-INFO +1 -1
- {sibna-1.5.0 → sibna-1.7.0}/LICENSE +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/MANIFEST.in +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/README.md +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/setup.cfg +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna/__init__.py +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna/_ed25519.py +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna/_websocket.py +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna/sibna_core.dll +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna.egg-info/SOURCES.txt +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna.egg-info/dependency_links.txt +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna.egg-info/top_level.txt +0 -0
- {sibna-1.5.0 → sibna-1.7.0}/sibna_demo/app.py +0 -0
|
@@ -146,23 +146,26 @@ def pad_payload(data: bytes) -> bytes:
|
|
|
146
146
|
"""
|
|
147
147
|
Pad payload to the nearest 1024-byte boundary.
|
|
148
148
|
Makes all messages appear the same size to a passive observer.
|
|
149
|
+
|
|
150
|
+
Format: [padding_len: 2 bytes LE] + [data] + [random padding]
|
|
151
|
+
Total length is always a multiple of 1024.
|
|
149
152
|
"""
|
|
150
|
-
|
|
151
|
-
remainder
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return
|
|
153
|
+
content_len = 2 + len(data)
|
|
154
|
+
remainder = content_len % _PADDING_BLOCK
|
|
155
|
+
padding_len = (_PADDING_BLOCK - remainder) % _PADDING_BLOCK
|
|
156
|
+
header = padding_len.to_bytes(2, "little")
|
|
157
|
+
return header + data + secrets.token_bytes(padding_len)
|
|
155
158
|
|
|
156
159
|
|
|
157
160
|
def unpad_payload(padded: bytes) -> bytes:
|
|
158
161
|
"""Remove padding added by pad_payload()."""
|
|
159
|
-
if
|
|
160
|
-
raise ValueError("
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return padded[
|
|
162
|
+
if len(padded) < 2:
|
|
163
|
+
raise ValueError("Payload too short")
|
|
164
|
+
padding_len = int.from_bytes(padded[:2], "little")
|
|
165
|
+
data_end = len(padded) - padding_len
|
|
166
|
+
if data_end < 2:
|
|
167
|
+
raise ValueError("Invalid padding length")
|
|
168
|
+
return padded[2:data_end]
|
|
166
169
|
|
|
167
170
|
|
|
168
171
|
def make_signed_envelope(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|