Skip to content

Commit 5e0ca8a

Browse files
committed
WIP: Protect SMP question
1 parent dfe6dec commit 5e0ca8a

File tree

5 files changed

+209
-98
lines changed

5 files changed

+209
-98
lines changed

core/crypto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def otp_encrypt_with_padding(plaintext: bytes, key: bytes, padding_limit: int) -
8585
8686
Args:
8787
plaintext: Data to encrypt.
88-
key: OTP key ( plaintext length + padding).
88+
key: OTP key (>= plaintext length + padding).
8989
padding_limit: Max padding length.
9090
9191
Returns:
@@ -105,7 +105,7 @@ def otp_decrypt_with_padding(ciphertext: bytes, key: bytes) -> bytes:
105105
106106
Args:
107107
ciphertext: Ciphertext bytes.
108-
key: OTP key ( ciphertext length).
108+
key: OTP key (>= ciphertext length).
109109
110110
Returns:
111111
Original plaintext bytes without padding.
@@ -175,7 +175,7 @@ def decrypt_shared_secrets(ciphertext_blob: bytes, private_key: bytes, algorithm
175175
shared_secrets += shared_secret
176176
cursor += cipher_size
177177

178-
return shared_secrets[:otp_pad_size]
178+
return shared_secrets #[:otp_pad_size]
179179

180180
def generate_shared_secrets(public_key: bytes, algorithm: str = None, otp_pad_size: int = OTP_PAD_SIZE):
181181
"""

logic/background_worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ def background_worker(user_data, user_data_lock, ui_queue, stop_flag):
3232
# logger.debug("Data received: %s", json.dumps(response, indent = 2)[:2000])
3333

3434
for message in response["messages"]:
35-
logger.debug("Received data message: %s", json.dumps(message, indent = 2)[:5000])
35+
try:
36+
logger.debug("Received data message: %s", json.dumps(message, indent = 2)[:5000])
37+
except:
38+
print("################# ", message)
3639

3740
# Sanity check universal message fields
3841
if (not "sender" in message) or (not message["sender"].isdigit()) or (len(message["sender"]) != 16):

logic/contacts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def save_contact(user_data: dict, user_data_lock, contact_id: str) -> None:
5959
"our_nonce": None,
6060
"contact_nonce": None,
6161
"smp_step": None,
62+
"tmp_proof": None,
63+
"contact_kem_public_key": None,
64+
"our_kem_keys": {
65+
"private_key": None,
66+
"public_key": None
67+
}
6268
},
6369
"ephemeral_keys": {
6470
"contact_public_keys": {

0 commit comments

Comments
 (0)