bambi7-service-fireworx

ESDSA-signed firework A/D service for BambiCTF7 in 2022
git clone https://git.sinitax.com/sinitax/bambi7-service-fireworx
Log | Files | Refs | README | LICENSE | sfeed.txt

patch.diff (710B)


      1diff --git a/service/crypto.py b/service/crypto.py
      2index 35c67e5..2799c23 100644
      3--- a/service/crypto.py
      4+++ b/service/crypto.py
      5@@ -56,7 +56,7 @@ class DSAKey:
      6         return DSAPubKey(self.p, self.q, self.g, self.y)
      7 
      8     def sign(self, msg):
      9-        k = H(self.y)
     10+        k = number.getRandomRange(1, self.q)
     11         r = pow(self.g, k, self.p) % self.q
     12         s = inverse(k, self.q) * (H(msg) + r * self.x) % self.q
     13         return r, s
     14@@ -82,6 +82,8 @@ class DSAPubKey:
     15 
     16     def verify(self, msg, signature):
     17         r, s = signature
     18+        if r == 1 and s % self.q == 0:
     19+            return False
     20         w = inverse(s, self.q)
     21         u1 = H(msg) * w % self.q
     22         u2 = r * w % self.q