Spaces:
Sleeping
Sleeping
Igor commited on
Security: Harden HKDF with salt and identity binding; fix stealth collision
Browse files- crypto.py +4 -3
- docs/KANBAN.md +2 -0
- stealth.py +1 -1
crypto.py
CHANGED
|
@@ -58,11 +58,12 @@ class ShitposterCrypto:
|
|
| 58 |
i_am_alice = False
|
| 59 |
|
| 60 |
# 3. HKDF Expand (64 bytes)
|
|
|
|
| 61 |
derived_material = HKDF(
|
| 62 |
algorithm=hashes.SHA256(),
|
| 63 |
-
length=64, # 32 bytes for
|
| 64 |
-
salt=
|
| 65 |
-
info=b'
|
| 66 |
).derive(shared_secret)
|
| 67 |
|
| 68 |
key_a = derived_material[:32]
|
|
|
|
| 58 |
i_am_alice = False
|
| 59 |
|
| 60 |
# 3. HKDF Expand (64 bytes)
|
| 61 |
+
# We use a protocol-specific salt and bind the identities into info
|
| 62 |
derived_material = HKDF(
|
| 63 |
algorithm=hashes.SHA256(),
|
| 64 |
+
length=64, # 32 bytes for tx, 32 bytes for rx
|
| 65 |
+
salt=b'shitposter-handshake-v2-salt',
|
| 66 |
+
info=b'session-keys|' + context_info,
|
| 67 |
).derive(shared_secret)
|
| 68 |
|
| 69 |
key_a = derived_material[:32]
|
docs/KANBAN.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
## Backlog
|
| 4 |
|
| 5 |
### Cryptography Improvements
|
|
|
|
| 6 |
- [ ] **Forward Secrecy Strategy:** Investigate a "Ratchet" mechanism or ephemeral session keys. Currently, compromise of the static Identity Key compromises all historical messages.
|
| 7 |
|
| 8 |
### Features
|
|
@@ -19,6 +20,7 @@
|
|
| 19 |
*(None)*
|
| 20 |
|
| 21 |
## Done
|
|
|
|
| 22 |
- [x] **Bind Context in HKDF:** Bind sorted public keys into HKDF `info`.
|
| 23 |
- [x] **Directional Key Separation:** Derive separate TX/RX keys to prevent reflection attacks.
|
| 24 |
- [x] **Core Crypto:** X25519 + AES-256-GCM.
|
|
|
|
| 3 |
## Backlog
|
| 4 |
|
| 5 |
### Cryptography Improvements
|
| 6 |
+
- [ ] **Nonce Tracking / Replay Protection:** Implement a mechanism to prevent replay attacks. Since the protocol is currently stateless and asynchronous, investigate using a time-windowed nonce cache or an embedded sequence number in the payload.
|
| 7 |
- [ ] **Forward Secrecy Strategy:** Investigate a "Ratchet" mechanism or ephemeral session keys. Currently, compromise of the static Identity Key compromises all historical messages.
|
| 8 |
|
| 9 |
### Features
|
|
|
|
| 20 |
*(None)*
|
| 21 |
|
| 22 |
## Done
|
| 23 |
+
- [x] **Harden HKDF:** Added protocol salt and explicit identity binding into `info`.
|
| 24 |
- [x] **Bind Context in HKDF:** Bind sorted public keys into HKDF `info`.
|
| 25 |
- [x] **Directional Key Separation:** Derive separate TX/RX keys to prevent reflection attacks.
|
| 26 |
- [x] **Core Crypto:** X25519 + AES-256-GCM.
|
stealth.py
CHANGED
|
@@ -28,7 +28,7 @@ TEMPLATES = [
|
|
| 28 |
CONNECTORS = [
|
| 29 |
"Essentially,", "Basically,", "Actually,", "Honestly speaking,",
|
| 30 |
"Regarding the issue,", "Concerning the spec,", "With respect to the logs,",
|
| 31 |
-
"Even if we ignore that,", "Unless the
|
| 32 |
]
|
| 33 |
|
| 34 |
def generate_stealth_text(payload_words):
|
|
|
|
| 28 |
CONNECTORS = [
|
| 29 |
"Essentially,", "Basically,", "Actually,", "Honestly speaking,",
|
| 30 |
"Regarding the issue,", "Concerning the spec,", "With respect to the logs,",
|
| 31 |
+
"Even if we ignore that,", "Unless the setup is wrong,"
|
| 32 |
]
|
| 33 |
|
| 34 |
def generate_stealth_text(payload_words):
|