mirror of
https://github.com/The-Art-of-Hacking/h4cker.git
synced 2024-10-01 01:25:43 -04:00
39 lines
923 B
Markdown
39 lines
923 B
Markdown
|
# Challenge 6: Digital Signature Forgery
|
||
|
|
||
|
**Level:** Advanced
|
||
|
|
||
|
**Description:**
|
||
|
Provide a digital signature scheme with a weakness (e.g., using a small prime number). Forge a digital signature for a new message.
|
||
|
|
||
|
**Challenge Text:**
|
||
|
```
|
||
|
Signature scheme: RSA with n = 391, e = 3, d = 107
|
||
|
Signed message: ("HELLO", signature = 220)
|
||
|
Challenge: Forge a signature for the message "WORLD"
|
||
|
```
|
||
|
|
||
|
**Instructions:**
|
||
|
1. Understand the weakness in the provided RSA signature scheme.
|
||
|
2. Forge a signature for the new message.
|
||
|
3. Validate the forged signature.
|
||
|
|
||
|
|
||
|
**Answer:**
|
||
|
For the message "WORLD," a forged signature could be 115.
|
||
|
|
||
|
**Code:**
|
||
|
```python
|
||
|
n = 391
|
||
|
e = 3
|
||
|
message = "WORLD"
|
||
|
|
||
|
# Compute numeric representation of message
|
||
|
message_numeric = sum([ord(c) * (256 ** i) for i, c in enumerate(message[::-1])])
|
||
|
|
||
|
# Compute forged signature
|
||
|
forged_signature = message_numeric ** e % n
|
||
|
|
||
|
print("Forged signature:", forged_signature)
|
||
|
```
|
||
|
|