Skip to content

Commit cdedf88

Browse files
author
tuxmike
committed
Add check for Key Degradation Attack
1 parent 43d0b84 commit cdedf88

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/spake2/spake2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class WrongGroupError(SPAKEError):
2525
pass
2626
class ReflectionThwarted(SPAKEError):
2727
"""Someone tried to reflect our message back to us."""
28+
class KeyDegradationThwarted(SPAKEError):
29+
"""Someone tried to degrade our key material."""
2830

2931
SideA = b"A"
3032
SideB = b"B"
@@ -113,6 +115,8 @@ def finish(self, inbound_side_and_message):
113115
# ) * self.xy_scalar
114116
pw_unblinding = self.my_unblinding().scalarmult(-self.pw_scalar)
115117
K_elem = inbound_elem.add(pw_unblinding).scalarmult(self.xy_scalar)
118+
if K_elem is g.Zero:
119+
raise KeyDegradationThwarted
116120
K_bytes = K_elem.to_bytes()
117121
key = self._finalize(K_bytes)
118122
return key

0 commit comments

Comments
 (0)