MCPcopy Create free account
hub / github.com/Apress/practical-cryptography-in-python / attack

Method attack

src/rsa_oracle_attack.py:136–162  ·  view source on GitHub ↗
(self, c)

Source from the content-addressed store, hash-verified

134
135# RSA Oracle Attack Component, part of class RSAOracleAttacker
136 def attack(self, c):
137 self.stats.append(RSAStat())
138 t0 = time.time()
139 self._step1_blinding(c)
140
141 # do this until there is one interval left
142 finished = False
143 while not finished:
144 if self.i == 1:
145 si = self._step2a_start_the_searching()
146 elif len(self.M[-1]) > 1:
147 si = self._step2b_searching_with_more_than_one_interval()
148 elif len(self.M[-1]) == 1:
149 interval = self.M[-1][0]
150 si = self._step2c_searching_with_one_interval_left()
151
152 print("Found! i={} si={}".format(self.i, si))
153 finished = self._step3_narrowing_set_of_solutions(si)
154 self.i += 1
155
156 print("Found solution")
157 m = self._step4_computing_the_solution()
158
159 tn = time.time()
160 self.stats[-1].i = self.i
161 self.stats[-1].runtime = tn - t0
162 return m
163
164def main(args):
165 key_size, messagecount = [int(arg) for arg in args]

Callers 1

mainFunction · 0.95

Tested by

no test coverage detected