Viewing File: /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyc
ó
Â/¾Oc @ s× d Z d Z d g Z d d l Z e j d d k rT e j d d k rT d d l Tn d d l m Z m Z m Z d
e
f d „ ƒ YZ d e f d
„ ƒ YZ
d d d d d „ Z d e f d „ ƒ YZ d d „ Z d S( sU Pure Python implementation of the RSA-related portions of Crypto.PublicKey._fastmath.s $Id$t
rsa_constructiÿÿÿÿNi i i ( t *( t sizet inverset GCDt errorc B s e Z RS( ( t __name__t
__module__( ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR % s t _RSAKeyc B sP e Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( c C s | t | | j | j ƒ S( N( t powt et n( t selft mt r( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _blind) s c C s t | | j ƒ | | j S( N( R R ( R R
R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _unblind- s c C sí | j ƒ s t d ƒ ‚ n t | d ƒ r× t | d ƒ r× t | d ƒ r× t | | j | j d | j ƒ } t | | j | j d | j ƒ } | | } | d k r´ | | j } n | | j | j } | | j | St | | j | j ƒ S( Ns No private keyt pt qt ui i ( t has_privatet TypeErrort hasattrR t dR R R R ( R t ct m1t m2t h( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _decrypt1 s -##
c C s t | | j | j ƒ S( N( R R
R ( R R
( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _encrypt? s c C s( | j ƒ s t d ƒ ‚ n | j | ƒ S( Ns No private key( R R R ( R R
( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _signC s c C s | j | ƒ | k S( N( R ( R R
t sig( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt _verifyH s c C s
t | d ƒ S( NR ( R ( R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR K s c C s t | j ƒ d S( s7 Return the maximum number of bits that can be encryptedi ( R R ( R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR N s (
R R R R R R R R R R ( ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR ( s c
C s t | t ƒ s t ‚ t | t ƒ s* t ‚ t | t t d ƒ f ƒ sK t ‚ t | t t d ƒ f ƒ sl t ‚ t | t t d ƒ f ƒ s t ‚ t | t t d ƒ f ƒ s® t ‚ t ƒ } | | _ | | _ | d k rÙ | S| | _ | d k r| d k r| | _ | | _
n>| | d } | } x' | d d k rLt | d ƒ d } q&Wd } d }
xª | r|
d k r| } x€ | | k r÷t |
| | ƒ } | d k rê| | d k rêt | d | ƒ d k rêt
| d | ƒ | _ d } Pn | d } qxW|
d }
q\W| st d ƒ ‚ n | | j d k s4t ‚ t | | j ƒ d | _
| d k re| | _ n t | j | j
ƒ | _ | S( s Construct an RSAKey objecti i i id s2 Unable to compute factors p and q from exponent d.N( t
isinstancet longt AssertionErrort typet NoneR R R
R R R t divmodR R t
ValueErrorR R (
R R
R R R R t objt ktott tt spottedt at kt cand( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR R sN !!!! 4t _DSAKeyc B s, e Z d „ Z d „ Z d „ Z d „ Z RS( c C s t | j ƒ d S( s7 Return the maximum number of bits that can be encryptedi ( R R ( R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR s c C s
t | d ƒ S( Nt x( R ( R ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR “ s c C s | j ƒ s t d ƒ ‚ n d | k o5 | j k n sI t d ƒ ‚ n t | | j ƒ } t | j | | j ƒ | j } | | | j | | j } | | f S( Ns No private keyl s k is not between 2 and q-1( R R R R' R R t gR R0 ( R R
R- t inv_kR t s( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR – s c C s¾ d | k o | j k n s@ d | k o: | j k n rD t St | | j ƒ } | | | j } | | | j } t | j | | j ƒ t | j | | j ƒ | j | j } | | k S( Ni ( R t FalseR R R1 R t y( R R
R R3 t wt u1t u2t v( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR ¡ s @<( R R R R R R ( ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyR/ Ž s c C s¾ t | t ƒ s t ‚ t | t ƒ s* t ‚ t | t ƒ s? t ‚ t | t ƒ sT t ‚ t | t t d ƒ f ƒ su t ‚ t ƒ } | | _ | | _ | | _ | | _ | d k rº | | _
n | S( N( R! R"