Lines Matching refs:self

103     def __init__(self, val_a: str, val_b: str = "0", bits_in_limb: int = 32) -> None:  argument
104 self.val_a = val_a
105 self.val_b = val_b
108 self.int_a = hex_to_int(val_a)
109 self.int_b = hex_to_int(val_b)
110 if bits_in_limb not in self.limb_sizes:
112 if self.input_style == "arch_split":
113 self.dependencies = ["MBEDTLS_HAVE_INT{:d}".format(bits_in_limb)]
114 self.bits_in_limb = bits_in_limb
117 def boundary(self) -> int: argument
118 if self.arity == 1:
119 return self.int_a
120 elif self.arity == 2:
121 return max(self.int_a, self.int_b)
125 def limb_boundary(self) -> int: argument
126 return bound_mpi(self.boundary, self.bits_in_limb)
129 def limbs(self) -> int: argument
130 return limbs_mpi(self.boundary, self.bits_in_limb)
133 def hex_digits(self) -> int: argument
134 return 2 * (self.limbs * self.bits_in_limb // 8)
136 def format_arg(self, val) -> str: argument
137 if self.input_style not in self.input_styles:
139 if self.input_style == "variable":
142 return val.zfill(self.hex_digits)
144 def format_result(self, res) -> str: argument
146 return quote_str(self.format_arg(res_str))
149 def arg_a(self) -> str: argument
150 return self.format_arg(self.val_a)
153 def arg_b(self) -> str: argument
154 if self.arity == 1:
156 return self.format_arg(self.val_b)
158 def arguments(self) -> List[str]: argument
159 args = [quote_str(self.arg_a)]
160 if self.arity == 2:
161 args.append(quote_str(self.arg_b))
162 return args + self.result()
164 def description(self) -> str: argument
171 if not self.case_description:
172 if self.arity == 1:
173 self.case_description = "{} {:x}".format(
174 self.symbol, self.int_a
176 elif self.arity == 2:
177 self.case_description = "{:x} {} {:x}".format(
178 self.int_a, self.symbol, self.int_b
183 def is_valid(self) -> bool: argument
187 def result(self) -> List[str]: argument
246 def __init__(self, val_n: str, val_a: str, val_b: str = "0", argument
249 self.val_n = val_n
252 self.int_n = hex_to_int(val_n)
254 def to_montgomery(self, val: int) -> int: argument
255 return (val * self.r) % self.int_n
257 def from_montgomery(self, val: int) -> int: argument
258 return (val * self.r_inv) % self.int_n
261 def boundary(self) -> int: argument
262 return self.int_n
265 def arg_n(self) -> str: argument
266 return self.format_arg(self.val_n)
268 def arguments(self) -> List[str]: argument
269 return [quote_str(self.arg_n)] + super().arguments()
272 def r(self) -> int: # pylint: disable=invalid-name argument
273 l = limbs_mpi(self.int_n, self.bits_in_limb)
274 return bound_mpi_limbs(l, self.bits_in_limb)
277 def r_inv(self) -> int: argument
278 return invmod(self.r, self.int_n)
281 def r2(self) -> int: # pylint: disable=invalid-name argument
282 return pow(self.r, 2)
285 def is_valid(self) -> bool: argument
286 if self.int_a >= self.int_n:
288 if self.arity == 2 and self.int_b >= self.int_n:
292 def description(self) -> str: argument
299 if not self.case_description:
300 return super().description() + " mod {:x}".format(self.int_n)