ó
Â/¾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 ƒ } | | _ | | _ | d k r+ | S| | _ | d k ra | d k ra | | _ | | _ n%| | d } | } x' | d d k rž t | d ƒ d } qx Wd } d }
xª | rW|
d k rW| } x€ | | k rIt |
| | ƒ } | d k r<| | d k r<t | d | ƒ d k r<t | d | ƒ | _ d } Pn | d } qÊ W|
d }
q® W| smt
d ƒ ‚ n t | | j ƒ d | _ | d k rž| | _ 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(
R R R
t NoneR 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 s@ 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 R, ( 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 R- R t y( R R
R R/ 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 sI t ƒ } | | _ | | _ | | _ | | _ | d k rE | | _ n | S( N( R+ R1 R- R R R! R, ( R1 R- R R R, R$ ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt
dsa_construct« s ( t __doc__t __revision__t __all__t syst version_infot Crypto.Util.py21compatt Crypto.Util.numberR R R t ExceptionR t objectR R! R R+ R6 ( ( ( s@ /usr/lib64/python2.7/site-packages/Crypto/PublicKey/_slowmath.pyt <module> s &
*<