Beispiel #1
0
 def rsadp(self, c):
     if not (0 <= c <= self.n - 1):
         raise exceptions.CiphertextRepresentativeOutOfRange
     R = 1
     m = 0
     if self.blind:
         c = (c * self.blind) % self.n
     for prime, exponent, crt in zip(self.primes, self.exponents, self.crts):
         m_i = primitives._pow(c, exponent, prime)
         h = ((m_i - m) * crt) % prime
         m += R * h
         R *= prime
     if self.blind_inv:
         m = (m * self.blind_inv) % self.n
     return m
Beispiel #2
0
 def rsadp(self, c):
     if not (0 <= c <= self.n-1):
         raise exceptions.CiphertextRepresentativeOutOfRange
     R = 1
     m = 0
     if self.blind:
         c = (c * self.blind) % self.n
     for prime, exponent, crt in zip(self.primes, self.exponents, self.crts):
         m_i = primitives._pow(c, exponent, prime)
         h = ((m_i - m) * crt) % prime
         m += R * h
         R *= prime
     if self.blind_inv:
         m = (m * self.blind_inv) % self.n
     return m
Beispiel #3
0
 def rsadp(self, c):
     if not (0 <= c <= self.n - 1):
         raise exceptions.CiphertextRepresentativeOutOfRange
     return primitives._pow(c, self.d, self.n)
Beispiel #4
0
 def rsaep(self, m):
     if not (0 <= m <= self.n - 1):
         raise exceptions.MessageRepresentativeOutOfRange
     return primitives._pow(m, self.e, self.n)
Beispiel #5
0
 def rsadp(self, c):
     if not (0 <= c <= self.n-1):
         raise exceptions.CiphertextRepresentativeOutOfRange
     return primitives._pow(c, self.d, self.n)
Beispiel #6
0
 def rsaep(self, m):
     if not (0 <= m <= self.n-1):
         raise exceptions.MessageRepresentativeOutOfRange
     return primitives._pow(m, self.e, self.n)