|
30 | 30 | ) |
31 | 31 | from base64 import b64encode, b64decode |
32 | 32 | from core.constants import ( |
33 | | - SMP_TYPE, |
| 33 | + SMP_TYPES, |
34 | 34 | SMP_NONCE_LENGTH, |
35 | 35 | SMP_PROOF_LENGTH, |
36 | 36 | SMP_QUESTION_MAX_LEN, |
@@ -75,7 +75,7 @@ def initiate_smp(user_data: dict, user_data_lock: threading.Lock, contact_id: st |
75 | 75 | "recipient": contact_id |
76 | 76 | }, |
77 | 77 | headers = session_headers, |
78 | | - blob = SMP_TYPE + kem_public_key, |
| 78 | + blob = SMP_TYPES["SMP_INIT"] + kem_public_key, |
79 | 79 | auth_token = auth_token |
80 | 80 | ) |
81 | 81 | except Exception as e: |
@@ -136,7 +136,7 @@ def smp_step_2(user_data: dict, user_data_lock, contact_id: str, blob: bytes, ui |
136 | 136 | http_request(f"{server_url}/data/send", "POST", metadata = { |
137 | 137 | "recipient": contact_id |
138 | 138 | }, |
139 | | - blob = SMP_TYPE + key_ciphertext + ciphertext_nonce + ciphertext_blob, |
| 139 | + blob = SMP_TYPES["SMP_INIT"] + key_ciphertext + ciphertext_nonce + ciphertext_blob, |
140 | 140 | headers = session_headers, |
141 | 141 | auth_token = auth_token |
142 | 142 | ) |
@@ -215,7 +215,7 @@ def smp_step_3(user_data: dict, user_data_lock: threading.Lock, contact_id: str, |
215 | 215 | our_new_strand_nonce = sha3_512(secrets.token_bytes(XCHACHA20POLY1305_NONCE_LEN))[:XCHACHA20POLY1305_NONCE_LEN] |
216 | 216 | _, ciphertext_blob = encrypt_xchacha20poly1305( |
217 | 217 | chacha_key, |
218 | | - SMP_TYPE + our_new_strand_nonce + signing_public_key + our_nonce + our_proof + question.encode("utf-8"), |
| 218 | + SMP_TYPES["SMP_INIT"] + our_new_strand_nonce + signing_public_key + our_nonce + our_proof + question.encode("utf-8"), |
219 | 219 | nonce = our_next_strand_nonce |
220 | 220 | ) |
221 | 221 |
|
@@ -348,7 +348,7 @@ def smp_step_4_answer_provided(user_data, user_data_lock, contact_id, answer, ui |
348 | 348 | our_new_strand_nonce = sha3_512(secrets.token_bytes(XCHACHA20POLY1305_NONCE_LEN))[:XCHACHA20POLY1305_NONCE_LEN] |
349 | 349 | _, ciphertext_blob = encrypt_xchacha20poly1305( |
350 | 350 | tmp_key, |
351 | | - SMP_TYPE + our_new_strand_nonce + our_proof + our_strand_key + contact_strand_key, |
| 351 | + SMP_TYPES["SMP_INIT"] + our_new_strand_nonce + our_proof + our_strand_key + contact_strand_key, |
352 | 352 | nonce = our_next_strand_nonce |
353 | 353 | ) |
354 | 354 |
|
@@ -513,7 +513,7 @@ def smp_failure_notify_contact(user_data, user_data_lock, contact_id, ui_queue) |
513 | 513 | # it can be any number other than 2, we chose 7 because failure is *technically* the 7th smp step. |
514 | 514 | ciphertext_nonce, ciphertext_blob = encrypt_xchacha20poly1305( |
515 | 515 | tmp_key, |
516 | | - SMP_TYPE + b"failure", |
| 516 | + SMP_TYPES["SMP_INIT"] + b"failure", |
517 | 517 | counter = 7 |
518 | 518 | ) |
519 | 519 | try: |
@@ -550,12 +550,14 @@ def smp_data_handler(user_data, user_data_lock, user_data_copied, ui_queue, cont |
550 | 550 | except Exception: |
551 | 551 | smp_step = 2 |
552 | 552 |
|
553 | | - |
554 | 553 |
|
555 | 554 | if user_data_copied["settings"]["ignore_new_contacts_smp"]: |
556 | 555 | logger.info("Skipping SMP request because you have set to ignore new contacts requests.") |
557 | 556 | return |
558 | 557 |
|
| 558 | + |
| 559 | + # TEMPORARIY, UNTIL WE REWORK SMP STEP HANDLING |
| 560 | + message = message[1:] |
559 | 561 |
|
560 | 562 |
|
561 | 563 | if message == b"failure": |
|
0 commit comments