mirror of
https://github.com/godotengine/buildroot.git
synced 2026-01-02 21:48:20 +03:00
SPAKE2 password-authenticated key exchange (in pure python).
This library implements the SPAKE2 password-authenticated key
exchange ("PAKE") algorithm. This allows two parties, who share a
weak password, to safely derive a strong shared secret (and
therefore build an encrypted+authenticated channel).
https://github.com/warner/python-spake2
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
23 lines
448 B
Python
23 lines
448 B
Python
from binascii import hexlify
|
|
|
|
from spake2 import SPAKE2_A, SPAKE2_B
|
|
|
|
|
|
shared_password = b"This Is The Password!"
|
|
|
|
alice = SPAKE2_A(shared_password)
|
|
alice_msg = alice.start()
|
|
|
|
bob = SPAKE2_B(shared_password)
|
|
bob_msg = bob.start()
|
|
|
|
# Alice and Bob exchange their messages...
|
|
|
|
alice_key = alice.finish(bob_msg)
|
|
bob_key = bob.finish(alice_msg)
|
|
|
|
print("alice_key:", hexlify(alice_key))
|
|
print(" bob_key:", hexlify(bob_key))
|
|
|
|
assert alice_key == bob_key
|